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.Annotation40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Money40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 010import org.hl7.fhir.exceptions.FHIRException; 011 012/* 013 Copyright (c) 2011+, HL7, Inc. 014 All rights reserved. 015 016 Redistribution and use in source and binary forms, with or without modification, 017 are permitted provided that the following conditions are met: 018 019 * Redistributions of source code must retain the above copyright notice, this 020 list of conditions and the following disclaimer. 021 * Redistributions in binary form must reproduce the above copyright notice, 022 this list of conditions and the following disclaimer in the documentation 023 and/or other materials provided with the distribution. 024 * Neither the name of HL7 nor the names of its contributors may be used to 025 endorse or promote products derived from this software without specific 026 prior written permission. 027 028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 029 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 030 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 031 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 032 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 033 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 034 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 035 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 036 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 037 POSSIBILITY OF SUCH DAMAGE. 038 039*/ 040// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 041public class Invoice40_50 { 042 043 public static org.hl7.fhir.r5.model.Invoice convertInvoice(org.hl7.fhir.r4.model.Invoice src) throws FHIRException { 044 if (src == null) 045 return null; 046 org.hl7.fhir.r5.model.Invoice tgt = new org.hl7.fhir.r5.model.Invoice(); 047 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 048 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 049 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 050 if (src.hasStatus()) 051 tgt.setStatusElement(convertInvoiceStatus(src.getStatusElement())); 052 if (src.hasCancelledReason()) 053 tgt.setCancelledReasonElement(String40_50.convertString(src.getCancelledReasonElement())); 054 if (src.hasType()) 055 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 056 if (src.hasSubject()) 057 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 058 if (src.hasRecipient()) 059 tgt.setRecipient(Reference40_50.convertReference(src.getRecipient())); 060 if (src.hasDate()) 061 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 062 for (org.hl7.fhir.r4.model.Invoice.InvoiceParticipantComponent t : src.getParticipant()) 063 tgt.addParticipant(convertInvoiceParticipantComponent(t)); 064 if (src.hasIssuer()) 065 tgt.setIssuer(Reference40_50.convertReference(src.getIssuer())); 066 if (src.hasAccount()) 067 tgt.setAccount(Reference40_50.convertReference(src.getAccount())); 068 for (org.hl7.fhir.r4.model.Invoice.InvoiceLineItemComponent t : src.getLineItem()) 069 tgt.addLineItem(convertInvoiceLineItemComponent(t)); 070 for (org.hl7.fhir.r4.model.Invoice.InvoiceLineItemPriceComponentComponent t : src.getTotalPriceComponent()) 071 tgt.addTotalPriceComponent(convertInvoiceLineItemPriceComponentComponent(t)); 072 if (src.hasTotalNet()) 073 tgt.setTotalNet(Money40_50.convertMoney(src.getTotalNet())); 074 if (src.hasTotalGross()) 075 tgt.setTotalGross(Money40_50.convertMoney(src.getTotalGross())); 076 if (src.hasPaymentTerms()) 077 tgt.setPaymentTermsElement(MarkDown40_50.convertMarkdown(src.getPaymentTermsElement())); 078 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 079 return tgt; 080 } 081 082 public static org.hl7.fhir.r4.model.Invoice convertInvoice(org.hl7.fhir.r5.model.Invoice src) throws FHIRException { 083 if (src == null) 084 return null; 085 org.hl7.fhir.r4.model.Invoice tgt = new org.hl7.fhir.r4.model.Invoice(); 086 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 087 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 088 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 089 if (src.hasStatus()) 090 tgt.setStatusElement(convertInvoiceStatus(src.getStatusElement())); 091 if (src.hasCancelledReason()) 092 tgt.setCancelledReasonElement(String40_50.convertString(src.getCancelledReasonElement())); 093 if (src.hasType()) 094 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 095 if (src.hasSubject()) 096 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 097 if (src.hasRecipient()) 098 tgt.setRecipient(Reference40_50.convertReference(src.getRecipient())); 099 if (src.hasDate()) 100 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 101 for (org.hl7.fhir.r5.model.Invoice.InvoiceParticipantComponent t : src.getParticipant()) 102 tgt.addParticipant(convertInvoiceParticipantComponent(t)); 103 if (src.hasIssuer()) 104 tgt.setIssuer(Reference40_50.convertReference(src.getIssuer())); 105 if (src.hasAccount()) 106 tgt.setAccount(Reference40_50.convertReference(src.getAccount())); 107 for (org.hl7.fhir.r5.model.Invoice.InvoiceLineItemComponent t : src.getLineItem()) 108 tgt.addLineItem(convertInvoiceLineItemComponent(t)); 109 for (org.hl7.fhir.r5.model.Invoice.InvoiceLineItemPriceComponentComponent t : src.getTotalPriceComponent()) 110 tgt.addTotalPriceComponent(convertInvoiceLineItemPriceComponentComponent(t)); 111 if (src.hasTotalNet()) 112 tgt.setTotalNet(Money40_50.convertMoney(src.getTotalNet())); 113 if (src.hasTotalGross()) 114 tgt.setTotalGross(Money40_50.convertMoney(src.getTotalGross())); 115 if (src.hasPaymentTerms()) 116 tgt.setPaymentTermsElement(MarkDown40_50.convertMarkdown(src.getPaymentTermsElement())); 117 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 118 return tgt; 119 } 120 121 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Invoice.InvoiceStatus> convertInvoiceStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Invoice.InvoiceStatus> src) throws FHIRException { 122 if (src == null || src.isEmpty()) 123 return null; 124 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Invoice.InvoiceStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Invoice.InvoiceStatusEnumFactory()); 125 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 126 switch (src.getValue()) { 127 case DRAFT: 128 tgt.setValue(org.hl7.fhir.r5.model.Invoice.InvoiceStatus.DRAFT); 129 break; 130 case ISSUED: 131 tgt.setValue(org.hl7.fhir.r5.model.Invoice.InvoiceStatus.ISSUED); 132 break; 133 case BALANCED: 134 tgt.setValue(org.hl7.fhir.r5.model.Invoice.InvoiceStatus.BALANCED); 135 break; 136 case CANCELLED: 137 tgt.setValue(org.hl7.fhir.r5.model.Invoice.InvoiceStatus.CANCELLED); 138 break; 139 case ENTEREDINERROR: 140 tgt.setValue(org.hl7.fhir.r5.model.Invoice.InvoiceStatus.ENTEREDINERROR); 141 break; 142 default: 143 tgt.setValue(org.hl7.fhir.r5.model.Invoice.InvoiceStatus.NULL); 144 break; 145 } 146 return tgt; 147 } 148 149 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Invoice.InvoiceStatus> convertInvoiceStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Invoice.InvoiceStatus> src) throws FHIRException { 150 if (src == null || src.isEmpty()) 151 return null; 152 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Invoice.InvoiceStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Invoice.InvoiceStatusEnumFactory()); 153 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 154 switch (src.getValue()) { 155 case DRAFT: 156 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoiceStatus.DRAFT); 157 break; 158 case ISSUED: 159 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoiceStatus.ISSUED); 160 break; 161 case BALANCED: 162 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoiceStatus.BALANCED); 163 break; 164 case CANCELLED: 165 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoiceStatus.CANCELLED); 166 break; 167 case ENTEREDINERROR: 168 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoiceStatus.ENTEREDINERROR); 169 break; 170 default: 171 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoiceStatus.NULL); 172 break; 173 } 174 return tgt; 175 } 176 177 public static org.hl7.fhir.r5.model.Invoice.InvoiceParticipantComponent convertInvoiceParticipantComponent(org.hl7.fhir.r4.model.Invoice.InvoiceParticipantComponent src) throws FHIRException { 178 if (src == null) 179 return null; 180 org.hl7.fhir.r5.model.Invoice.InvoiceParticipantComponent tgt = new org.hl7.fhir.r5.model.Invoice.InvoiceParticipantComponent(); 181 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 182 if (src.hasRole()) 183 tgt.setRole(CodeableConcept40_50.convertCodeableConcept(src.getRole())); 184 if (src.hasActor()) 185 tgt.setActor(Reference40_50.convertReference(src.getActor())); 186 return tgt; 187 } 188 189 public static org.hl7.fhir.r4.model.Invoice.InvoiceParticipantComponent convertInvoiceParticipantComponent(org.hl7.fhir.r5.model.Invoice.InvoiceParticipantComponent src) throws FHIRException { 190 if (src == null) 191 return null; 192 org.hl7.fhir.r4.model.Invoice.InvoiceParticipantComponent tgt = new org.hl7.fhir.r4.model.Invoice.InvoiceParticipantComponent(); 193 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 194 if (src.hasRole()) 195 tgt.setRole(CodeableConcept40_50.convertCodeableConcept(src.getRole())); 196 if (src.hasActor()) 197 tgt.setActor(Reference40_50.convertReference(src.getActor())); 198 return tgt; 199 } 200 201 public static org.hl7.fhir.r5.model.Invoice.InvoiceLineItemComponent convertInvoiceLineItemComponent(org.hl7.fhir.r4.model.Invoice.InvoiceLineItemComponent src) throws FHIRException { 202 if (src == null) 203 return null; 204 org.hl7.fhir.r5.model.Invoice.InvoiceLineItemComponent tgt = new org.hl7.fhir.r5.model.Invoice.InvoiceLineItemComponent(); 205 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 206 if (src.hasSequence()) 207 tgt.setSequenceElement(PositiveInt40_50.convertPositiveInt(src.getSequenceElement())); 208 if (src.hasChargeItem()) 209 tgt.setChargeItem(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getChargeItem())); 210 for (org.hl7.fhir.r4.model.Invoice.InvoiceLineItemPriceComponentComponent t : src.getPriceComponent()) 211 tgt.addPriceComponent(convertInvoiceLineItemPriceComponentComponent(t)); 212 return tgt; 213 } 214 215 public static org.hl7.fhir.r4.model.Invoice.InvoiceLineItemComponent convertInvoiceLineItemComponent(org.hl7.fhir.r5.model.Invoice.InvoiceLineItemComponent src) throws FHIRException { 216 if (src == null) 217 return null; 218 org.hl7.fhir.r4.model.Invoice.InvoiceLineItemComponent tgt = new org.hl7.fhir.r4.model.Invoice.InvoiceLineItemComponent(); 219 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 220 if (src.hasSequence()) 221 tgt.setSequenceElement(PositiveInt40_50.convertPositiveInt(src.getSequenceElement())); 222 if (src.hasChargeItem()) 223 tgt.setChargeItem(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getChargeItem())); 224 for (org.hl7.fhir.r5.model.Invoice.InvoiceLineItemPriceComponentComponent t : src.getPriceComponent()) 225 tgt.addPriceComponent(convertInvoiceLineItemPriceComponentComponent(t)); 226 return tgt; 227 } 228 229 public static org.hl7.fhir.r5.model.Invoice.InvoiceLineItemPriceComponentComponent convertInvoiceLineItemPriceComponentComponent(org.hl7.fhir.r4.model.Invoice.InvoiceLineItemPriceComponentComponent src) throws FHIRException { 230 if (src == null) 231 return null; 232 org.hl7.fhir.r5.model.Invoice.InvoiceLineItemPriceComponentComponent tgt = new org.hl7.fhir.r5.model.Invoice.InvoiceLineItemPriceComponentComponent(); 233 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 234 if (src.hasType()) 235 tgt.setTypeElement(convertInvoicePriceComponentType(src.getTypeElement())); 236 if (src.hasCode()) 237 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 238 if (src.hasFactor()) 239 tgt.setFactorElement(Decimal40_50.convertDecimal(src.getFactorElement())); 240 if (src.hasAmount()) 241 tgt.setAmount(Money40_50.convertMoney(src.getAmount())); 242 return tgt; 243 } 244 245 public static org.hl7.fhir.r4.model.Invoice.InvoiceLineItemPriceComponentComponent convertInvoiceLineItemPriceComponentComponent(org.hl7.fhir.r5.model.Invoice.InvoiceLineItemPriceComponentComponent src) throws FHIRException { 246 if (src == null) 247 return null; 248 org.hl7.fhir.r4.model.Invoice.InvoiceLineItemPriceComponentComponent tgt = new org.hl7.fhir.r4.model.Invoice.InvoiceLineItemPriceComponentComponent(); 249 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 250 if (src.hasType()) 251 tgt.setTypeElement(convertInvoicePriceComponentType(src.getTypeElement())); 252 if (src.hasCode()) 253 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 254 if (src.hasFactor()) 255 tgt.setFactorElement(Decimal40_50.convertDecimal(src.getFactorElement())); 256 if (src.hasAmount()) 257 tgt.setAmount(Money40_50.convertMoney(src.getAmount())); 258 return tgt; 259 } 260 261 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType> convertInvoicePriceComponentType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType> src) throws FHIRException { 262 if (src == null || src.isEmpty()) 263 return null; 264 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentTypeEnumFactory()); 265 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 266 switch (src.getValue()) { 267 case BASE: 268 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.BASE); 269 break; 270 case SURCHARGE: 271 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.SURCHARGE); 272 break; 273 case DEDUCTION: 274 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.DEDUCTION); 275 break; 276 case DISCOUNT: 277 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.DISCOUNT); 278 break; 279 case TAX: 280 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.TAX); 281 break; 282 case INFORMATIONAL: 283 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.INFORMATIONAL); 284 break; 285 default: 286 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType.NULL); 287 break; 288 } 289 return tgt; 290 } 291 292 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType> convertInvoicePriceComponentType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.InvoicePriceComponentType> src) throws FHIRException { 293 if (src == null || src.isEmpty()) 294 return null; 295 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentTypeEnumFactory()); 296 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 297 switch (src.getValue()) { 298 case BASE: 299 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.BASE); 300 break; 301 case SURCHARGE: 302 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.SURCHARGE); 303 break; 304 case DEDUCTION: 305 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.DEDUCTION); 306 break; 307 case DISCOUNT: 308 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.DISCOUNT); 309 break; 310 case TAX: 311 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.TAX); 312 break; 313 case INFORMATIONAL: 314 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.INFORMATIONAL); 315 break; 316 default: 317 tgt.setValue(org.hl7.fhir.r4.model.Invoice.InvoicePriceComponentType.NULL); 318 break; 319 } 320 return tgt; 321 } 322}