001package org.hl7.fhir.convertors.conv30_50;
002
003import java.util.ArrayList;
004import java.util.List;
005
006import javax.annotation.Nonnull;
007
008import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50;
009import org.hl7.fhir.convertors.context.ConversionContext30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.BackboneElement30_50;
011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Element30_50;
012import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Type30_50;
013import org.hl7.fhir.exceptions.FHIRException;
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_30_50 {
044  static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type";
045  private static final String CODE_SYSTEM_MEDIA_TYPE = "http://terminology.hl7.org/CodeSystem/media-type";
046  static public List<String> CANONICAL_URLS = new ArrayList<>();
047
048  static {
049    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-conceptmap");
050    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/11179-permitted-value-valueset");
051    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/codesystem-map");
052    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/cqif-library");
053    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits");
054    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-inheritedExtensibleValueSet");
055    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet");
056    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet");
057    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/event-instantiatesCanonical");
058    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-allowedProfile");
059    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-deMap");
060    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-sourceStructureMap");
061    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-targetStructureMap");
062    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/questionnaire-unit-valueSet");
063    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-map");
064    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-supplement");
065    CANONICAL_URLS.add("http://hl7.org/fhir/StructureDefinition/valueset-system");
066  }
067
068  private final BaseAdvisor_30_50 advisor;
069  private final Element30_50 elementConvertor;
070
071  private final BackboneElement30_50 backboneElementConvertor;
072  private final Resource30_50 resourceConvertor;
073  private final Type30_50 typeConvertor;
074
075  public VersionConvertor_30_50(@Nonnull BaseAdvisor_30_50 advisor) {
076    this.advisor = advisor;
077    this.elementConvertor = new Element30_50(advisor);
078    this.backboneElementConvertor = new BackboneElement30_50();
079    this.resourceConvertor = new Resource30_50(advisor);
080    this.typeConvertor = new Type30_50(advisor);
081  }
082
083  public BaseAdvisor_30_50 advisor() {
084    return advisor;
085  }
086
087  public void copyResource(@Nonnull org.hl7.fhir.dstu3.model.Resource src,
088                           @Nonnull org.hl7.fhir.r5.model.Resource tgt) throws FHIRException {
089    resourceConvertor.copyResource(src, tgt);
090  }
091
092  public void copyResource(@Nonnull org.hl7.fhir.r5.model.Resource src,
093                           @Nonnull org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException {
094    resourceConvertor.copyResource(src, tgt);
095  }
096
097  public org.hl7.fhir.r5.model.Resource convertResource(@Nonnull org.hl7.fhir.dstu3.model.Resource src) throws FHIRException {
098    ConversionContext30_50.INSTANCE.init(this, src.fhirType());
099    try {
100      return resourceConvertor.convertResource(src);
101    } finally {
102      ConversionContext30_50.INSTANCE.close(src.fhirType());
103    }
104  }
105
106  public org.hl7.fhir.dstu3.model.Resource convertResource(@Nonnull org.hl7.fhir.r5.model.Resource src) throws FHIRException {
107    ConversionContext30_50.INSTANCE.init(this, src.fhirType());
108    try {
109      return resourceConvertor.convertResource(src);
110    } finally {
111      ConversionContext30_50.INSTANCE.close(src.fhirType());
112    }
113  }
114
115  public org.hl7.fhir.r5.model.DataType convertType(@Nonnull org.hl7.fhir.dstu3.model.Type src) throws FHIRException {
116    ConversionContext30_50.INSTANCE.init(this, src.fhirType());
117    try {
118      return typeConvertor.convertType(src);
119    } finally {
120      ConversionContext30_50.INSTANCE.close(src.fhirType());
121    }
122  }
123
124  public org.hl7.fhir.dstu3.model.Type convertType(@Nonnull org.hl7.fhir.r5.model.DataType src) throws FHIRException {
125    ConversionContext30_50.INSTANCE.init(this, src.fhirType());
126    try {
127      return typeConvertor.convertType(src);
128    } finally {
129      ConversionContext30_50.INSTANCE.close(src.fhirType());
130    }
131  }
132
133  public void copyDomainResource(
134    @Nonnull org.hl7.fhir.dstu3.model.DomainResource src,
135    @Nonnull org.hl7.fhir.r5.model.DomainResource tgt,
136    String... extensionUrlsToIgnore) throws FHIRException {
137    resourceConvertor.copyDomainResource(src, tgt, extensionUrlsToIgnore);
138  }
139
140  public void copyDomainResource(
141    @Nonnull org.hl7.fhir.r5.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.r5.model.Element tgt,
150    String... extensionUrlsToIgnore) throws FHIRException {
151    elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), extensionUrlsToIgnore);
152  }
153
154  public void copyElement(
155    @Nonnull org.hl7.fhir.r5.model.Element src,
156    @Nonnull org.hl7.fhir.dstu3.model.Element tgt,
157    String... extensionUrlsToIgnore) throws FHIRException {
158    elementConvertor.copyElement(src, tgt, ConversionContext30_50.INSTANCE.path(), extensionUrlsToIgnore);
159  }
160
161  public void copyBackboneElement(
162    @Nonnull org.hl7.fhir.r5.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.r5.model.BackboneElement tgt,
171    String... extensionUrlsToIgnore) throws FHIRException {
172    backboneElementConvertor.copyBackboneElement(src, tgt, extensionUrlsToIgnore);
173  }
174}