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; 009 010/* 011 Copyright (c) 2011+, HL7, Inc. 012 All rights reserved. 013 014 Redistribution and use in source and binary forms, with or without modification, 015 are permitted provided that the following conditions are met: 016 017 * Redistributions of source code must retain the above copyright notice, this 018 list of conditions and the following disclaimer. 019 * Redistributions in binary form must reproduce the above copyright notice, 020 this list of conditions and the following disclaimer in the documentation 021 and/or other materials provided with the distribution. 022 * Neither the name of HL7 nor the names of its contributors may be used to 023 endorse or promote products derived from this software without specific 024 prior written permission. 025 026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 027 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 028 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 029 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 030 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 031 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 032 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 033 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 034 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 035 POSSIBILITY OF SUCH DAMAGE. 036 037*/ 038// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 039public class SupplyDelivery43_50 { 040 041 public static org.hl7.fhir.r5.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r4b.model.SupplyDelivery src) throws FHIRException { 042 if (src == null) 043 return null; 044 org.hl7.fhir.r5.model.SupplyDelivery tgt = new org.hl7.fhir.r5.model.SupplyDelivery(); 045 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 046 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 047 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 048 for (org.hl7.fhir.r4b.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t)); 049 for (org.hl7.fhir.r4b.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t)); 050 if (src.hasStatus()) 051 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 052 if (src.hasPatient()) 053 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 054 if (src.hasType()) 055 tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType())); 056 if (src.hasSuppliedItem()) 057 tgt.addSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItem())); 058 if (src.hasOccurrence()) 059 tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence())); 060 if (src.hasSupplier()) 061 tgt.setSupplier(Reference43_50.convertReference(src.getSupplier())); 062 if (src.hasDestination()) 063 tgt.setDestination(Reference43_50.convertReference(src.getDestination())); 064 for (org.hl7.fhir.r4b.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference43_50.convertReference(t)); 065 return tgt; 066 } 067 068 public static org.hl7.fhir.r4b.model.SupplyDelivery convertSupplyDelivery(org.hl7.fhir.r5.model.SupplyDelivery src) throws FHIRException { 069 if (src == null) 070 return null; 071 org.hl7.fhir.r4b.model.SupplyDelivery tgt = new org.hl7.fhir.r4b.model.SupplyDelivery(); 072 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 073 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 074 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 075 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t)); 076 for (org.hl7.fhir.r5.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t)); 077 if (src.hasStatus()) 078 tgt.setStatusElement(convertSupplyDeliveryStatus(src.getStatusElement())); 079 if (src.hasPatient()) 080 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 081 if (src.hasType()) 082 tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType())); 083 if (src.hasSuppliedItem()) 084 tgt.setSuppliedItem(convertSupplyDeliverySuppliedItemComponent(src.getSuppliedItemFirstRep())); 085 if (src.hasOccurrence()) 086 tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence())); 087 if (src.hasSupplier()) 088 tgt.setSupplier(Reference43_50.convertReference(src.getSupplier())); 089 if (src.hasDestination()) 090 tgt.setDestination(Reference43_50.convertReference(src.getDestination())); 091 for (org.hl7.fhir.r5.model.Reference t : src.getReceiver()) tgt.addReceiver(Reference43_50.convertReference(t)); 092 return tgt; 093 } 094 095 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 { 096 if (src == null || src.isEmpty()) 097 return null; 098 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()); 099 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 100 switch (src.getValue()) { 101 case INPROGRESS: 102 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 103 break; 104 case COMPLETED: 105 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 106 break; 107 case ABANDONED: 108 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 109 break; 110 case ENTEREDINERROR: 111 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR); 112 break; 113 default: 114 tgt.setValue(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliveryStatus.NULL); 115 break; 116 } 117 return tgt; 118 } 119 120 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 { 121 if (src == null || src.isEmpty()) 122 return null; 123 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()); 124 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 125 switch (src.getValue()) { 126 case INPROGRESS: 127 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.INPROGRESS); 128 break; 129 case COMPLETED: 130 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.COMPLETED); 131 break; 132 case ABANDONED: 133 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.ABANDONED); 134 break; 135 case ENTEREDINERROR: 136 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.ENTEREDINERROR); 137 break; 138 default: 139 tgt.setValue(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliveryStatus.NULL); 140 break; 141 } 142 return tgt; 143 } 144 145 public static org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException { 146 if (src == null) 147 return null; 148 org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent(); 149 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 150 if (src.hasQuantity()) 151 tgt.setQuantity(SimpleQuantity43_50.convertSimpleQuantity(src.getQuantity())); 152 if (src.hasItem()) 153 tgt.setItem(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getItem())); 154 return tgt; 155 } 156 157 public static org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent convertSupplyDeliverySuppliedItemComponent(org.hl7.fhir.r5.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent src) throws FHIRException { 158 if (src == null) 159 return null; 160 org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent tgt = new org.hl7.fhir.r4b.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent(); 161 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 162 if (src.hasQuantity()) 163 tgt.setQuantity(SimpleQuantity43_50.convertSimpleQuantity(src.getQuantity())); 164 if (src.hasItem()) 165 tgt.setItem(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getItem())); 166 return tgt; 167 } 168}