001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Date30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
009import org.hl7.fhir.dstu3.model.PaymentNotice;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r5.model.Enumeration;
012import org.hl7.fhir.r5.model.Enumerations;
013
014public class PaymentNotice30_50 {
015
016  public static org.hl7.fhir.dstu3.model.PaymentNotice convertPaymentNotice(org.hl7.fhir.r5.model.PaymentNotice src) throws FHIRException {
017    if (src == null)
018      return null;
019    org.hl7.fhir.dstu3.model.PaymentNotice tgt = new org.hl7.fhir.dstu3.model.PaymentNotice();
020    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
021    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
022      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
023    if (src.hasStatus())
024      tgt.setStatusElement(convertPaymentNoticeStatus(src.getStatusElement()));
025    if (src.hasRequest())
026      tgt.setRequest(Reference30_50.convertReference(src.getRequest()));
027    if (src.hasResponse())
028      tgt.setResponse(Reference30_50.convertReference(src.getResponse()));
029    if (src.hasPaymentDate())
030      tgt.setStatusDateElement(Date30_50.convertDate(src.getPaymentDateElement()));
031    if (src.hasCreated())
032      tgt.setCreatedElement(DateTime30_50.convertDateTime(src.getCreatedElement()));
033    if (src.hasRecipient())
034      tgt.setTarget(Reference30_50.convertReference(src.getRecipient()));
035    if (src.hasReporter())
036      tgt.setProvider(Reference30_50.convertReference(src.getReporter()));
037    if (src.hasPaymentStatus())
038      tgt.setPaymentStatus(CodeableConcept30_50.convertCodeableConcept(src.getPaymentStatus()));
039    return tgt;
040  }
041
042  public static org.hl7.fhir.r5.model.PaymentNotice convertPaymentNotice(org.hl7.fhir.dstu3.model.PaymentNotice src) throws FHIRException {
043    if (src == null)
044      return null;
045    org.hl7.fhir.r5.model.PaymentNotice tgt = new org.hl7.fhir.r5.model.PaymentNotice();
046    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
047    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
048      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
049    if (src.hasStatus())
050      tgt.setStatusElement(convertPaymentNoticeStatus(src.getStatusElement()));
051    if (src.hasRequest())
052      tgt.setRequest(Reference30_50.convertReference(src.getRequest()));
053    if (src.hasResponse())
054      tgt.setResponse(Reference30_50.convertReference(src.getResponse()));
055    if (src.hasStatusDate())
056      tgt.setPaymentDateElement(Date30_50.convertDate(src.getStatusDateElement()));
057    if (src.hasCreated())
058      tgt.setCreatedElement(DateTime30_50.convertDateTime(src.getCreatedElement()));
059    if (src.hasTarget())
060      tgt.setRecipient(Reference30_50.convertReference(src.getTarget()));
061    if (src.hasProvider())
062      tgt.setReporter(Reference30_50.convertReference(src.getProvider()));
063    if (src.hasPaymentStatus())
064      tgt.setPaymentStatus(CodeableConcept30_50.convertCodeableConcept(src.getPaymentStatus()));
065    return tgt;
066  }
067
068  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> convertPaymentNoticeStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus> src) throws FHIRException {
069      if (src == null || src.isEmpty())
070          return null;
071      Enumeration<Enumerations.FinancialResourceStatusCodes> tgt = new Enumeration<>(new Enumerations.FinancialResourceStatusCodesEnumFactory());
072      ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
073      if (src.getValue() == null) {
074          tgt.setValue(null);
075      } else {
076          switch (src.getValue()) {
077              case ACTIVE:
078                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.ACTIVE);
079                  break;
080              case CANCELLED:
081                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.CANCELLED);
082                  break;
083              case DRAFT:
084                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.DRAFT);
085                  break;
086              case ENTEREDINERROR:
087                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
088                  break;
089              default:
090                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.NULL);
091                  break;
092          }
093      }
094      return tgt;
095  }
096
097  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.PaymentNotice.PaymentNoticeStatus> convertPaymentNoticeStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException {
098      if (src == null || src.isEmpty())
099          return null;
100      org.hl7.fhir.dstu3.model.Enumeration<PaymentNotice.PaymentNoticeStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new PaymentNotice.PaymentNoticeStatusEnumFactory());
101      ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
102      if (src.getValue() == null) {
103          tgt.setValue(null);
104      } else {
105          switch (src.getValue()) {
106              case ACTIVE:
107                  tgt.setValue(PaymentNotice.PaymentNoticeStatus.ACTIVE);
108                  break;
109              case CANCELLED:
110                  tgt.setValue(PaymentNotice.PaymentNoticeStatus.CANCELLED);
111                  break;
112              case DRAFT:
113                  tgt.setValue(PaymentNotice.PaymentNoticeStatus.DRAFT);
114                  break;
115              case ENTEREDINERROR:
116                  tgt.setValue(PaymentNotice.PaymentNoticeStatus.ENTEREDINERROR);
117                  break;
118              default:
119                  tgt.setValue(PaymentNotice.PaymentNoticeStatus.NULL);
120                  break;
121          }
122      }
123      return tgt;
124  }
125}