001package org.hl7.fhir.convertors.conv30_40;
002
003import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40;
004import org.hl7.fhir.convertors.context.ConversionContext30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Element30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Type30_40;
007import org.hl7.fhir.convertors.conv30_40.resources30_40.Resource30_40;
008import org.hl7.fhir.exceptions.FHIRException;
009
010import javax.annotation.Nonnull;
011import java.util.ArrayList;
012import java.util.List;
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_30_40 {
043  static final public String EXT_SRC_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type";
044  static final public String URN_IETF_RFC_3986 = "urn:ietf:rfc:3986";
045  static public List<String> CANONICAL_URLS = new ArrayList<>();
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_30_40 advisor;
068  private final Element30_40 elementConvertor;
069  private final Resource30_40 resourceConvertor;
070  private final Type30_40 typeConvertor;
071
072  public VersionConvertor_30_40(@Nonnull BaseAdvisor_30_40 advisor) {
073    this.advisor = advisor;
074    this.elementConvertor = new Element30_40(advisor);
075    this.resourceConvertor = new Resource30_40(advisor);
076    this.typeConvertor = new Type30_40(advisor);
077  }
078
079  public BaseAdvisor_30_40 advisor() {
080    return advisor;
081  }
082
083  public void copyResource(@Nonnull org.hl7.fhir.dstu3.model.Resource src,
084                           @Nonnull org.hl7.fhir.r4.model.Resource tgt) throws FHIRException {
085    resourceConvertor.copyResource(src, tgt);
086  }
087
088  public void copyResource(@Nonnull org.hl7.fhir.r4.model.Resource src,
089                           @Nonnull org.hl7.fhir.dstu3.model.Resource tgt) throws FHIRException {
090    resourceConvertor.copyResource(src, tgt);
091  }
092
093  public org.hl7.fhir.r4.model.Resource convertResource(@Nonnull org.hl7.fhir.dstu3.model.Resource src) throws FHIRException {
094    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
095    try {
096      return resourceConvertor.convertResource(src);
097    } finally {
098      ConversionContext30_40.INSTANCE.close(src.fhirType());
099    }
100  }
101
102  public org.hl7.fhir.dstu3.model.Resource convertResource(@Nonnull org.hl7.fhir.r4.model.Resource src) throws FHIRException {
103    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
104    try {
105      return resourceConvertor.convertResource(src);
106    } finally {
107      ConversionContext30_40.INSTANCE.close(src.fhirType());
108    }
109  }
110
111  public org.hl7.fhir.r4.model.Type convertType(@Nonnull org.hl7.fhir.dstu3.model.Type src) throws FHIRException {
112    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
113    try {
114      return typeConvertor.convertType(src);
115    } finally {
116      ConversionContext30_40.INSTANCE.close(src.fhirType());
117    }
118  }
119
120  public org.hl7.fhir.dstu3.model.Type convertType(@Nonnull org.hl7.fhir.r4.model.Type src) throws FHIRException {
121    ConversionContext30_40.INSTANCE.init(this, src.fhirType());
122    try {
123      return typeConvertor.convertType(src);
124    } finally {
125      ConversionContext30_40.INSTANCE.close(src.fhirType());
126    }
127  }
128
129  public void copyDomainResource(@Nonnull org.hl7.fhir.dstu3.model.DomainResource src,
130                                 @Nonnull org.hl7.fhir.r4.model.DomainResource tgt) throws FHIRException {
131    resourceConvertor.copyDomainResource(src, tgt);
132  }
133
134  public void copyDomainResource(@Nonnull org.hl7.fhir.r4.model.DomainResource src,
135                                 @Nonnull org.hl7.fhir.dstu3.model.DomainResource tgt) throws FHIRException {
136    resourceConvertor.copyDomainResource(src, tgt);
137  }
138
139  public void copyElement(@Nonnull org.hl7.fhir.dstu3.model.Element src,
140                          @Nonnull org.hl7.fhir.r4.model.Element tgt,
141                          String... var) throws FHIRException {
142    elementConvertor.copyElement(src, tgt, ConversionContext30_40.INSTANCE.path(), var);
143  }
144
145  public void copyElement(@Nonnull org.hl7.fhir.r4.model.Element src,
146                          @Nonnull org.hl7.fhir.dstu3.model.Element tgt,
147                          String... var) throws FHIRException {
148    elementConvertor.copyElement(src, tgt, ConversionContext30_40.INSTANCE.path(), var);
149  }
150}