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.*; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Dosage40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_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 MedicationRequest40_50 { 040 041 public static org.hl7.fhir.r5.model.MedicationRequest convertMedicationRequest(org.hl7.fhir.r4.model.MedicationRequest src) throws FHIRException { 042 if (src == null) 043 return null; 044 org.hl7.fhir.r5.model.MedicationRequest tgt = new org.hl7.fhir.r5.model.MedicationRequest(); 045 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 046 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 047 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 048 if (src.hasStatus()) 049 tgt.setStatusElement(convertMedicationRequestStatus(src.getStatusElement())); 050 if (src.hasStatusReason()) 051 tgt.setStatusReason(CodeableConcept40_50.convertCodeableConcept(src.getStatusReason())); 052 if (src.hasIntent()) 053 tgt.setIntentElement(convertMedicationRequestIntent(src.getIntentElement())); 054 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) 055 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 056 if (src.hasPriority()) 057 tgt.setPriorityElement(convertMedicationRequestPriority(src.getPriorityElement())); 058 if (src.hasDoNotPerform()) 059 tgt.setDoNotPerformElement(Boolean40_50.convertBoolean(src.getDoNotPerformElement())); 060 if (src.hasReportedBooleanType()) 061 tgt.setReportedElement(Boolean40_50.convertBoolean(src.getReportedBooleanType())); 062 if (src.hasReportedReference()) 063 tgt.setInformationSource(Reference40_50.convertReference(src.getReportedReference())); 064 if (src.hasMedicationCodeableConcept()) 065 tgt.getMedication().setConcept(CodeableConcept40_50.convertCodeableConcept(src.getMedicationCodeableConcept())); 066 if (src.hasMedicationReference()) 067 tgt.getMedication().setReference(Reference40_50.convertReference(src.getMedicationReference())); 068 if (src.hasSubject()) 069 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 070 if (src.hasEncounter()) 071 tgt.setEncounter(Reference40_50.convertReference(src.getEncounter())); 072 for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation()) 073 tgt.addSupportingInformation(Reference40_50.convertReference(t)); 074 if (src.hasAuthoredOn()) 075 tgt.setAuthoredOnElement(DateTime40_50.convertDateTime(src.getAuthoredOnElement())); 076 if (src.hasRequester()) 077 tgt.setRequester(Reference40_50.convertReference(src.getRequester())); 078 if (src.hasPerformer()) 079 tgt.setPerformer(Reference40_50.convertReference(src.getPerformer())); 080 if (src.hasPerformerType()) 081 tgt.setPerformerType(CodeableConcept40_50.convertCodeableConcept(src.getPerformerType())); 082 if (src.hasRecorder()) 083 tgt.setRecorder(Reference40_50.convertReference(src.getRecorder())); 084 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) 085 tgt.addReason().setConcept(CodeableConcept40_50.convertCodeableConcept(t)); 086 for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference()) 087 tgt.addReason().setReference(Reference40_50.convertReference(t)); 088 for (org.hl7.fhir.r4.model.CanonicalType t : src.getInstantiatesCanonical()) 089 tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t)); 090 for (org.hl7.fhir.r4.model.UriType t : src.getInstantiatesUri()) 091 tgt.getInstantiatesUri().add(Uri40_50.convertUri(t)); 092 for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 093 if (src.hasGroupIdentifier()) 094 tgt.setGroupIdentifier(Identifier40_50.convertIdentifier(src.getGroupIdentifier())); 095 if (src.hasCourseOfTherapyType()) 096 tgt.setCourseOfTherapyType(CodeableConcept40_50.convertCodeableConcept(src.getCourseOfTherapyType())); 097 for (org.hl7.fhir.r4.model.Reference t : src.getInsurance()) tgt.addInsurance(Reference40_50.convertReference(t)); 098 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 099 for (org.hl7.fhir.r4.model.Dosage t : src.getDosageInstruction()) 100 tgt.getDose().addDosageInstruction(Dosage40_50.convertDosage(t)); 101 if (src.hasDispenseRequest()) 102 tgt.setDispenseRequest(convertMedicationRequestDispenseRequestComponent(src.getDispenseRequest())); 103 if (src.hasSubstitution()) 104 tgt.setSubstitution(convertMedicationRequestSubstitutionComponent(src.getSubstitution())); 105 if (src.hasPriorPrescription()) 106 tgt.setPriorPrescription(Reference40_50.convertReference(src.getPriorPrescription())); 107 for (org.hl7.fhir.r4.model.Reference t : src.getDetectedIssue()) 108 tgt.addDetectedIssue(Reference40_50.convertReference(t)); 109 for (org.hl7.fhir.r4.model.Reference t : src.getEventHistory()) 110 tgt.addEventHistory(Reference40_50.convertReference(t)); 111 return tgt; 112 } 113 114 public static org.hl7.fhir.r4.model.MedicationRequest convertMedicationRequest(org.hl7.fhir.r5.model.MedicationRequest src) throws FHIRException { 115 if (src == null) 116 return null; 117 org.hl7.fhir.r4.model.MedicationRequest tgt = new org.hl7.fhir.r4.model.MedicationRequest(); 118 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 119 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 120 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 121 if (src.hasStatus()) 122 tgt.setStatusElement(convertMedicationRequestStatus(src.getStatusElement())); 123 if (src.hasStatusReason()) 124 tgt.setStatusReason(CodeableConcept40_50.convertCodeableConcept(src.getStatusReason())); 125 if (src.hasIntent()) 126 tgt.setIntentElement(convertMedicationRequestIntent(src.getIntentElement())); 127 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 128 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 129 if (src.hasPriority()) 130 tgt.setPriorityElement(convertMedicationRequestPriority(src.getPriorityElement())); 131 if (src.hasDoNotPerform()) 132 tgt.setDoNotPerformElement(Boolean40_50.convertBoolean(src.getDoNotPerformElement())); 133 if (src.hasReported()) 134 tgt.setReported(Boolean40_50.convertBoolean(src.getReportedElement())); 135 if (src.hasInformationSource()) 136 tgt.setReported(Reference40_50.convertReference(src.getInformationSource())); 137 if (src.getMedication().hasReference()) 138 tgt.setMedication(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getMedication().getReference())); 139 if (src.getMedication().hasConcept()) 140 tgt.setMedication(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getMedication().getConcept())); 141 if (src.hasSubject()) 142 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 143 if (src.hasEncounter()) 144 tgt.setEncounter(Reference40_50.convertReference(src.getEncounter())); 145 for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInformation()) 146 tgt.addSupportingInformation(Reference40_50.convertReference(t)); 147 if (src.hasAuthoredOn()) 148 tgt.setAuthoredOnElement(DateTime40_50.convertDateTime(src.getAuthoredOnElement())); 149 if (src.hasRequester()) 150 tgt.setRequester(Reference40_50.convertReference(src.getRequester())); 151 if (src.hasPerformer()) 152 tgt.setPerformer(Reference40_50.convertReference(src.getPerformer())); 153 if (src.hasPerformerType()) 154 tgt.setPerformerType(CodeableConcept40_50.convertCodeableConcept(src.getPerformerType())); 155 if (src.hasRecorder()) 156 tgt.setRecorder(Reference40_50.convertReference(src.getRecorder())); 157 for (org.hl7.fhir.r5.model.CodeableReference t : src.getReason()) { 158 if (t.hasConcept()) 159 tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 160 if (t.hasReference()) 161 tgt.addReasonReference(Reference40_50.convertReference(t.getReference())); 162 } 163 for (org.hl7.fhir.r5.model.CanonicalType t : src.getInstantiatesCanonical()) 164 tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t)); 165 for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri()) 166 tgt.getInstantiatesUri().add(Uri40_50.convertUri(t)); 167 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 168 if (src.hasGroupIdentifier()) 169 tgt.setGroupIdentifier(Identifier40_50.convertIdentifier(src.getGroupIdentifier())); 170 if (src.hasCourseOfTherapyType()) 171 tgt.setCourseOfTherapyType(CodeableConcept40_50.convertCodeableConcept(src.getCourseOfTherapyType())); 172 for (org.hl7.fhir.r5.model.Reference t : src.getInsurance()) tgt.addInsurance(Reference40_50.convertReference(t)); 173 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 174 for (org.hl7.fhir.r5.model.Dosage t : src.getDose().getDosageInstruction()) 175 tgt.addDosageInstruction(Dosage40_50.convertDosage(t)); 176 if (src.hasDispenseRequest()) 177 tgt.setDispenseRequest(convertMedicationRequestDispenseRequestComponent(src.getDispenseRequest())); 178 if (src.hasSubstitution()) 179 tgt.setSubstitution(convertMedicationRequestSubstitutionComponent(src.getSubstitution())); 180 if (src.hasPriorPrescription()) 181 tgt.setPriorPrescription(Reference40_50.convertReference(src.getPriorPrescription())); 182 for (org.hl7.fhir.r5.model.Reference t : src.getDetectedIssue()) 183 tgt.addDetectedIssue(Reference40_50.convertReference(t)); 184 for (org.hl7.fhir.r5.model.Reference t : src.getEventHistory()) 185 tgt.addEventHistory(Reference40_50.convertReference(t)); 186 return tgt; 187 } 188 189 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus> convertMedicationRequestStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus> src) throws FHIRException { 190 if (src == null || src.isEmpty()) 191 return null; 192 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatusEnumFactory()); 193 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 194 switch (src.getValue()) { 195 case ACTIVE: 196 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.ACTIVE); 197 break; 198 case ONHOLD: 199 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.ONHOLD); 200 break; 201 case CANCELLED: 202 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.CANCELLED); 203 break; 204 case COMPLETED: 205 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.COMPLETED); 206 break; 207 case ENTEREDINERROR: 208 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.ENTEREDINERROR); 209 break; 210 case STOPPED: 211 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.STOPPED); 212 break; 213 case DRAFT: 214 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.DRAFT); 215 break; 216 case UNKNOWN: 217 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.UNKNOWN); 218 break; 219 default: 220 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus.NULL); 221 break; 222 } 223 return tgt; 224 } 225 226 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus> convertMedicationRequestStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationRequest.MedicationrequestStatus> src) throws FHIRException { 227 if (src == null || src.isEmpty()) 228 return null; 229 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatusEnumFactory()); 230 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 231 switch (src.getValue()) { 232 case ACTIVE: 233 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.ACTIVE); 234 break; 235 case ONHOLD: 236 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.ONHOLD); 237 break; 238 case CANCELLED: 239 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.CANCELLED); 240 break; 241 case COMPLETED: 242 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.COMPLETED); 243 break; 244 case ENTEREDINERROR: 245 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.ENTEREDINERROR); 246 break; 247 case STOPPED: 248 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.STOPPED); 249 break; 250 case DRAFT: 251 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.DRAFT); 252 break; 253 case UNKNOWN: 254 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.UNKNOWN); 255 break; 256 default: 257 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.NULL); 258 break; 259 } 260 return tgt; 261 } 262 263 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent> convertMedicationRequestIntent(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent> src) throws FHIRException { 264 if (src == null || src.isEmpty()) 265 return null; 266 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntentEnumFactory()); 267 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 268 switch (src.getValue()) { 269 case PROPOSAL: 270 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.PROPOSAL); 271 break; 272 case PLAN: 273 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.PLAN); 274 break; 275 case ORDER: 276 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.ORDER); 277 break; 278 case ORIGINALORDER: 279 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.ORIGINALORDER); 280 break; 281 case REFLEXORDER: 282 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.REFLEXORDER); 283 break; 284 case FILLERORDER: 285 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.FILLERORDER); 286 break; 287 case INSTANCEORDER: 288 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.INSTANCEORDER); 289 break; 290 case OPTION: 291 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.OPTION); 292 break; 293 default: 294 tgt.setValue(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent.NULL); 295 break; 296 } 297 return tgt; 298 } 299 300 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent> convertMedicationRequestIntent(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestIntent> src) throws FHIRException { 301 if (src == null || src.isEmpty()) 302 return null; 303 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntentEnumFactory()); 304 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 305 switch (src.getValue()) { 306 case PROPOSAL: 307 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.PROPOSAL); 308 break; 309 case PLAN: 310 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.PLAN); 311 break; 312 case ORDER: 313 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.ORDER); 314 break; 315 case ORIGINALORDER: 316 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.ORIGINALORDER); 317 break; 318 case REFLEXORDER: 319 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.REFLEXORDER); 320 break; 321 case FILLERORDER: 322 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.FILLERORDER); 323 break; 324 case INSTANCEORDER: 325 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.INSTANCEORDER); 326 break; 327 case OPTION: 328 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.OPTION); 329 break; 330 default: 331 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.NULL); 332 break; 333 } 334 return tgt; 335 } 336 337 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> convertMedicationRequestPriority(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority> src) throws FHIRException { 338 if (src == null || src.isEmpty()) 339 return null; 340 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()); 341 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 342 switch (src.getValue()) { 343 case ROUTINE: 344 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ROUTINE); 345 break; 346 case URGENT: 347 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.URGENT); 348 break; 349 case ASAP: 350 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ASAP); 351 break; 352 case STAT: 353 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.STAT); 354 break; 355 default: 356 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.NULL); 357 break; 358 } 359 return tgt; 360 } 361 362 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority> convertMedicationRequestPriority(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> src) throws FHIRException { 363 if (src == null || src.isEmpty()) 364 return null; 365 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriorityEnumFactory()); 366 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 367 switch (src.getValue()) { 368 case ROUTINE: 369 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.ROUTINE); 370 break; 371 case URGENT: 372 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.URGENT); 373 break; 374 case ASAP: 375 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.ASAP); 376 break; 377 case STAT: 378 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.STAT); 379 break; 380 default: 381 tgt.setValue(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestPriority.NULL); 382 break; 383 } 384 return tgt; 385 } 386 387 public static org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestComponent convertMedicationRequestDispenseRequestComponent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent src) throws FHIRException { 388 if (src == null) 389 return null; 390 org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestComponent tgt = new org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestComponent(); 391 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 392 if (src.hasInitialFill()) 393 tgt.setInitialFill(convertMedicationRequestDispenseRequestInitialFillComponent(src.getInitialFill())); 394 if (src.hasDispenseInterval()) 395 tgt.setDispenseInterval(Duration40_50.convertDuration(src.getDispenseInterval())); 396 if (src.hasValidityPeriod()) 397 tgt.setValidityPeriod(Period40_50.convertPeriod(src.getValidityPeriod())); 398 if (src.hasNumberOfRepeatsAllowed()) 399 tgt.setNumberOfRepeatsAllowedElement(UnsignedInt40_50.convertUnsignedInt(src.getNumberOfRepeatsAllowedElement())); 400 if (src.hasQuantity()) 401 tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity())); 402 if (src.hasExpectedSupplyDuration()) 403 tgt.setExpectedSupplyDuration(Duration40_50.convertDuration(src.getExpectedSupplyDuration())); 404 if (src.hasPerformer()) 405 tgt.setDispenser(Reference40_50.convertReference(src.getPerformer())); 406 return tgt; 407 } 408 409 public static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent convertMedicationRequestDispenseRequestComponent(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestComponent src) throws FHIRException { 410 if (src == null) 411 return null; 412 org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent(); 413 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 414 if (src.hasInitialFill()) 415 tgt.setInitialFill(convertMedicationRequestDispenseRequestInitialFillComponent(src.getInitialFill())); 416 if (src.hasDispenseInterval()) 417 tgt.setDispenseInterval(Duration40_50.convertDuration(src.getDispenseInterval())); 418 if (src.hasValidityPeriod()) 419 tgt.setValidityPeriod(Period40_50.convertPeriod(src.getValidityPeriod())); 420 if (src.hasNumberOfRepeatsAllowed()) 421 tgt.setNumberOfRepeatsAllowedElement(UnsignedInt40_50.convertUnsignedInt(src.getNumberOfRepeatsAllowedElement())); 422 if (src.hasQuantity()) 423 tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity())); 424 if (src.hasExpectedSupplyDuration()) 425 tgt.setExpectedSupplyDuration(Duration40_50.convertDuration(src.getExpectedSupplyDuration())); 426 if (src.hasDispenser()) 427 tgt.setPerformer(Reference40_50.convertReference(src.getDispenser())); 428 return tgt; 429 } 430 431 public static org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent convertMedicationRequestDispenseRequestInitialFillComponent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent src) throws FHIRException { 432 if (src == null) 433 return null; 434 org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent tgt = new org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent(); 435 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 436 if (src.hasQuantity()) 437 tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity())); 438 if (src.hasDuration()) 439 tgt.setDuration(Duration40_50.convertDuration(src.getDuration())); 440 return tgt; 441 } 442 443 public static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent convertMedicationRequestDispenseRequestInitialFillComponent(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent src) throws FHIRException { 444 if (src == null) 445 return null; 446 org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestInitialFillComponent(); 447 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 448 if (src.hasQuantity()) 449 tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity())); 450 if (src.hasDuration()) 451 tgt.setDuration(Duration40_50.convertDuration(src.getDuration())); 452 return tgt; 453 } 454 455 public static org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestSubstitutionComponent convertMedicationRequestSubstitutionComponent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent src) throws FHIRException { 456 if (src == null) 457 return null; 458 org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestSubstitutionComponent tgt = new org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestSubstitutionComponent(); 459 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 460 if (src.hasAllowed()) 461 tgt.setAllowed(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAllowed())); 462 if (src.hasReason()) 463 tgt.setReason(CodeableConcept40_50.convertCodeableConcept(src.getReason())); 464 return tgt; 465 } 466 467 public static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent convertMedicationRequestSubstitutionComponent(org.hl7.fhir.r5.model.MedicationRequest.MedicationRequestSubstitutionComponent src) throws FHIRException { 468 if (src == null) 469 return null; 470 org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent(); 471 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 472 if (src.hasAllowed()) 473 tgt.setAllowed(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAllowed())); 474 if (src.hasReason()) 475 tgt.setReason(CodeableConcept40_50.convertCodeableConcept(src.getReason())); 476 return tgt; 477 } 478}