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