001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40;
007import org.hl7.fhir.exceptions.FHIRException;
008
009public class SupplyDelivery10_40 {
010
011  public static org.hl7.fhir.dstu2.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery src) throws FHIRException {
012    if (src == null || src.isEmpty())
013      return null;
014    org.hl7.fhir.dstu2.model.SupplyDelivery tgt = new org.hl7.fhir.dstu2.model.SupplyDelivery();
015    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
016    if (src.hasIdentifier())
017      tgt.setIdentifier(Identifier10_40.convertIdentifier(src.getIdentifierFirstRep()));
018    if (src.hasStatus())
019      tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement()));
020    if (src.hasPatient())
021      tgt.setPatient(Reference10_40.convertReference(src.getPatient()));
022    if (src.hasType())
023      tgt.setType(CodeableConcept10_40.convertCodeableConcept(src.getType()));
024    if (src.hasSupplier())
025      tgt.setSupplier(Reference10_40.convertReference(src.getSupplier()));
026    if (src.hasDestination())
027      tgt.setDestination(Reference10_40.convertReference(src.getDestination()));
028    for (org.hl7.fhir.r4.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference10_40.convertReference(t));
029    return tgt;
030  }
031
032  public static org.hl7.fhir.r4.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.dstu2.model.SupplyDelivery src) throws FHIRException {
033    if (src == null || src.isEmpty())
034      return null;
035    org.hl7.fhir.r4.model.SupplyDelivery tgt = new org.hl7.fhir.r4.model.SupplyDelivery();
036    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
037    if (src.hasIdentifier())
038      tgt.addIdentifier(Identifier10_40.convertIdentifier(src.getIdentifier()));
039    if (src.hasStatus())
040      tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement()));
041    if (src.hasPatient())
042      tgt.setPatient(Reference10_40.convertReference(src.getPatient()));
043    if (src.hasType())
044      tgt.setType(CodeableConcept10_40.convertCodeableConcept(src.getType()));
045    if (src.hasSupplier())
046      tgt.setSupplier(Reference10_40.convertReference(src.getSupplier()));
047    if (src.hasDestination())
048      tgt.setDestination(Reference10_40.convertReference(src.getDestination()));
049    for (org.hl7.fhir.dstu2.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference10_40.convertReference(t));
050    return tgt;
051  }
052
053  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus> convertSupplyDeliveryStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus> src) throws FHIRException {
054    if (src == null || src.isEmpty())
055      return null;
056    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatusEnumFactory());
057    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
058    switch (src.getValue()) {
059      case INPROGRESS:
060        tgt.setValue(org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS);
061        break;
062      case COMPLETED:
063        tgt.setValue(org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED);
064        break;
065      case ABANDONED:
066        tgt.setValue(org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED);
067        break;
068      default:
069        tgt.setValue(org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus.NULL);
070        break;
071    }
072    return tgt;
073  }
074
075  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus> convertSupplyDeliveryStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SupplyDelivery.SupplyDeliveryStatus> src) throws FHIRException {
076    if (src == null || src.isEmpty())
077      return null;
078    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatusEnumFactory());
079    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
080    switch (src.getValue()) {
081      case INPROGRESS:
082        tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS);
083        break;
084      case COMPLETED:
085        tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED);
086        break;
087      case ABANDONED:
088        tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED);
089        break;
090      default:
091        tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.NULL);
092        break;
093    }
094    return tgt;
095  }
096}