001package org.hl7.fhir.convertors.conv40_50;
002
003
004import org.hl7.fhir.convertors.VersionConvertor_40_50;
005import org.hl7.fhir.exceptions.FHIRException;
006
007/*
008  Copyright (c) 2011+, HL7, Inc.
009  All rights reserved.
010  
011  Redistribution and use in source and binary forms, with or without modification, 
012  are permitted provided that the following conditions are met:
013  
014   * Redistributions of source code must retain the above copyright notice, this 
015     list of conditions and the following disclaimer.
016   * Redistributions in binary form must reproduce the above copyright notice, 
017     this list of conditions and the following disclaimer in the documentation 
018     and/or other materials provided with the distribution.
019   * Neither the name of HL7 nor the names of its contributors may be used to 
020     endorse or promote products derived from this software without specific 
021     prior written permission.
022  
023  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
024  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
025  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
026  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
027  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
028  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
029  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
030  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
031  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
032  POSSIBILITY OF SUCH DAMAGE.
033  
034*/
035// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
036public class Account40_50 extends VersionConvertor_40_50 {
037
038    public static org.hl7.fhir.r5.model.Account convertAccount(org.hl7.fhir.r4.model.Account src) throws FHIRException {
039        if (src == null)
040            return null;
041        org.hl7.fhir.r5.model.Account tgt = new org.hl7.fhir.r5.model.Account();
042        copyDomainResource(src, tgt);
043        for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t));
044        if (src.hasStatus())
045            tgt.setStatusElement(convertAccountStatus(src.getStatusElement()));
046        if (src.hasType())
047            tgt.setType(convertCodeableConcept(src.getType()));
048        if (src.hasName())
049            tgt.setNameElement(convertString(src.getNameElement()));
050        for (org.hl7.fhir.r4.model.Reference t : src.getSubject()) tgt.addSubject(convertReference(t));
051        if (src.hasServicePeriod())
052            tgt.setServicePeriod(convertPeriod(src.getServicePeriod()));
053        for (org.hl7.fhir.r4.model.Account.CoverageComponent t : src.getCoverage()) tgt.addCoverage(convertCoverageComponent(t));
054        if (src.hasOwner())
055            tgt.setOwner(convertReference(src.getOwner()));
056        if (src.hasDescription())
057            tgt.setDescriptionElement(convertString(src.getDescriptionElement()));
058        for (org.hl7.fhir.r4.model.Account.GuarantorComponent t : src.getGuarantor()) tgt.addGuarantor(convertGuarantorComponent(t));
059        if (src.hasPartOf())
060            tgt.setPartOf(convertReference(src.getPartOf()));
061        return tgt;
062    }
063
064    public static org.hl7.fhir.r4.model.Account convertAccount(org.hl7.fhir.r5.model.Account src) throws FHIRException {
065        if (src == null)
066            return null;
067        org.hl7.fhir.r4.model.Account tgt = new org.hl7.fhir.r4.model.Account();
068        copyDomainResource(src, tgt);
069        for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t));
070        if (src.hasStatus())
071            tgt.setStatusElement(convertAccountStatus(src.getStatusElement()));
072        if (src.hasType())
073            tgt.setType(convertCodeableConcept(src.getType()));
074        if (src.hasName())
075            tgt.setNameElement(convertString(src.getNameElement()));
076        for (org.hl7.fhir.r5.model.Reference t : src.getSubject()) tgt.addSubject(convertReference(t));
077        if (src.hasServicePeriod())
078            tgt.setServicePeriod(convertPeriod(src.getServicePeriod()));
079        for (org.hl7.fhir.r5.model.Account.CoverageComponent t : src.getCoverage()) tgt.addCoverage(convertCoverageComponent(t));
080        if (src.hasOwner())
081            tgt.setOwner(convertReference(src.getOwner()));
082        if (src.hasDescription())
083            tgt.setDescriptionElement(convertString(src.getDescriptionElement()));
084        for (org.hl7.fhir.r5.model.Account.GuarantorComponent t : src.getGuarantor()) tgt.addGuarantor(convertGuarantorComponent(t));
085        if (src.hasPartOf())
086            tgt.setPartOf(convertReference(src.getPartOf()));
087        return tgt;
088    }
089
090    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 {
091        if (src == null || src.isEmpty())
092            return null;
093        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());
094        VersionConvertor_40_50.copyElement(src, tgt);
095        switch(src.getValue()) {
096            case ACTIVE:
097                tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.ACTIVE);
098                break;
099            case INACTIVE:
100                tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.INACTIVE);
101                break;
102            case ENTEREDINERROR:
103                tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.ENTEREDINERROR);
104                break;
105            case ONHOLD:
106                tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.ONHOLD);
107                break;
108            case UNKNOWN:
109                tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.UNKNOWN);
110                break;
111            default:
112                tgt.setValue(org.hl7.fhir.r5.model.Account.AccountStatus.NULL);
113                break;
114        }
115        return tgt;
116    }
117
118    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 {
119        if (src == null || src.isEmpty())
120            return null;
121        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());
122        VersionConvertor_40_50.copyElement(src, tgt);
123        switch(src.getValue()) {
124            case ACTIVE:
125                tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.ACTIVE);
126                break;
127            case INACTIVE:
128                tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.INACTIVE);
129                break;
130            case ENTEREDINERROR:
131                tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.ENTEREDINERROR);
132                break;
133            case ONHOLD:
134                tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.ONHOLD);
135                break;
136            case UNKNOWN:
137                tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.UNKNOWN);
138                break;
139            default:
140                tgt.setValue(org.hl7.fhir.r4.model.Account.AccountStatus.NULL);
141                break;
142        }
143        return tgt;
144    }
145
146    public static org.hl7.fhir.r5.model.Account.CoverageComponent convertCoverageComponent(org.hl7.fhir.r4.model.Account.CoverageComponent src) throws FHIRException {
147        if (src == null)
148            return null;
149        org.hl7.fhir.r5.model.Account.CoverageComponent tgt = new org.hl7.fhir.r5.model.Account.CoverageComponent();
150        copyElement(src, tgt);
151        if (src.hasCoverage())
152            tgt.setCoverage(convertReference(src.getCoverage()));
153        if (src.hasPriority())
154            tgt.setPriorityElement(convertPositiveInt(src.getPriorityElement()));
155        return tgt;
156    }
157
158    public static org.hl7.fhir.r4.model.Account.CoverageComponent convertCoverageComponent(org.hl7.fhir.r5.model.Account.CoverageComponent src) throws FHIRException {
159        if (src == null)
160            return null;
161        org.hl7.fhir.r4.model.Account.CoverageComponent tgt = new org.hl7.fhir.r4.model.Account.CoverageComponent();
162        copyElement(src, tgt);
163        if (src.hasCoverage())
164            tgt.setCoverage(convertReference(src.getCoverage()));
165        if (src.hasPriority())
166            tgt.setPriorityElement(convertPositiveInt(src.getPriorityElement()));
167        return tgt;
168    }
169
170    public static org.hl7.fhir.r5.model.Account.GuarantorComponent convertGuarantorComponent(org.hl7.fhir.r4.model.Account.GuarantorComponent src) throws FHIRException {
171        if (src == null)
172            return null;
173        org.hl7.fhir.r5.model.Account.GuarantorComponent tgt = new org.hl7.fhir.r5.model.Account.GuarantorComponent();
174        copyElement(src, tgt);
175        if (src.hasParty())
176            tgt.setParty(convertReference(src.getParty()));
177        if (src.hasOnHold())
178            tgt.setOnHoldElement(convertBoolean(src.getOnHoldElement()));
179        if (src.hasPeriod())
180            tgt.setPeriod(convertPeriod(src.getPeriod()));
181        return tgt;
182    }
183
184    public static org.hl7.fhir.r4.model.Account.GuarantorComponent convertGuarantorComponent(org.hl7.fhir.r5.model.Account.GuarantorComponent src) throws FHIRException {
185        if (src == null)
186            return null;
187        org.hl7.fhir.r4.model.Account.GuarantorComponent tgt = new org.hl7.fhir.r4.model.Account.GuarantorComponent();
188        copyElement(src, tgt);
189        if (src.hasParty())
190            tgt.setParty(convertReference(src.getParty()));
191        if (src.hasOnHold())
192            tgt.setOnHoldElement(convertBoolean(src.getOnHoldElement()));
193        if (src.hasPeriod())
194            tgt.setPeriod(convertPeriod(src.getPeriod()));
195        return tgt;
196    }
197}