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