001package org.hl7.fhir.convertors.conv30_50; 002 003import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50; 004import org.hl7.fhir.convertors.context.ConversionContext30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Element30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Type30_50; 007import org.hl7.fhir.exceptions.FHIRException; 008 009import javax.annotation.Nonnull; 010import java.util.ArrayList; 011import java.util.List; 012 013/* 014 Copyright (c) 2011+, HL7, Inc. 015 All rights reserved. 016 017 Redistribution and use in source and binary forms, with or without modification, 018 are permitted provided that the following conditions are met: 019 020 * Redistributions of source code must retain the above copyright notice, this 021 list of conditions and the following disclaimer. 022 * Redistributions in binary form must reproduce the above copyright notice, 023 this list of conditions and the following disclaimer in the documentation 024 and/or other materials provided with the distribution. 025 * Neither the name of HL7 nor the names of its contributors may be used to 026 endorse or promote products derived from this software without specific 027 prior written permission. 028 029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 030 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 031 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 032 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 033 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 034 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 035 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 036 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 037 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 038 POSSIBILITY OF SUCH DAMAGE. 039 */ 040 041public class VersionConvertor_30_50 { 042 static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"; 043 private static final String CODE_SYSTEM_MEDIA_TYPE = "http://terminology.hl7.org/CodeSystem/media-type"; 044 static public List<String> CANONICAL_URLS = new ArrayList<>(); 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_30_50 advisor; 067 private final Element30_50 elementConvertor; 068 private final Resource30_50 resourceConvertor; 069 private final Type30_50 typeConvertor; 070 071 public VersionConvertor_30_50(@Nonnull BaseAdvisor_30_50 advisor) { 072 this.advisor = advisor; 073 this.elementConvertor = new Element30_50(advisor); 074 this.resourceConvertor = new Resource30_50(advisor); 075 this.typeConvertor = new Type30_50(advisor); 076 } 077 078 public BaseAdvisor_30_50 advisor() { 079 return advisor; 080 } 081 082 public void copyResource(@Nonnull org.hl7.fhir.dstu3.model.Resource src, 083 @Nonnull org.hl7.fhir.r5.model.Resource tgt) throws FHIRException { 084 resourceConvertor.copyResource(src, tgt); 085 } 086 087 public void copyResource(@Nonnull org.hl7.fhir.r5.model.Resource src, 088 @Nonnull org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException { 089 resourceConvertor.copyResource(src, tgt); 090 } 091 092 public org.hl7.fhir.r5.model.Resource convertResource(@Nonnull org.hl7.fhir.dstu3.model.Resource src) throws FHIRException { 093 ConversionContext30_50.INSTANCE.init(this, src.fhirType()); 094 try { 095 return resourceConvertor.convertResource(src); 096 } finally { 097 ConversionContext30_50.INSTANCE.close(src.fhirType()); 098 } 099 } 100 101 public org.hl7.fhir.dstu3.model.Resource convertResource(@Nonnull org.hl7.fhir.r5.model.Resource src) throws FHIRException { 102 ConversionContext30_50.INSTANCE.init(this, src.fhirType()); 103 try { 104 return resourceConvertor.convertResource(src); 105 } finally { 106 ConversionContext30_50.INSTANCE.close(src.fhirType()); 107 } 108 } 109 110 public org.hl7.fhir.r5.model.DataType convertType(@Nonnull org.hl7.fhir.dstu3.model.Type src) throws FHIRException { 111 ConversionContext30_50.INSTANCE.init(this, src.fhirType()); 112 try { 113 return typeConvertor.convertType(src); 114 } finally { 115 ConversionContext30_50.INSTANCE.close(src.fhirType()); 116 } 117 } 118 119 public org.hl7.fhir.dstu3.model.Type convertType(@Nonnull org.hl7.fhir.r5.model.DataType src) throws FHIRException { 120 ConversionContext30_50.INSTANCE.init(this, src.fhirType()); 121 try { 122 return typeConvertor.convertType(src); 123 } finally { 124 ConversionContext30_50.INSTANCE.close(src.fhirType()); 125 } 126 } 127 128 public void copyDomainResource(@Nonnull org.hl7.fhir.dstu3.model.DomainResource src, 129 @Nonnull org.hl7.fhir.r5.model.DomainResource tgt) throws FHIRException { 130 resourceConvertor.copyDomainResource(src, tgt); 131 } 132 133 public void copyDomainResource(@Nonnull org.hl7.fhir.r5.model.DomainResource src, 134 @Nonnull org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException { 135 resourceConvertor.copyDomainResource(src, tgt); 136 } 137 138 public void copyElement(@Nonnull org.hl7.fhir.dstu3.model.Element src, 139 @Nonnull org.hl7.fhir.r5.model.Element tgt, 140 String... var) throws FHIRException { 141 elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), var); 142 } 143 144 public void copyElement(@Nonnull org.hl7.fhir.r5.model.Element src, 145 @Nonnull org.hl7.fhir.dstu3.model.Element tgt, 146 String... var) throws FHIRException { 147 elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), var); 148 } 149 150}