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