
001package org.hl7.fhir.convertors.conv43_50.resources43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.SimpleQuantity43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 008import org.hl7.fhir.exceptions.FHIRException; 009import org.hl7.fhir.r5.model.Enumeration; 010import org.hl7.fhir.r5.model.SupplyDelivery; 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 SupplyDelivery43_50 { 042 043 public static org.hl7.fhir.r5.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4b.model.SupplyDelivery src) throws FHIRException { 044 if (src == null) 045 return null; 046 org.hl7.fhir.r5.model.SupplyDelivery tgt = new org.hl7.fhir.r5.model.SupplyDelivery(); 047 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 048 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 049 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 050 for (org.hl7.fhir.r4b.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t)); 051 for (org.hl7.fhir.r4b.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t)); 052 if (src.hasStatus()) 053 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 054 if (src.hasPatient()) 055 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 056 if (src.hasType()) 057 tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType())); 058 if (src.hasSuppliedItem()) 059 tgt.addSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItem())); 060 if (src.hasOccurrence()) 061 tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence())); 062 if (src.hasSupplier()) 063 tgt.setSupplier(Reference43_50.convertReference(src.getSupplier())); 064 if (src.hasDestination()) 065 tgt.setDestination(Reference43_50.convertReference(src.getDestination())); 066 for (org.hl7.fhir.r4b.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference43_50.convertReference(t)); 067 return tgt; 068 } 069 070 public static org.hl7.fhir.r4b.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r5.model.SupplyDelivery src) throws FHIRException { 071 if (src == null) 072 return null; 073 org.hl7.fhir.r4b.model.SupplyDelivery tgt = new org.hl7.fhir.r4b.model.SupplyDelivery(); 074 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 075 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 076 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 077 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t)); 078 for (org.hl7.fhir.r5.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t)); 079 if (src.hasStatus()) 080 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 081 if (src.hasPatient()) 082 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 083 if (src.hasType()) 084 tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType())); 085 if (src.hasSuppliedItem()) 086 tgt.setSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItemFirstRep())); 087 if (src.hasOccurrence()) 088 tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence())); 089 if (src.hasSupplier()) 090 tgt.setSupplier(Reference43_50.convertReference(src.getSupplier())); 091 if (src.hasDestination()) 092 tgt.setDestination(Reference43_50.convertReference(src.getDestination())); 093 for (org.hl7.fhir.r5.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference43_50.convertReference(t)); 094 return tgt; 095 } 096 097 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus> convertSupplyDeliveryStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus> src) throws FHIRException { 098 if (src == null || src.isEmpty()) 099 return null; 100 Enumeration<SupplyDelivery.SupplyDeliveryStatus> tgt = new Enumeration<>(new SupplyDelivery.SupplyDeliveryStatusEnumFactory()); 101 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 102 if (src.getValue() == null) { 103 tgt.setValue(null); 104 } else { 105 switch (src.getValue()) { 106 case INPROGRESS: 107 tgt.setValue(SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 108 break; 109 case COMPLETED: 110 tgt.setValue(SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 111 break; 112 case ABANDONED: 113 tgt.setValue(SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 114 break; 115 case ENTEREDINERROR: 116 tgt.setValue(SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR); 117 break; 118 default: 119 tgt.setValue(SupplyDelivery.SupplyDeliveryStatus.NULL); 120 break; 121 } 122 } 123 return tgt; 124 } 125 126 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus> convertSupplyDeliveryStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus> src) throws FHIRException { 127 if (src == null || src.isEmpty()) 128 return null; 129 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatusEnumFactory()); 130 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 131 if (src.getValue() == null) { 132 tgt.setValue(null); 133 } else { 134 switch (src.getValue()) { 135 case INPROGRESS: 136 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 137 break; 138 case COMPLETED: 139 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 140 break; 141 case ABANDONED: 142 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 143 break; 144 case ENTEREDINERROR: 145 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR); 146 break; 147 default: 148 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.NULL); 149 break; 150 } 151 } 152 return tgt; 153 } 154 155 public static org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException { 156 if (src == null) 157 return null; 158 org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent(); 159 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 160 if (src.hasQuantity()) 161 tgt.setQuantity(SimpleQuantity43_50.convertSimpleQuantity(src.getQuantity())); 162 if (src.hasItem()) 163 tgt.setItem(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getItem())); 164 return tgt; 165 } 166 167 public static org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException { 168 if (src == null) 169 return null; 170 org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent(); 171 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 172 if (src.hasQuantity()) 173 tgt.setQuantity(SimpleQuantity43_50.convertSimpleQuantity(src.getQuantity())); 174 if (src.hasItem()) 175 tgt.setItem(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getItem())); 176 return tgt; 177 } 178}