001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.SimpleQuantity30_40; 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class SupplyDelivery30_40 { 011 012 public static org.hl7.fhir.r4.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.dstu3.model.SupplyDelivery src) throws FHIRException { 013 if (src == null) 014 return null; 015 org.hl7.fhir.r4.model.SupplyDelivery tgt = new org.hl7.fhir.r4.model.SupplyDelivery(); 016 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 017 if (src.hasIdentifier()) 018 tgt.addIdentifier(Identifier30_40.convertIdentifier(src.getIdentifier())); 019 for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference30_40.convertReference(t)); 020 for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference30_40.convertReference(t)); 021 if (src.hasStatus()) 022 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 023 if (src.hasPatient()) 024 tgt.setPatient(Reference30_40.convertReference(src.getPatient())); 025 if (src.hasType()) 026 tgt.setType(CodeableConcept30_40.convertCodeableConcept(src.getType())); 027 if (src.hasSuppliedItem()) 028 tgt.setSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItem())); 029 if (src.hasOccurrence()) 030 tgt.setOccurrence(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getOccurrence())); 031 if (src.hasSupplier()) 032 tgt.setSupplier(Reference30_40.convertReference(src.getSupplier())); 033 if (src.hasDestination()) 034 tgt.setDestination(Reference30_40.convertReference(src.getDestination())); 035 for (org.hl7.fhir.dstu3.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference30_40.convertReference(t)); 036 return tgt; 037 } 038 039 public static org.hl7.fhir.dstu3.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery src) throws FHIRException { 040 if (src == null) 041 return null; 042 org.hl7.fhir.dstu3.model.SupplyDelivery tgt = new org.hl7.fhir.dstu3.model.SupplyDelivery(); 043 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 044 if (src.hasIdentifier()) 045 tgt.setIdentifier(Identifier30_40.convertIdentifier(src.getIdentifierFirstRep())); 046 for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference30_40.convertReference(t)); 047 for (org.hl7.fhir.r4.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference30_40.convertReference(t)); 048 if (src.hasStatus()) 049 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 050 if (src.hasPatient()) 051 tgt.setPatient(Reference30_40.convertReference(src.getPatient())); 052 if (src.hasType()) 053 tgt.setType(CodeableConcept30_40.convertCodeableConcept(src.getType())); 054 if (src.hasSuppliedItem()) 055 tgt.setSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItem())); 056 if (src.hasOccurrence()) 057 tgt.setOccurrence(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getOccurrence())); 058 if (src.hasSupplier()) 059 tgt.setSupplier(Reference30_40.convertReference(src.getSupplier())); 060 if (src.hasDestination()) 061 tgt.setDestination(Reference30_40.convertReference(src.getDestination())); 062 for (org.hl7.fhir.r4.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference30_40.convertReference(t)); 063 return tgt; 064 } 065 066 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus> convertSupplyDeliveryStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus> src) throws FHIRException { 067 if (src == null || src.isEmpty()) 068 return null; 069 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()); 070 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 071 switch (src.getValue()) { 072 case INPROGRESS: 073 tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 074 break; 075 case COMPLETED: 076 tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 077 break; 078 case ABANDONED: 079 tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 080 break; 081 case ENTEREDINERROR: 082 tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR); 083 break; 084 default: 085 tgt.setValue(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus.NULL); 086 break; 087 } 088 return tgt; 089 } 090 091 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus> convertSupplyDeliveryStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus> src) throws FHIRException { 092 if (src == null || src.isEmpty()) 093 return null; 094 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatusEnumFactory()); 095 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 096 switch (src.getValue()) { 097 case INPROGRESS: 098 tgt.setValue(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 099 break; 100 case COMPLETED: 101 tgt.setValue(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 102 break; 103 case ABANDONED: 104 tgt.setValue(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 105 break; 106 case ENTEREDINERROR: 107 tgt.setValue(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR); 108 break; 109 default: 110 tgt.setValue(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus.NULL); 111 break; 112 } 113 return tgt; 114 } 115 116 public static org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException { 117 if (src == null) 118 return null; 119 org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent(); 120 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 121 if (src.hasQuantity()) 122 tgt.setQuantity(SimpleQuantity30_40.convertSimpleQuantity(src.getQuantity())); 123 if (src.hasItem()) 124 tgt.setItem(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getItem())); 125 return tgt; 126 } 127 128 public static org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException { 129 if (src == null) 130 return null; 131 org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent(); 132 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 133 if (src.hasQuantity()) 134 tgt.setQuantity(SimpleQuantity30_40.convertSimpleQuantity(src.getQuantity())); 135 if (src.hasItem()) 136 tgt.setItem(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getItem())); 137 return tgt; 138 } 139}