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