001package org.hl7.fhir.convertors.conv30_40;
002
003import java.util.ArrayList;
004import java.util.List;
005
006import javax.annotation.Nonnull;
007
008import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
009import org.hl7.fhir.convertors.context.ConversionContext30_40;
010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.BackboneElement30_40;
011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Element30_40;
012import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Type30_40;
013import org.hl7.fhir.convertors.conv30_40.resources30_40.Resource30_40;
014import org.hl7.fhir.exceptions.FHIRException;
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_30_40 {
045  static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type";
046  static final public String URN_IETF_RFC_3986 = "urn:ietf:rfc:3986";
047  static public List<String> CANONICAL_URLS = new ArrayList<>();
048
049  static {
050    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap");
051    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset");
052    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map");
053    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library");
054    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits");
055    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet");
056    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet");
057    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet");
058    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical");
059    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile");
060    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap");
061    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap");
062    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap");
063    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet");
064    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map");
065    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement");
066    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system");
067  }
068
069  private final BaseAdvisor_30_40 advisor;
070  private final Element30_40 elementConvertor;
071
072  private final BackboneElement30_40 backboneElementConvertor;
073
074  private final Resource30_40 resourceConvertor;
075  private final Type30_40 typeConvertor;
076
077  public VersionConvertor_30_40(@Nonnull BaseAdvisor_30_40 advisor) {
078    this.advisor = advisor;
079    this.elementConvertor = new Element30_40(advisor);
080    this.backboneElementConvertor = new BackboneElement30_40();
081    this.resourceConvertor = new Resource30_40(advisor);
082    this.typeConvertor = new Type30_40(advisor);
083  }
084
085  public BaseAdvisor_30_40 advisor() {
086    return advisor;
087  }
088
089  public void copyResource(@Nonnull org.hl7.fhir.dstu3.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.dstu3.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.dstu3.model.Resource src) throws FHIRException {
100    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
101    try {
102      return resourceConvertor.convertResource(src);
103    } finally {
104      ConversionContext30_40.INSTANCE.close(src.fhirType());
105    }
106  }
107
108  public org.hl7.fhir.dstu3.model.Resource convertResource(@Nonnull org.hl7.fhir.r4.model.Resource src) throws FHIRException {
109    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
110    try {
111      return resourceConvertor.convertResource(src);
112    } finally {
113      ConversionContext30_40.INSTANCE.close(src.fhirType());
114    }
115  }
116
117  public org.hl7.fhir.r4.model.Type convertType(@Nonnull org.hl7.fhir.dstu3.model.Type src) throws FHIRException {
118    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
119    try {
120      return typeConvertor.convertType(src);
121    } finally {
122      ConversionContext30_40.INSTANCE.close(src.fhirType());
123    }
124  }
125
126  public org.hl7.fhir.dstu3.model.Type convertType(@Nonnull org.hl7.fhir.r4.model.Type src) throws FHIRException {
127    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
128    try {
129      return typeConvertor.convertType(src);
130    } finally {
131      ConversionContext30_40.INSTANCE.close(src.fhirType());
132    }
133  }
134
135  public void copyDomainResource(@Nonnull org.hl7.fhir.dstu3.model.DomainResource src,
136                                 @Nonnull org.hl7.fhir.r4.model.DomainResource tgt, String... extensionUrlsToIgnore) throws FHIRException {
137    resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
138  }
139
140  public void copyDomainResource(
141    @Nonnull org.hl7.fhir.r4.model.DomainResource src,
142    @Nonnull org.hl7.fhir.dstu3.model.DomainResource tgt,
143    String... extensionUrlsToIgnore) throws FHIRException {
144    resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
145  }
146
147  public void copyElement(
148    @Nonnull org.hl7.fhir.dstu3.model.Element src,
149    @Nonnull org.hl7.fhir.r4.model.Element tgt,
150    String... extensionUrlsToIgnore) throws FHIRException {
151    elementConvertor.copyElement(src, tgt, ConversionContext30_40.INSTANCE.path(), extensionUrlsToIgnore);
152  }
153
154  public void copyElement(
155    @Nonnull org.hl7.fhir.r4.model.Element src,
156    @Nonnull org.hl7.fhir.dstu3.model.Element tgt,
157    String... extensionUrlsToIgnore) throws FHIRException {
158    elementConvertor.copyElement(src, tgt, ConversionContext30_40.INSTANCE.path(), extensionUrlsToIgnore);
159  }
160
161  public void copyBackboneElement(
162    @Nonnull org.hl7.fhir.r4.model.BackboneElement src,
163    @Nonnull org.hl7.fhir.dstu3.model.BackboneElement tgt,
164    String... extensionUrlsToIgnore) throws FHIRException {
165    backboneElementConvertor.copyBackboneElement(src, tgt, extensionUrlsToIgnore);
166  }
167
168  public void copyBackboneElement(
169    @Nonnull org.hl7.fhir.dstu3.model.BackboneElement src,
170    @Nonnull org.hl7.fhir.r4.model.BackboneElement tgt,
171    String... extensionUrlsToIgnore) throws FHIRException {
172    backboneElementConvertor.copyBackboneElement(src, tgt, extensionUrlsToIgnore);
173  }
174}