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