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.Money40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Date40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_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 PaymentNotice40_50 {
042
043  public static org.hl7.fhir.r5.model.PaymentNotice convertPaymentNotice(org.hl7.fhir.r4.model.PaymentNotice src) throws FHIRException {
044    if (src == null)
045      return null;
046    org.hl7.fhir.r5.model.PaymentNotice tgt = new org.hl7.fhir.r5.model.PaymentNotice();
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(convertPaymentNoticeStatus(src.getStatusElement()));
052    if (src.hasRequest())
053      tgt.setRequest(Reference40_50.convertReference(src.getRequest()));
054    if (src.hasResponse())
055      tgt.setResponse(Reference40_50.convertReference(src.getResponse()));
056    if (src.hasCreated())
057      tgt.setCreatedElement(DateTime40_50.convertDateTime(src.getCreatedElement()));
058    if (src.hasProvider())
059      tgt.setReporter(Reference40_50.convertReference(src.getProvider()));
060    if (src.hasPayment())
061      tgt.setPayment(Reference40_50.convertReference(src.getPayment()));
062    if (src.hasPaymentDate())
063      tgt.setPaymentDateElement(Date40_50.convertDate(src.getPaymentDateElement()));
064    if (src.hasPayee())
065      tgt.setPayee(Reference40_50.convertReference(src.getPayee()));
066    if (src.hasRecipient())
067      tgt.setRecipient(Reference40_50.convertReference(src.getRecipient()));
068    if (src.hasAmount())
069      tgt.setAmount(Money40_50.convertMoney(src.getAmount()));
070    if (src.hasPaymentStatus())
071      tgt.setPaymentStatus(CodeableConcept40_50.convertCodeableConcept(src.getPaymentStatus()));
072    return tgt;
073  }
074
075  public static org.hl7.fhir.r4.model.PaymentNotice convertPaymentNotice(org.hl7.fhir.r5.model.PaymentNotice src) throws FHIRException {
076    if (src == null)
077      return null;
078    org.hl7.fhir.r4.model.PaymentNotice tgt = new org.hl7.fhir.r4.model.PaymentNotice();
079    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
080    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
081      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
082    if (src.hasStatus())
083      tgt.setStatusElement(convertPaymentNoticeStatus(src.getStatusElement()));
084    if (src.hasRequest())
085      tgt.setRequest(Reference40_50.convertReference(src.getRequest()));
086    if (src.hasResponse())
087      tgt.setResponse(Reference40_50.convertReference(src.getResponse()));
088    if (src.hasCreated())
089      tgt.setCreatedElement(DateTime40_50.convertDateTime(src.getCreatedElement()));
090    if (src.hasReporter())
091      tgt.setProvider(Reference40_50.convertReference(src.getReporter()));
092    if (src.hasPayment())
093      tgt.setPayment(Reference40_50.convertReference(src.getPayment()));
094    if (src.hasPaymentDate())
095      tgt.setPaymentDateElement(Date40_50.convertDate(src.getPaymentDateElement()));
096    if (src.hasPayee())
097      tgt.setPayee(Reference40_50.convertReference(src.getPayee()));
098    if (src.hasRecipient())
099      tgt.setRecipient(Reference40_50.convertReference(src.getRecipient()));
100    if (src.hasAmount())
101      tgt.setAmount(Money40_50.convertMoney(src.getAmount()));
102    if (src.hasPaymentStatus())
103      tgt.setPaymentStatus(CodeableConcept40_50.convertCodeableConcept(src.getPaymentStatus()));
104    return tgt;
105  }
106
107  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> convertPaymentNoticeStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus> src) throws FHIRException {
108    if (src == null || src.isEmpty())
109      return null;
110    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodesEnumFactory());
111    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
112    switch (src.getValue()) {
113      case ACTIVE:
114        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ACTIVE);
115        break;
116      case CANCELLED:
117        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.CANCELLED);
118        break;
119      case DRAFT:
120        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.DRAFT);
121        break;
122      case ENTEREDINERROR:
123        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
124        break;
125      default:
126        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.NULL);
127        break;
128    }
129    return tgt;
130  }
131
132  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus> convertPaymentNoticeStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException {
133    if (src == null || src.isEmpty())
134      return null;
135    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatusEnumFactory());
136    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
137    switch (src.getValue()) {
138      case ACTIVE:
139        tgt.setValue(org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.ACTIVE);
140        break;
141      case CANCELLED:
142        tgt.setValue(org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.CANCELLED);
143        break;
144      case DRAFT:
145        tgt.setValue(org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.DRAFT);
146        break;
147      case ENTEREDINERROR:
148        tgt.setValue(org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.ENTEREDINERROR);
149        break;
150      default:
151        tgt.setValue(org.hl7.fhir.r4.model.PaymentNotice.PaymentNoticeStatus.NULL);
152        break;
153    }
154    return tgt;
155  }
156}