001package org.hl7.fhir.convertors.conv14_40; 002 003import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_14_40; 004import org.hl7.fhir.convertors.context.ConversionContext14_40; 005import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Element14_40; 006import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Type14_40; 007import org.hl7.fhir.convertors.conv14_40.resources14_40.Resource14_40; 008import org.hl7.fhir.dstu2016may.model.CodeableConcept; 009import org.hl7.fhir.exceptions.FHIRException; 010 011import javax.annotation.Nonnull; 012import java.util.ArrayList; 013import java.util.List; 014 015/* 016 Copyright (c) 2011+, HL7, Inc. 017 All rights reserved. 018 019 Redistribution and use in source and binary forms, with or without modification, 020 are permitted provided that the following conditions are met: 021 022 * Redistributions of source code must retain the above copyright notice, this 023 list of conditions and the following disclaimer. 024 * Redistributions in binary form must reproduce the above copyright notice, 025 this list of conditions and the following disclaimer in the documentation 026 and/or other materials provided with the distribution. 027 * Neither the name of HL7 nor the names of its contributors may be used to 028 endorse or promote products derived from this software without specific 029 prior written permission. 030 031 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 032 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 033 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 034 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 035 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 036 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 037 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 038 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 039 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 040 POSSIBILITY OF SUCH DAMAGE. 041 */ 042 043public class VersionConvertor_14_40 { 044 static public List<String> CANONICAL_URLS = new ArrayList<String>(); 045 046 static { 047 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap"); 048 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset"); 049 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map"); 050 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library"); 051 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits"); 052 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet"); 053 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet"); 054 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet"); 055 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical"); 056 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile"); 057 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap"); 058 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap"); 059 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap"); 060 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet"); 061 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map"); 062 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement"); 063 CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system"); 064 } 065 066 private final BaseAdvisor_14_40 advisor; 067 private final Element14_40 elementConvertor; 068 private final Resource14_40 resourceConvertor; 069 private final Type14_40 typeConvertor; 070 071 public VersionConvertor_14_40(@Nonnull BaseAdvisor_14_40 advisor) { 072 this.advisor = advisor; 073 this.elementConvertor = new Element14_40(advisor); 074 this.resourceConvertor = new Resource14_40(advisor); 075 this.typeConvertor = new Type14_40(advisor); 076 } 077 078 static public boolean isJurisdiction(@Nonnull CodeableConcept t) { 079 return t.hasCoding() 080 && ("http://unstats.un.org/unsd/methods/m49/m49.htm".equals(t.getCoding().get(0).getSystem()) 081 || "urn:iso:std:iso:3166".equals(t.getCoding().get(0).getSystem()) 082 || "https://www.usps.com/".equals(t.getCoding().get(0).getSystem())); 083 } 084 085 public BaseAdvisor_14_40 advisor() { 086 return advisor; 087 } 088 089 public void copyResource(@Nonnull org.hl7.fhir.dstu2016may.model.Resource src, 090 @Nonnull org.hl7.fhir.r4.model.Resource tgt) throws FHIRException { 091 resourceConvertor.copyResource(src, tgt); 092 } 093 094 public void copyResource(@Nonnull org.hl7.fhir.r4.model.Resource src, 095 @Nonnull org.hl7.fhir.dstu2016may.model.Resource tgt) throws FHIRException { 096 resourceConvertor.copyResource(src, tgt); 097 } 098 099 public org.hl7.fhir.r4.model.Resource convertResource(@Nonnull org.hl7.fhir.dstu2016may.model.Resource src) throws FHIRException { 100 ConversionContext14_40.INSTANCE.init(this, src.fhirType()); 101 try { 102 return resourceConvertor.convertResource(src); 103 } finally { 104 ConversionContext14_40.INSTANCE.close(src.fhirType()); 105 } 106 } 107 108 public org.hl7.fhir.dstu2016may.model.Resource convertResource(@Nonnull org.hl7.fhir.r4.model.Resource src) throws FHIRException { 109 ConversionContext14_40.INSTANCE.init(this, src.fhirType()); 110 try { 111 return resourceConvertor.convertResource(src); 112 } finally { 113 ConversionContext14_40.INSTANCE.close(src.fhirType()); 114 } 115 } 116 117 public org.hl7.fhir.r4.model.Type convertType(@Nonnull org.hl7.fhir.dstu2016may.model.Type src) throws FHIRException { 118 ConversionContext14_40.INSTANCE.init(this, src.fhirType()); 119 try { 120 return typeConvertor.convertType(src); 121 } finally { 122 ConversionContext14_40.INSTANCE.close(src.fhirType()); 123 } 124 } 125 126 public org.hl7.fhir.dstu2016may.model.Type convertType(@Nonnull org.hl7.fhir.r4.model.Type src) throws FHIRException { 127 ConversionContext14_40.INSTANCE.init(this, src.fhirType()); 128 try { 129 return typeConvertor.convertType(src); 130 } finally { 131 ConversionContext14_40.INSTANCE.close(src.fhirType()); 132 } 133 } 134 135 public void copyDomainResource(@Nonnull org.hl7.fhir.dstu2016may.model.DomainResource src, 136 @Nonnull org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException { 137 resourceConvertor.copyDomainResource(src, tgt); 138 } 139 140 public void copyDomainResource(@Nonnull org.hl7.fhir.r4.model.DomainResource src, 141 @Nonnull org.hl7.fhir.dstu2016may.model.DomainResource tgt) throws FHIRException { 142 resourceConvertor.copyDomainResource(src, tgt); 143 } 144 145 public void copyElement(@Nonnull org.hl7.fhir.dstu2016may.model.Element src, 146 @Nonnull org.hl7.fhir.r4.model.Element tgt, 147 String... var) throws FHIRException { 148 elementConvertor.copyElement(src, tgt, ConversionContext14_40.INSTANCE.path(), var); 149 } 150 151 public void copyElement(@Nonnull org.hl7.fhir.r4.model.Element src, 152 @Nonnull org.hl7.fhir.dstu2016may.model.Element tgt, 153 String... var) throws FHIRException { 154 elementConvertor.copyElement(src, tgt, ConversionContext14_40.INSTANCE.path(), var); 155 } 156}