001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext43_50;
004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.PositiveInt43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_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// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
042public class Coverage43_50 {
043
044  public static org.hl7.fhir.r5.model.Coverage convertCoverage(org.hl7.fhir.r4b.model.Coverage src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.Coverage tgt = new org.hl7.fhir.r5.model.Coverage();
048    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
051    if (src.hasStatus())
052      tgt.setStatusElement(convertCoverageStatus(src.getStatusElement()));
053    if (src.hasType())
054      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
055    if (src.hasPolicyHolder())
056      tgt.setPolicyHolder(Reference43_50.convertReference(src.getPolicyHolder()));
057    if (src.hasSubscriber())
058      tgt.setSubscriber(Reference43_50.convertReference(src.getSubscriber()));
059    if (src.hasSubscriberId())
060      tgt.getSubscriberIdFirstRep().setValueElement(String43_50.convertString(src.getSubscriberIdElement()));
061    if (src.hasBeneficiary())
062      tgt.setBeneficiary(Reference43_50.convertReference(src.getBeneficiary()));
063    if (src.hasDependent())
064      tgt.setDependentElement(String43_50.convertString(src.getDependentElement()));
065    if (src.hasRelationship())
066      tgt.setRelationship(CodeableConcept43_50.convertCodeableConcept(src.getRelationship()));
067    if (src.hasPeriod())
068      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
069    for (org.hl7.fhir.r4b.model.Reference t : src.getPayor()) tgt.setInsurer(Reference43_50.convertReference(t));
070    for (org.hl7.fhir.r4b.model.Coverage.ClassComponent t : src.getClass_()) tgt.addClass_(convertClassComponent(t));
071    if (src.hasOrder())
072      tgt.setOrderElement(PositiveInt43_50.convertPositiveInt(src.getOrderElement()));
073    if (src.hasNetwork())
074      tgt.setNetworkElement(String43_50.convertString(src.getNetworkElement()));
075    for (org.hl7.fhir.r4b.model.Coverage.CostToBeneficiaryComponent t : src.getCostToBeneficiary())
076      tgt.addCostToBeneficiary(convertCostToBeneficiaryComponent(t));
077    if (src.hasSubrogation())
078      tgt.setSubrogationElement(Boolean43_50.convertBoolean(src.getSubrogationElement()));
079    for (org.hl7.fhir.r4b.model.Reference t : src.getContract()) tgt.addContract(Reference43_50.convertReference(t));
080    return tgt;
081  }
082
083  public static org.hl7.fhir.r4b.model.Coverage convertCoverage(org.hl7.fhir.r5.model.Coverage src) throws FHIRException {
084    if (src == null)
085      return null;
086    org.hl7.fhir.r4b.model.Coverage tgt = new org.hl7.fhir.r4b.model.Coverage();
087    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
088    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
089      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
090    if (src.hasStatus())
091      tgt.setStatusElement(convertCoverageStatus(src.getStatusElement()));
092    if (src.hasType())
093      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
094    if (src.hasPolicyHolder())
095      tgt.setPolicyHolder(Reference43_50.convertReference(src.getPolicyHolder()));
096    if (src.hasSubscriber())
097      tgt.setSubscriber(Reference43_50.convertReference(src.getSubscriber()));
098    if (src.hasSubscriberId())
099      tgt.setSubscriberIdElement(String43_50.convertString(src.getSubscriberIdFirstRep().getValueElement()));
100    if (src.hasBeneficiary())
101      tgt.setBeneficiary(Reference43_50.convertReference(src.getBeneficiary()));
102    if (src.hasDependent())
103      tgt.setDependentElement(String43_50.convertString(src.getDependentElement()));
104    if (src.hasRelationship())
105      tgt.setRelationship(CodeableConcept43_50.convertCodeableConcept(src.getRelationship()));
106    if (src.hasPeriod())
107      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
108    tgt.addPayor(Reference43_50.convertReference(src.getInsurer()));
109    for (org.hl7.fhir.r5.model.Coverage.ClassComponent t : src.getClass_()) tgt.addClass_(convertClassComponent(t));
110    if (src.hasOrder())
111      tgt.setOrderElement(PositiveInt43_50.convertPositiveInt(src.getOrderElement()));
112    if (src.hasNetwork())
113      tgt.setNetworkElement(String43_50.convertString(src.getNetworkElement()));
114    for (org.hl7.fhir.r5.model.Coverage.CostToBeneficiaryComponent t : src.getCostToBeneficiary())
115      tgt.addCostToBeneficiary(convertCostToBeneficiaryComponent(t));
116    if (src.hasSubrogation())
117      tgt.setSubrogationElement(Boolean43_50.convertBoolean(src.getSubrogationElement()));
118    for (org.hl7.fhir.r5.model.Reference t : src.getContract()) tgt.addContract(Reference43_50.convertReference(t));
119    return tgt;
120  }
121
122  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> convertCoverageStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException {
123    if (src == null || src.isEmpty())
124      return null;
125    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodesEnumFactory());
126    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
127    switch (src.getValue()) {
128      case ACTIVE:
129        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ACTIVE);
130        break;
131      case CANCELLED:
132        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.CANCELLED);
133        break;
134      case DRAFT:
135        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.DRAFT);
136        break;
137      case ENTEREDINERROR:
138        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
139        break;
140      default:
141        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.NULL);
142        break;
143    }
144    return tgt;
145  }
146
147  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> convertCoverageStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException {
148    if (src == null || src.isEmpty())
149      return null;
150    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodesEnumFactory());
151    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
152    switch (src.getValue()) {
153      case ACTIVE:
154        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ACTIVE);
155        break;
156      case CANCELLED:
157        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.CANCELLED);
158        break;
159      case DRAFT:
160        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.DRAFT);
161        break;
162      case ENTEREDINERROR:
163        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
164        break;
165      default:
166        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.NULL);
167        break;
168    }
169    return tgt;
170  }
171
172  public static org.hl7.fhir.r5.model.Coverage.ClassComponent convertClassComponent(org.hl7.fhir.r4b.model.Coverage.ClassComponent src) throws FHIRException {
173    if (src == null)
174      return null;
175    org.hl7.fhir.r5.model.Coverage.ClassComponent tgt = new org.hl7.fhir.r5.model.Coverage.ClassComponent();
176    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
177    if (src.hasType())
178      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
179    if (src.hasValue())
180      tgt.getValue().setValueElement(String43_50.convertString(src.getValueElement()));
181    if (src.hasName())
182      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
183    return tgt;
184  }
185
186  public static org.hl7.fhir.r4b.model.Coverage.ClassComponent convertClassComponent(org.hl7.fhir.r5.model.Coverage.ClassComponent src) throws FHIRException {
187    if (src == null)
188      return null;
189    org.hl7.fhir.r4b.model.Coverage.ClassComponent tgt = new org.hl7.fhir.r4b.model.Coverage.ClassComponent();
190    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
191    if (src.hasType())
192      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
193    if (src.hasValue())
194      tgt.setValueElement(String43_50.convertString(src.getValue().getValueElement()));
195    if (src.hasName())
196      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
197    return tgt;
198  }
199
200  public static org.hl7.fhir.r5.model.Coverage.CostToBeneficiaryComponent convertCostToBeneficiaryComponent(org.hl7.fhir.r4b.model.Coverage.CostToBeneficiaryComponent src) throws FHIRException {
201    if (src == null)
202      return null;
203    org.hl7.fhir.r5.model.Coverage.CostToBeneficiaryComponent tgt = new org.hl7.fhir.r5.model.Coverage.CostToBeneficiaryComponent();
204    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
205    if (src.hasType())
206      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
207    if (src.hasValue())
208      tgt.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getValue()));
209    for (org.hl7.fhir.r4b.model.Coverage.ExemptionComponent t : src.getException())
210      tgt.addException(convertExemptionComponent(t));
211    return tgt;
212  }
213
214  public static org.hl7.fhir.r4b.model.Coverage.CostToBeneficiaryComponent convertCostToBeneficiaryComponent(org.hl7.fhir.r5.model.Coverage.CostToBeneficiaryComponent src) throws FHIRException {
215    if (src == null)
216      return null;
217    org.hl7.fhir.r4b.model.Coverage.CostToBeneficiaryComponent tgt = new org.hl7.fhir.r4b.model.Coverage.CostToBeneficiaryComponent();
218    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
219    if (src.hasType())
220      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
221    if (src.hasValue())
222      tgt.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getValue()));
223    for (org.hl7.fhir.r5.model.Coverage.ExemptionComponent t : src.getException())
224      tgt.addException(convertExemptionComponent(t));
225    return tgt;
226  }
227
228  public static org.hl7.fhir.r5.model.Coverage.ExemptionComponent convertExemptionComponent(org.hl7.fhir.r4b.model.Coverage.ExemptionComponent src) throws FHIRException {
229    if (src == null)
230      return null;
231    org.hl7.fhir.r5.model.Coverage.ExemptionComponent tgt = new org.hl7.fhir.r5.model.Coverage.ExemptionComponent();
232    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
233    if (src.hasType())
234      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
235    if (src.hasPeriod())
236      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
237    return tgt;
238  }
239
240  public static org.hl7.fhir.r4b.model.Coverage.ExemptionComponent convertExemptionComponent(org.hl7.fhir.r5.model.Coverage.ExemptionComponent src) throws FHIRException {
241    if (src == null)
242      return null;
243    org.hl7.fhir.r4b.model.Coverage.ExemptionComponent tgt = new org.hl7.fhir.r4b.model.Coverage.ExemptionComponent();
244    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
245    if (src.hasType())
246      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
247    if (src.hasPeriod())
248      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
249    return tgt;
250  }
251}