
001package org.hl7.fhir.convertors.conv40_50.resources40_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext40_50; 004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Quantity40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 009import org.hl7.fhir.exceptions.FHIRException; 010import org.hl7.fhir.r5.model.CodeableReference; 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 SupplyRequest40_50 { 042 043 public static org.hl7.fhir.r5.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.r4.model.SupplyRequest src) throws FHIRException { 044 if (src == null) 045 return null; 046 org.hl7.fhir.r5.model.SupplyRequest tgt = new org.hl7.fhir.r5.model.SupplyRequest(); 047 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 048 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 049 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 050 if (src.hasStatus()) 051 tgt.setStatusElement(convertSupplyRequestStatus(src.getStatusElement())); 052 if (src.hasCategory()) 053 tgt.setCategory(CodeableConcept40_50.convertCodeableConcept(src.getCategory())); 054 if (src.hasPriority()) 055 tgt.setPriorityElement(convertRequestPriority(src.getPriorityElement())); 056 if (src.hasItem()) { 057 if (src.hasItemCodeableConcept()) { 058 tgt.getItem().setConcept(CodeableConcept40_50.convertCodeableConcept(src.getItemCodeableConcept())); 059 } else { 060 tgt.getItem().setReference(Reference40_50.convertReference(src.getItemReference())); 061 } 062 } 063 if (src.hasQuantity()) 064 tgt.setQuantity(Quantity40_50.convertQuantity(src.getQuantity())); 065 for (org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestParameterComponent t : src.getParameter()) 066 tgt.addParameter(convertSupplyRequestParameterComponent(t)); 067 if (src.hasOccurrence()) 068 tgt.setOccurrence(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurrence())); 069 if (src.hasAuthoredOn()) 070 tgt.setAuthoredOnElement(DateTime40_50.convertDateTime(src.getAuthoredOnElement())); 071 if (src.hasRequester()) 072 tgt.setRequester(Reference40_50.convertReference(src.getRequester())); 073 for (org.hl7.fhir.r4.model.Reference t : src.getSupplier()) tgt.addSupplier(Reference40_50.convertReference(t)); 074 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) 075 tgt.addReason(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t)); 076 for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference()) 077 tgt.addReason(Reference40_50.convertReferenceToCodeableReference(t)); 078 if (src.hasDeliverFrom()) 079 tgt.setDeliverFrom(Reference40_50.convertReference(src.getDeliverFrom())); 080 if (src.hasDeliverTo()) 081 tgt.setDeliverTo(Reference40_50.convertReference(src.getDeliverTo())); 082 return tgt; 083 } 084 085 public static org.hl7.fhir.r4.model.SupplyRequest convertSupplyRequest(org.hl7.fhir.r5.model.SupplyRequest src) throws FHIRException { 086 if (src == null) 087 return null; 088 org.hl7.fhir.r4.model.SupplyRequest tgt = new org.hl7.fhir.r4.model.SupplyRequest(); 089 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 090 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 091 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 092 if (src.hasStatus()) 093 tgt.setStatusElement(convertSupplyRequestStatus(src.getStatusElement())); 094 if (src.hasCategory()) 095 tgt.setCategory(CodeableConcept40_50.convertCodeableConcept(src.getCategory())); 096 if (src.hasPriority()) 097 tgt.setPriorityElement(convertRequestPriority(src.getPriorityElement())); 098 if (src.hasItem()) { 099 if (src.getItem().hasReference()) { 100 tgt.setItem(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getItem().getReference())); 101 } else { 102 tgt.setItem(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getItem().getConcept())); 103 } 104 } 105 if (src.hasQuantity()) 106 tgt.setQuantity(Quantity40_50.convertQuantity(src.getQuantity())); 107 for (org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestParameterComponent t : src.getParameter()) 108 tgt.addParameter(convertSupplyRequestParameterComponent(t)); 109 if (src.hasOccurrence()) 110 tgt.setOccurrence(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurrence())); 111 if (src.hasAuthoredOn()) 112 tgt.setAuthoredOnElement(DateTime40_50.convertDateTime(src.getAuthoredOnElement())); 113 if (src.hasRequester()) 114 tgt.setRequester(Reference40_50.convertReference(src.getRequester())); 115 for (org.hl7.fhir.r5.model.Reference t : src.getSupplier()) tgt.addSupplier(Reference40_50.convertReference(t)); 116 for (CodeableReference t : src.getReason()) 117 if (t.hasConcept()) 118 tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 119 for (CodeableReference t : src.getReason()) 120 if (t.hasReference()) 121 tgt.addReasonReference(Reference40_50.convertReference(t.getReference())); 122 if (src.hasDeliverFrom()) 123 tgt.setDeliverFrom(Reference40_50.convertReference(src.getDeliverFrom())); 124 if (src.hasDeliverTo()) 125 tgt.setDeliverTo(Reference40_50.convertReference(src.getDeliverTo())); 126 return tgt; 127 } 128 129 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus> convertSupplyRequestStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus> src) throws FHIRException { 130 if (src == null || src.isEmpty()) 131 return null; 132 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()); 133 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 134 switch (src.getValue()) { 135 case DRAFT: 136 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.DRAFT); 137 break; 138 case ACTIVE: 139 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.ACTIVE); 140 break; 141 case SUSPENDED: 142 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.SUSPENDED); 143 break; 144 case CANCELLED: 145 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.CANCELLED); 146 break; 147 case COMPLETED: 148 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.COMPLETED); 149 break; 150 case ENTEREDINERROR: 151 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.ENTEREDINERROR); 152 break; 153 case UNKNOWN: 154 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.UNKNOWN); 155 break; 156 default: 157 tgt.setValue(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus.NULL); 158 break; 159 } 160 return tgt; 161 } 162 163 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus> convertSupplyRequestStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestStatus> src) throws FHIRException { 164 if (src == null || src.isEmpty()) 165 return null; 166 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatusEnumFactory()); 167 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 168 switch (src.getValue()) { 169 case DRAFT: 170 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.DRAFT); 171 break; 172 case ACTIVE: 173 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ACTIVE); 174 break; 175 case SUSPENDED: 176 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.SUSPENDED); 177 break; 178 case CANCELLED: 179 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.CANCELLED); 180 break; 181 case COMPLETED: 182 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.COMPLETED); 183 break; 184 case ENTEREDINERROR: 185 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.ENTEREDINERROR); 186 break; 187 case UNKNOWN: 188 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.UNKNOWN); 189 break; 190 default: 191 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestStatus.NULL); 192 break; 193 } 194 return tgt; 195 } 196 197 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> convertRequestPriority(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyRequest.RequestPriority> src) throws FHIRException { 198 if (src == null || src.isEmpty()) 199 return null; 200 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestPriorityEnumFactory()); 201 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 202 switch (src.getValue()) { 203 case ROUTINE: 204 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ROUTINE); 205 break; 206 case URGENT: 207 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.URGENT); 208 break; 209 case ASAP: 210 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ASAP); 211 break; 212 case STAT: 213 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.STAT); 214 break; 215 default: 216 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.NULL); 217 break; 218 } 219 return tgt; 220 } 221 222 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyRequest.RequestPriority> convertRequestPriority(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> src) throws FHIRException { 223 if (src == null || src.isEmpty()) 224 return null; 225 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SupplyRequest.RequestPriority> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SupplyRequest.RequestPriorityEnumFactory()); 226 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 227 switch (src.getValue()) { 228 case ROUTINE: 229 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.ROUTINE); 230 break; 231 case URGENT: 232 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.URGENT); 233 break; 234 case ASAP: 235 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.ASAP); 236 break; 237 case STAT: 238 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.STAT); 239 break; 240 default: 241 tgt.setValue(org.hl7.fhir.r4.model.SupplyRequest.RequestPriority.NULL); 242 break; 243 } 244 return tgt; 245 } 246 247 public static org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestParameterComponent convertSupplyRequestParameterComponent(org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestParameterComponent src) throws FHIRException { 248 if (src == null) 249 return null; 250 org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestParameterComponent tgt = new org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestParameterComponent(); 251 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 252 if (src.hasCode()) 253 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 254 if (src.hasValue()) 255 tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue())); 256 return tgt; 257 } 258 259 public static org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestParameterComponent convertSupplyRequestParameterComponent(org.hl7.fhir.r5.model.SupplyRequest.SupplyRequestParameterComponent src) throws FHIRException { 260 if (src == null) 261 return null; 262 org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestParameterComponent tgt = new org.hl7.fhir.r4.model.SupplyRequest.SupplyRequestParameterComponent(); 263 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 264 if (src.hasCode()) 265 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 266 if (src.hasValue()) 267 tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue())); 268 return tgt; 269 } 270}