001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Period40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.PositiveInt40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_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 Account40_50 {
043
044  public static org.hl7.fhir.r5.model.Account convertAccount(org.hl7.fhir.r4.model.Account src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.Account tgt = new org.hl7.fhir.r5.model.Account();
048    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
051    if (src.hasStatus())
052      tgt.setStatusElement(convertAccountStatus(src.getStatusElement()));
053    if (src.hasType())
054      tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType()));
055    if (src.hasName())
056      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
057    for (org.hl7.fhir.r4.model.Reference t : src.getSubject()) tgt.addSubject(Reference40_50.convertReference(t));
058    if (src.hasServicePeriod())
059      tgt.setServicePeriod(Period40_50.convertPeriod(src.getServicePeriod()));
060    for (org.hl7.fhir.r4.model.Account.CoverageComponent t : src.getCoverage())
061      tgt.addCoverage(convertCoverageComponent(t));
062    if (src.hasOwner())
063      tgt.setOwner(Reference40_50.convertReference(src.getOwner()));
064    if (src.hasDescription())
065      tgt.setDescriptionElement(String40_50.convertStringToMarkdown(src.getDescriptionElement()));
066    for (org.hl7.fhir.r4.model.Account.GuarantorComponent t : src.getGuarantor())
067      tgt.addGuarantor(convertGuarantorComponent(t));
068//    if (src.hasPartOf())
069//      tgt.setPartOf(Reference40_50.convertReference(src.getPartOf()));
070    return tgt;
071  }
072
073  public static org.hl7.fhir.r4.model.Account convertAccount(org.hl7.fhir.r5.model.Account src) throws FHIRException {
074    if (src == null)
075      return null;
076    org.hl7.fhir.r4.model.Account tgt = new org.hl7.fhir.r4.model.Account();
077    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
078    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
079      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
080    if (src.hasStatus())
081      tgt.setStatusElement(convertAccountStatus(src.getStatusElement()));
082    if (src.hasType())
083      tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType()));
084    if (src.hasName())
085      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
086    for (org.hl7.fhir.r5.model.Reference t : src.getSubject()) tgt.addSubject(Reference40_50.convertReference(t));
087    if (src.hasServicePeriod())
088      tgt.setServicePeriod(Period40_50.convertPeriod(src.getServicePeriod()));
089    for (org.hl7.fhir.r5.model.Account.CoverageComponent t : src.getCoverage())
090      tgt.addCoverage(convertCoverageComponent(t));
091    if (src.hasOwner())
092      tgt.setOwner(Reference40_50.convertReference(src.getOwner()));
093    if (src.hasDescription())
094      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
095    for (org.hl7.fhir.r5.model.Account.GuarantorComponent t : src.getGuarantor())
096      tgt.addGuarantor(convertGuarantorComponent(t));
097//    if (src.hasPartOf())
098//      tgt.setPartOf(Reference40_50.convertReference(src.getPartOf()));
099    return tgt;
100  }
101
102  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Account.AccountStatus> convertAccountStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Account.AccountStatus> src) throws FHIRException {
103    if (src == null || src.isEmpty())
104      return null;
105    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Account.AccountStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Account.AccountStatusEnumFactory());
106    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
107    switch (src.getValue()) {
108      case ACTIVE:
109        tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.ACTIVE);
110        break;
111      case INACTIVE:
112        tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.INACTIVE);
113        break;
114      case ENTEREDINERROR:
115        tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.ENTEREDINERROR);
116        break;
117      case ONHOLD:
118        tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.ONHOLD);
119        break;
120      case UNKNOWN:
121        tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.UNKNOWN);
122        break;
123      default:
124        tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.NULL);
125        break;
126    }
127    return tgt;
128  }
129
130  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Account.AccountStatus> convertAccountStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Account.AccountStatus> src) throws FHIRException {
131    if (src == null || src.isEmpty())
132      return null;
133    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Account.AccountStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Account.AccountStatusEnumFactory());
134    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
135    switch (src.getValue()) {
136      case ACTIVE:
137        tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.ACTIVE);
138        break;
139      case INACTIVE:
140        tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.INACTIVE);
141        break;
142      case ENTEREDINERROR:
143        tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.ENTEREDINERROR);
144        break;
145      case ONHOLD:
146        tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.ONHOLD);
147        break;
148      case UNKNOWN:
149        tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.UNKNOWN);
150        break;
151      default:
152        tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.NULL);
153        break;
154    }
155    return tgt;
156  }
157
158  public static org.hl7.fhir.r5.model.Account.CoverageComponent convertCoverageComponent(org.hl7.fhir.r4.model.Account.CoverageComponent src) throws FHIRException {
159    if (src == null)
160      return null;
161    org.hl7.fhir.r5.model.Account.CoverageComponent tgt = new org.hl7.fhir.r5.model.Account.CoverageComponent();
162    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
163    if (src.hasCoverage())
164      tgt.setCoverage(Reference40_50.convertReference(src.getCoverage()));
165    if (src.hasPriority())
166      tgt.setPriorityElement(PositiveInt40_50.convertPositiveInt(src.getPriorityElement()));
167    return tgt;
168  }
169
170  public static org.hl7.fhir.r4.model.Account.CoverageComponent convertCoverageComponent(org.hl7.fhir.r5.model.Account.CoverageComponent src) throws FHIRException {
171    if (src == null)
172      return null;
173    org.hl7.fhir.r4.model.Account.CoverageComponent tgt = new org.hl7.fhir.r4.model.Account.CoverageComponent();
174    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
175    if (src.hasCoverage())
176      tgt.setCoverage(Reference40_50.convertReference(src.getCoverage()));
177    if (src.hasPriority())
178      tgt.setPriorityElement(PositiveInt40_50.convertPositiveInt(src.getPriorityElement()));
179    return tgt;
180  }
181
182  public static org.hl7.fhir.r5.model.Account.GuarantorComponent convertGuarantorComponent(org.hl7.fhir.r4.model.Account.GuarantorComponent src) throws FHIRException {
183    if (src == null)
184      return null;
185    org.hl7.fhir.r5.model.Account.GuarantorComponent tgt = new org.hl7.fhir.r5.model.Account.GuarantorComponent();
186    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
187    if (src.hasParty())
188      tgt.setParty(Reference40_50.convertReference(src.getParty()));
189    if (src.hasOnHold())
190      tgt.setOnHoldElement(Boolean40_50.convertBoolean(src.getOnHoldElement()));
191    if (src.hasPeriod())
192      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
193    return tgt;
194  }
195
196  public static org.hl7.fhir.r4.model.Account.GuarantorComponent convertGuarantorComponent(org.hl7.fhir.r5.model.Account.GuarantorComponent src) throws FHIRException {
197    if (src == null)
198      return null;
199    org.hl7.fhir.r4.model.Account.GuarantorComponent tgt = new org.hl7.fhir.r4.model.Account.GuarantorComponent();
200    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
201    if (src.hasParty())
202      tgt.setParty(Reference40_50.convertReference(src.getParty()));
203    if (src.hasOnHold())
204      tgt.setOnHoldElement(Boolean40_50.convertBoolean(src.getOnHoldElement()));
205    if (src.hasPeriod())
206      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
207    return tgt;
208  }
209}