![](/hapi-fhir/images/logos/raccoon-forwards.png)
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.Annotation43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.SimpleQuantity43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 010import org.hl7.fhir.exceptions.FHIRException; 011import org.hl7.fhir.r5.model.CodeableReference; 012 013/* 014 Copyright (c) 2011+, HL7, Inc. 015 All rights reserved. 016 017 Redistribution and use in source and binary forms, with or without modification, 018 are permitted provided that the following conditions are met: 019 020 * Redistributions of source code must retain the above copyright notice, this 021 list of conditions and the following disclaimer. 022 * Redistributions in binary form must reproduce the above copyright notice, 023 this list of conditions and the following disclaimer in the documentation 024 and/or other materials provided with the distribution. 025 * Neither the name of HL7 nor the names of its contributors may be used to 026 endorse or promote products derived from this software without specific 027 prior written permission. 028 029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 030 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 031 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 032 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 033 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 034 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 035 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 036 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 037 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 038 POSSIBILITY OF SUCH DAMAGE. 039 040*/ 041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 042public class MedicationAdministration43_50 { 043 044 public static org.hl7.fhir.r5.model.MedicationAdministration convertMedicationAdministration(org.hl7.fhir.r4b.model.MedicationAdministration src) throws FHIRException { 045 if (src == null) 046 return null; 047 org.hl7.fhir.r5.model.MedicationAdministration tgt = new org.hl7.fhir.r5.model.MedicationAdministration(); 048 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 049 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 050 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 051// for (org.hl7.fhir.r4b.model.UriType t : src.getInstantiates()) tgt.getInstantiatesUri().add(Uri43_50.convertUri(t)); 052 for (org.hl7.fhir.r4b.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t)); 053 if (src.hasStatus()) 054 tgt.setStatusElement(convertMedicationAdministrationStatus(src.getStatusElement())); 055 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getStatusReason()) 056 tgt.addStatusReason(CodeableConcept43_50.convertCodeableConcept(t)); 057 if (src.hasCategory()) 058 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(src.getCategory())); 059 if (src.hasMedicationCodeableConcept()) 060 tgt.getMedication().setConcept(CodeableConcept43_50.convertCodeableConcept(src.getMedicationCodeableConcept())); 061 if (src.hasMedicationReference()) 062 tgt.getMedication().setReference(Reference43_50.convertReference(src.getMedicationReference())); 063 if (src.hasSubject()) 064 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 065 if (src.hasContext()) 066 tgt.setEncounter(Reference43_50.convertReference(src.getContext())); 067 for (org.hl7.fhir.r4b.model.Reference t : src.getSupportingInformation()) 068 tgt.addSupportingInformation(Reference43_50.convertReference(t)); 069 if (src.hasEffective()) 070 tgt.setOccurence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getEffective())); 071 for (org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationPerformerComponent t : src.getPerformer()) 072 tgt.addPerformer(convertMedicationAdministrationPerformerComponent(t)); 073 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getReasonCode()) 074 tgt.addReason(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t)); 075 for (org.hl7.fhir.r4b.model.Reference t : src.getReasonReference()) 076 tgt.addReason(Reference43_50.convertReferenceToCodeableReference(t)); 077 if (src.hasRequest()) 078 tgt.setRequest(Reference43_50.convertReference(src.getRequest())); 079 for (org.hl7.fhir.r4b.model.Reference t : src.getDevice()) tgt.addDevice(Reference43_50.convertReferenceToCodeableReference(t)); 080 for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t)); 081 if (src.hasDosage()) 082 tgt.setDosage(convertMedicationAdministrationDosageComponent(src.getDosage())); 083 for (org.hl7.fhir.r4b.model.Reference t : src.getEventHistory()) 084 tgt.addEventHistory(Reference43_50.convertReference(t)); 085 return tgt; 086 } 087 088 public static org.hl7.fhir.r4b.model.MedicationAdministration convertMedicationAdministration(org.hl7.fhir.r5.model.MedicationAdministration src) throws FHIRException { 089 if (src == null) 090 return null; 091 org.hl7.fhir.r4b.model.MedicationAdministration tgt = new org.hl7.fhir.r4b.model.MedicationAdministration(); 092 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 093 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 094 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 095// for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri()) tgt.getInstantiates().add(Uri43_50.convertUri(t)); 096 for (org.hl7.fhir.r5.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t)); 097 if (src.hasStatus()) 098 tgt.setStatusElement(convertMedicationAdministrationStatus(src.getStatusElement())); 099 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getStatusReason()) 100 tgt.addStatusReason(CodeableConcept43_50.convertCodeableConcept(t)); 101 if (src.hasCategory()) 102 tgt.setCategory(CodeableConcept43_50.convertCodeableConcept(src.getCategoryFirstRep())); 103 if (src.getMedication().hasConcept()) 104 tgt.setMedication(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getMedication().getConcept())); 105 if (src.getMedication().hasReference()) 106 tgt.setMedication(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getMedication().getReference())); 107 if (src.hasSubject()) 108 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 109 if (src.hasEncounter()) 110 tgt.setContext(Reference43_50.convertReference(src.getEncounter())); 111 for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInformation()) 112 tgt.addSupportingInformation(Reference43_50.convertReference(t)); 113 if (src.hasOccurence()) 114 tgt.setEffective(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurence())); 115 for (org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationPerformerComponent t : src.getPerformer()) 116 tgt.addPerformer(convertMedicationAdministrationPerformerComponent(t)); 117 for (CodeableReference t : src.getReason()) 118 if (t.hasConcept()) 119 tgt.addReasonCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept())); 120 for (CodeableReference t : src.getReason()) 121 if (t.hasReference()) 122 tgt.addReasonReference(Reference43_50.convertReference(t.getReference())); 123 if (src.hasRequest()) 124 tgt.setRequest(Reference43_50.convertReference(src.getRequest())); 125 for (CodeableReference t : src.getDevice()) 126 if (t.hasReference()) 127 tgt.addDevice(Reference43_50.convertReference(t.getReference())); 128 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t)); 129 if (src.hasDosage()) 130 tgt.setDosage(convertMedicationAdministrationDosageComponent(src.getDosage())); 131 for (org.hl7.fhir.r5.model.Reference t : src.getEventHistory()) 132 tgt.addEventHistory(Reference43_50.convertReference(t)); 133 return tgt; 134 } 135 136 private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes> convertMedicationAdministrationStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes> src) { 137 if (src == null) 138 return null; 139 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodesEnumFactory()); 140 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 141 // 142 switch (src.getValue()) { 143 case COMPLETED: 144 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.COMPLETED); 145 break; 146 case ENTEREDINERROR: 147 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.ENTEREDINERROR); 148 break; 149 case INPROGRESS: 150 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.INPROGRESS); 151 break; 152 case NOTDONE: 153 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.NOTDONE); 154 break; 155 case NULL: 156 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.NULL); 157 break; 158 case ONHOLD: 159 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.ONHOLD); 160 break; 161 case STOPPED: 162 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.STOPPED); 163 break; 164 case UNKNOWN: 165 tgt.setValue(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes.UNKNOWN); 166 break; 167 } 168 return tgt; 169 } 170 171 private static org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes> convertMedicationAdministrationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationStatusCodes> src) { 172 if (src == null) 173 return null; 174 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodesEnumFactory()); 175 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 176 // 177 switch (src.getValue()) { 178 case COMPLETED: 179 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.COMPLETED); 180 break; 181 case ENTEREDINERROR: 182 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.ENTEREDINERROR); 183 break; 184 case INPROGRESS: 185 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.INPROGRESS); 186 break; 187 case NOTDONE: 188 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.NOTDONE); 189 break; 190 case NULL: 191 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.NULL); 192 break; 193 case ONHOLD: 194 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.ONHOLD); 195 break; 196 case STOPPED: 197 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.STOPPED); 198 break; 199 case UNKNOWN: 200 tgt.setValue(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationStatusCodes.UNKNOWN); 201 break; 202 } 203 return tgt; 204 } 205 206 public static org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationPerformerComponent convertMedicationAdministrationPerformerComponent(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationPerformerComponent src) throws FHIRException { 207 if (src == null) 208 return null; 209 org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationPerformerComponent tgt = new org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationPerformerComponent(); 210 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 211 if (src.hasFunction()) 212 tgt.setFunction(CodeableConcept43_50.convertCodeableConcept(src.getFunction())); 213 if (src.hasActor()) 214 tgt.setActor(Reference43_50.convertReferenceToCodeableReference(src.getActor())); 215 return tgt; 216 } 217 218 public static org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationPerformerComponent convertMedicationAdministrationPerformerComponent(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationPerformerComponent src) throws FHIRException { 219 if (src == null) 220 return null; 221 org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationPerformerComponent tgt = new org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationPerformerComponent(); 222 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 223 if (src.hasFunction()) 224 tgt.setFunction(CodeableConcept43_50.convertCodeableConcept(src.getFunction())); 225 if (src.hasActor() && src.getActor().hasReference()) 226 tgt.setActor(Reference43_50.convertReference(src.getActor().getReference())); 227 return tgt; 228 } 229 230 public static org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationDosageComponent convertMedicationAdministrationDosageComponent(org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationDosageComponent src) throws FHIRException { 231 if (src == null) 232 return null; 233 org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationDosageComponent tgt = new org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationDosageComponent(); 234 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 235 if (src.hasText()) 236 tgt.setTextElement(String43_50.convertString(src.getTextElement())); 237 if (src.hasSite()) 238 tgt.setSite(CodeableConcept43_50.convertCodeableConcept(src.getSite())); 239 if (src.hasRoute()) 240 tgt.setRoute(CodeableConcept43_50.convertCodeableConcept(src.getRoute())); 241 if (src.hasMethod()) 242 tgt.setMethod(CodeableConcept43_50.convertCodeableConcept(src.getMethod())); 243 if (src.hasDose()) 244 tgt.setDose(SimpleQuantity43_50.convertSimpleQuantity(src.getDose())); 245 if (src.hasRate()) 246 tgt.setRate(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getRate())); 247 return tgt; 248 } 249 250 public static org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationDosageComponent convertMedicationAdministrationDosageComponent(org.hl7.fhir.r5.model.MedicationAdministration.MedicationAdministrationDosageComponent src) throws FHIRException { 251 if (src == null) 252 return null; 253 org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationDosageComponent tgt = new org.hl7.fhir.r4b.model.MedicationAdministration.MedicationAdministrationDosageComponent(); 254 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 255 if (src.hasText()) 256 tgt.setTextElement(String43_50.convertString(src.getTextElement())); 257 if (src.hasSite()) 258 tgt.setSite(CodeableConcept43_50.convertCodeableConcept(src.getSite())); 259 if (src.hasRoute()) 260 tgt.setRoute(CodeableConcept43_50.convertCodeableConcept(src.getRoute())); 261 if (src.hasMethod()) 262 tgt.setMethod(CodeableConcept43_50.convertCodeableConcept(src.getMethod())); 263 if (src.hasDose()) 264 tgt.setDose(SimpleQuantity43_50.convertSimpleQuantity(src.getDose())); 265 if (src.hasRate()) 266 tgt.setRate(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getRate())); 267 return tgt; 268 } 269}