001package org.hl7.fhir.convertors.conv10_50.resources10_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_50; 004import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Reference10_50; 005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.CodeableConcept10_50; 006import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Identifier10_50; 007import org.hl7.fhir.exceptions.FHIRException; 008 009public class SupplyDelivery10_50 { 010 011 public static org.hl7.fhir.dstu2.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r5.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_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt); 016 if (src.hasIdentifier()) 017 tgt.setIdentifier(Identifier10_50.convertIdentifier(src.getIdentifierFirstRep())); 018 if (src.hasStatus()) 019 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 020 if (src.hasPatient()) 021 tgt.setPatient(Reference10_50.convertReference(src.getPatient())); 022 if (src.hasType()) 023 tgt.setType(CodeableConcept10_50.convertCodeableConcept(src.getType())); 024 if (src.hasSupplier()) 025 tgt.setSupplier(Reference10_50.convertReference(src.getSupplier())); 026 if (src.hasDestination()) 027 tgt.setDestination(Reference10_50.convertReference(src.getDestination())); 028 for (org.hl7.fhir.r5.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference10_50.convertReference(t)); 029 return tgt; 030 } 031 032 public static org.hl7.fhir.r5.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.r5.model.SupplyDelivery tgt = new org.hl7.fhir.r5.model.SupplyDelivery(); 036 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt); 037 if (src.hasIdentifier()) 038 tgt.addIdentifier(Identifier10_50.convertIdentifier(src.getIdentifier())); 039 if (src.hasStatus()) 040 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 041 if (src.hasPatient()) 042 tgt.setPatient(Reference10_50.convertReference(src.getPatient())); 043 if (src.hasType()) 044 tgt.setType(CodeableConcept10_50.convertCodeableConcept(src.getType())); 045 if (src.hasSupplier()) 046 tgt.setSupplier(Reference10_50.convertReference(src.getSupplier())); 047 if (src.hasDestination()) 048 tgt.setDestination(Reference10_50.convertReference(src.getDestination())); 049 for (org.hl7.fhir.dstu2.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference10_50.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.r5.model.Enumeration<org.hl7.fhir.r5.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_50.INSTANCE.getVersionConvertor_10_50().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.r5.model.Enumeration<org.hl7.fhir.r5.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.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatusEnumFactory()); 079 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 080 switch (src.getValue()) { 081 case INPROGRESS: 082 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 083 break; 084 case COMPLETED: 085 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 086 break; 087 case ABANDONED: 088 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 089 break; 090 default: 091 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.NULL); 092 break; 093 } 094 return tgt; 095 } 096 097 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus> convertSupplyRequestStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus> src) throws FHIRException { 098 if (src == null || src.isEmpty()) return null; 099 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatusEnumFactory()); 100 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 101 if (src.getValue() == null) { 102 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.NULL); 103 } else { 104 switch (src.getValue()) { 105 case REQUESTED: 106 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.ACTIVE); 107 break; 108 case COMPLETED: 109 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.COMPLETED); 110 break; 111 case FAILED: 112 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); 113 break; 114 case CANCELLED: 115 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); 116 break; 117 default: 118 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.NULL); 119 break; 120 } 121 } 122 return tgt; 123 } 124 125 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus> convertSupplyRequestStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus> src) throws FHIRException { 126 if (src == null || src.isEmpty()) return null; 127 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatusEnumFactory()); 128 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 129 if (src.getValue() == null) { 130 tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); 131 } else { 132 switch (src.getValue()) { 133 case ACTIVE: 134 tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.REQUESTED); 135 break; 136 case COMPLETED: 137 tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.COMPLETED); 138 break; 139 case CANCELLED: 140 tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.CANCELLED); 141 break; 142 default: 143 tgt.setValue(org.hl7.fhir.dstu2.model.SupplyRequest.SupplyRequestStatus.NULL); 144 break; 145 } 146 } 147 return tgt; 148 } 149}