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.Coding40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Duration40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Period40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 010import org.hl7.fhir.exceptions.FHIRException; 011import org.hl7.fhir.r5.model.CodeableReference; 012import org.hl7.fhir.r5.model.Encounter.ReasonComponent; 013 014/* 015 Copyright (c) 2011+, HL7, Inc. 016 All rights reserved. 017 018 Redistribution and use in source and binary forms, with or without modification, 019 are permitted provided that the following conditions are met: 020 021 * Redistributions of source code must retain the above copyright notice, this 022 list of conditions and the following disclaimer. 023 * Redistributions in binary form must reproduce the above copyright notice, 024 this list of conditions and the following disclaimer in the documentation 025 and/or other materials provided with the distribution. 026 * Neither the name of HL7 nor the names of its contributors may be used to 027 endorse or promote products derived from this software without specific 028 prior written permission. 029 030 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 031 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 032 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 033 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 034 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 035 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 036 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 037 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 039 POSSIBILITY OF SUCH DAMAGE. 040 041*/ 042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 043public class Encounter40_50 { 044 045 public static org.hl7.fhir.r5.model.Encounter convertEncounter(org.hl7.fhir.r4.model.Encounter src) throws FHIRException { 046 if (src == null) 047 return null; 048 org.hl7.fhir.r5.model.Encounter tgt = new org.hl7.fhir.r5.model.Encounter(); 049 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 050 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 051 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 052 if (src.hasStatus()) 053 tgt.setStatusElement(convertEncounterStatus(src.getStatusElement())); 054// for (org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent t : src.getStatusHistory()) 055// tgt.addStatusHistory(convertStatusHistoryComponent(t)); 056 if (src.hasClass_()) 057 tgt.addClass_(new org.hl7.fhir.r5.model.CodeableConcept().addCoding(Coding40_50.convertCoding(src.getClass_()))); 058// for (org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent t : src.getClassHistory()) 059// tgt.addClassHistory(convertClassHistoryComponent(t)); 060 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) 061 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 062 if (src.hasServiceType()) 063 tgt.addServiceType(new CodeableReference(CodeableConcept40_50.convertCodeableConcept(src.getServiceType()))); 064 if (src.hasPriority()) 065 tgt.setPriority(CodeableConcept40_50.convertCodeableConcept(src.getPriority())); 066 if (src.hasSubject()) 067 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 068 for (org.hl7.fhir.r4.model.Reference t : src.getEpisodeOfCare()) 069 tgt.addEpisodeOfCare(Reference40_50.convertReference(t)); 070 for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 071 for (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent t : src.getParticipant()) 072 tgt.addParticipant(convertEncounterParticipantComponent(t)); 073 for (org.hl7.fhir.r4.model.Reference t : src.getAppointment()) 074 tgt.addAppointment(Reference40_50.convertReference(t)); 075 if (src.hasPeriod()) 076 tgt.setActualPeriod(Period40_50.convertPeriod(src.getPeriod())); 077 if (src.hasLength()) 078 tgt.setLength(Duration40_50.convertDuration(src.getLength())); 079 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) 080 tgt.addReason().addValue(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t)); 081 for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference()) 082 tgt.addReason().addValue(Reference40_50.convertReferenceToCodeableReference(t)); 083 for (org.hl7.fhir.r4.model.Encounter.DiagnosisComponent t : src.getDiagnosis()) 084 tgt.addDiagnosis(convertDiagnosisComponent(t)); 085 for (org.hl7.fhir.r4.model.Reference t : src.getAccount()) tgt.addAccount(Reference40_50.convertReference(t)); 086 if (src.hasHospitalization()) 087 tgt.setAdmission(convertEncounterHospitalizationComponent(src.getHospitalization(), tgt)); 088 for (org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent t : src.getLocation()) 089 tgt.addLocation(convertEncounterLocationComponent(t)); 090 if (src.hasServiceProvider()) 091 tgt.setServiceProvider(Reference40_50.convertReference(src.getServiceProvider())); 092 if (src.hasPartOf()) 093 tgt.setPartOf(Reference40_50.convertReference(src.getPartOf())); 094 return tgt; 095 } 096 097 public static org.hl7.fhir.r4.model.Encounter convertEncounter(org.hl7.fhir.r5.model.Encounter src) throws FHIRException { 098 if (src == null) 099 return null; 100 org.hl7.fhir.r4.model.Encounter tgt = new org.hl7.fhir.r4.model.Encounter(); 101 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 102 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 103 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 104 if (src.hasStatus()) 105 tgt.setStatusElement(convertEncounterStatus(src.getStatusElement())); 106// for (org.hl7.fhir.r5.model.Encounter.StatusHistoryComponent t : src.getStatusHistory()) 107// tgt.addStatusHistory(convertStatusHistoryComponent(t)); 108 if (src.hasClass_()) 109 tgt.setClass_(Coding40_50.convertCoding(src.getClass_FirstRep().getCodingFirstRep())); 110// for (org.hl7.fhir.r5.model.Encounter.ClassHistoryComponent t : src.getClassHistory()) 111// tgt.addClassHistory(convertClassHistoryComponent(t)); 112 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 113 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 114 if (src.getServiceTypeFirstRep().hasConcept()) 115 tgt.setServiceType(CodeableConcept40_50.convertCodeableConcept(src.getServiceTypeFirstRep().getConcept())); 116 if (src.hasPriority()) 117 tgt.setPriority(CodeableConcept40_50.convertCodeableConcept(src.getPriority())); 118 if (src.hasSubject()) 119 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 120 for (org.hl7.fhir.r5.model.Reference t : src.getEpisodeOfCare()) 121 tgt.addEpisodeOfCare(Reference40_50.convertReference(t)); 122 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 123 for (org.hl7.fhir.r5.model.Encounter.EncounterParticipantComponent t : src.getParticipant()) 124 tgt.addParticipant(convertEncounterParticipantComponent(t)); 125 for (org.hl7.fhir.r5.model.Reference t : src.getAppointment()) 126 tgt.addAppointment(Reference40_50.convertReference(t)); 127 if (src.hasActualPeriod()) 128 tgt.setPeriod(Period40_50.convertPeriod(src.getActualPeriod())); 129 if (src.hasLength()) 130 tgt.setLength(Duration40_50.convertDuration(src.getLength())); 131 for (ReasonComponent t1 : src.getReason()) 132 for (CodeableReference t : t1.getValue()) 133 if (t.hasConcept()) 134 tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 135 for (ReasonComponent t1 : src.getReason()) 136 for (CodeableReference t : t1.getValue()) 137 if (t.hasReference()) 138 tgt.addReasonReference(Reference40_50.convertReference(t.getReference())); 139 for (org.hl7.fhir.r5.model.Encounter.DiagnosisComponent t : src.getDiagnosis()) 140 tgt.addDiagnosis(convertDiagnosisComponent(t)); 141 for (org.hl7.fhir.r5.model.Reference t : src.getAccount()) tgt.addAccount(Reference40_50.convertReference(t)); 142 if (src.hasAdmission() || src.hasDietPreference() || src.hasSpecialArrangement() || src.hasSpecialCourtesy()) 143 tgt.setHospitalization(convertEncounterHospitalizationComponent(src.getAdmission(), src)); 144 for (org.hl7.fhir.r5.model.Encounter.EncounterLocationComponent t : src.getLocation()) 145 tgt.addLocation(convertEncounterLocationComponent(t)); 146 if (src.hasServiceProvider()) 147 tgt.setServiceProvider(Reference40_50.convertReference(src.getServiceProvider())); 148 if (src.hasPartOf()) 149 tgt.setPartOf(Reference40_50.convertReference(src.getPartOf())); 150 return tgt; 151 } 152 153 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EncounterStatus> convertEncounterStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Encounter.EncounterStatus> src) throws FHIRException { 154 if (src == null || src.isEmpty()) 155 return null; 156 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EncounterStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.EncounterStatusEnumFactory()); 157 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 158 switch (src.getValue()) { 159 case PLANNED: 160 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.PLANNED); 161 break; 162 case ARRIVED: 163 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.INPROGRESS); 164 break; 165 case TRIAGED: 166 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.INPROGRESS); 167 break; 168 case INPROGRESS: 169 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.INPROGRESS); 170 break; 171 case ONLEAVE: 172 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.INPROGRESS); 173 break; 174 case FINISHED: 175 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.COMPLETED); 176 break; 177 case CANCELLED: 178 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.CANCELLED); 179 break; 180 case ENTEREDINERROR: 181 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.ENTEREDINERROR); 182 break; 183 case UNKNOWN: 184 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.UNKNOWN); 185 break; 186 default: 187 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EncounterStatus.NULL); 188 break; 189 } 190 return tgt; 191 } 192 193 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Encounter.EncounterStatus> convertEncounterStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EncounterStatus> src) throws FHIRException { 194 if (src == null || src.isEmpty()) 195 return null; 196 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Encounter.EncounterStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Encounter.EncounterStatusEnumFactory()); 197 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 198 switch (src.getValue()) { 199 case PLANNED: 200 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.PLANNED); 201 break; 202 case INPROGRESS: 203 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.INPROGRESS); 204 break; 205 case CANCELLED: 206 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.CANCELLED); 207 break; 208 case COMPLETED: 209 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED); 210 break; 211 case ENTEREDINERROR: 212 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.ENTEREDINERROR); 213 break; 214 case UNKNOWN: 215 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN); 216 break; 217 default: 218 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterStatus.NULL); 219 break; 220 } 221 return tgt; 222 } 223 224// public static org.hl7.fhir.r5.model.Encounter.StatusHistoryComponent convertStatusHistoryComponent(org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent src) throws FHIRException { 225// if (src == null) 226// return null; 227// org.hl7.fhir.r5.model.Encounter.StatusHistoryComponent tgt = new org.hl7.fhir.r5.model.Encounter.StatusHistoryComponent(); 228// ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 229// if (src.hasStatus()) 230// tgt.setStatusElement(convertEncounterStatus(src.getStatusElement())); 231// if (src.hasPeriod()) 232// tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 233// return tgt; 234// } 235// 236// public static org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent convertStatusHistoryComponent(org.hl7.fhir.r5.model.Encounter.StatusHistoryComponent src) throws FHIRException { 237// if (src == null) 238// return null; 239// org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent tgt = new org.hl7.fhir.r4.model.Encounter.StatusHistoryComponent(); 240// ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 241// if (src.hasStatus()) 242// tgt.setStatusElement(convertEncounterStatus(src.getStatusElement())); 243// if (src.hasPeriod()) 244// tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 245// return tgt; 246// } 247// 248// public static org.hl7.fhir.r5.model.Encounter.ClassHistoryComponent convertClassHistoryComponent(org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent src) throws FHIRException { 249// if (src == null) 250// return null; 251// org.hl7.fhir.r5.model.Encounter.ClassHistoryComponent tgt = new org.hl7.fhir.r5.model.Encounter.ClassHistoryComponent(); 252// ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 253// if (src.hasClass_()) 254// tgt.setClass_(Coding40_50.convertCoding(src.getClass_())); 255// if (src.hasPeriod()) 256// tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 257// return tgt; 258// } 259// 260// public static org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent convertClassHistoryComponent(org.hl7.fhir.r5.model.Encounter.ClassHistoryComponent src) throws FHIRException { 261// if (src == null) 262// return null; 263// org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent tgt = new org.hl7.fhir.r4.model.Encounter.ClassHistoryComponent(); 264// ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 265// if (src.hasClass_()) 266// tgt.setClass_(Coding40_50.convertCoding(src.getClass_())); 267// if (src.hasPeriod()) 268// tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 269// return tgt; 270// } 271 272 public static org.hl7.fhir.r5.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent src) throws FHIRException { 273 if (src == null) 274 return null; 275 org.hl7.fhir.r5.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.r5.model.Encounter.EncounterParticipantComponent(); 276 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 277 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) 278 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 279 if (src.hasPeriod()) 280 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 281 if (src.hasIndividual()) 282 tgt.setActor(Reference40_50.convertReference(src.getIndividual())); 283 return tgt; 284 } 285 286 public static org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent convertEncounterParticipantComponent(org.hl7.fhir.r5.model.Encounter.EncounterParticipantComponent src) throws FHIRException { 287 if (src == null) 288 return null; 289 org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent(); 290 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 291 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 292 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 293 if (src.hasPeriod()) 294 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 295 if (src.hasActor()) 296 tgt.setIndividual(Reference40_50.convertReference(src.getActor())); 297 return tgt; 298 } 299 300 public static org.hl7.fhir.r5.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4.model.Encounter.DiagnosisComponent src) throws FHIRException { 301 if (src == null) 302 return null; 303 org.hl7.fhir.r5.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.Encounter.DiagnosisComponent(); 304 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 305 if (src.hasCondition()) 306 tgt.addCondition(Reference40_50.convertReferenceToCodeableReference(src.getCondition())); 307 if (src.hasUse()) 308 tgt.addUse(CodeableConcept40_50.convertCodeableConcept(src.getUse())); 309// if (src.hasRank()) 310// tgt.setRankElement(PositiveInt40_50.convertPositiveInt(src.getRankElement())); 311 return tgt; 312 } 313 314 public static org.hl7.fhir.r4.model.Encounter.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.Encounter.DiagnosisComponent src) throws FHIRException { 315 if (src == null) 316 return null; 317 org.hl7.fhir.r4.model.Encounter.DiagnosisComponent tgt = new org.hl7.fhir.r4.model.Encounter.DiagnosisComponent(); 318 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 319 if (src.hasCondition() && src.getConditionFirstRep().hasReference()) 320 tgt.setCondition(Reference40_50.convertReference(src.getConditionFirstRep().getReference())); 321 if (src.hasUse()) 322 tgt.setUse(CodeableConcept40_50.convertCodeableConcept(src.getUseFirstRep())); 323// if (src.hasRank()) 324// tgt.setRankElement(PositiveInt40_50.convertPositiveInt(src.getRankElement())); 325 return tgt; 326 } 327 328 public static org.hl7.fhir.r5.model.Encounter.EncounterAdmissionComponent convertEncounterHospitalizationComponent(org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent src, org.hl7.fhir.r5.model.Encounter tgte) throws FHIRException { 329 if (src == null) 330 return null; 331 org.hl7.fhir.r5.model.Encounter.EncounterAdmissionComponent tgt = new org.hl7.fhir.r5.model.Encounter.EncounterAdmissionComponent(); 332 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 333 if (src.hasPreAdmissionIdentifier()) 334 tgt.setPreAdmissionIdentifier(Identifier40_50.convertIdentifier(src.getPreAdmissionIdentifier())); 335 if (src.hasOrigin()) 336 tgt.setOrigin(Reference40_50.convertReference(src.getOrigin())); 337 if (src.hasAdmitSource()) 338 tgt.setAdmitSource(CodeableConcept40_50.convertCodeableConcept(src.getAdmitSource())); 339 if (src.hasReAdmission()) 340 tgt.setReAdmission(CodeableConcept40_50.convertCodeableConcept(src.getReAdmission())); 341 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getDietPreference()) 342 tgte.addDietPreference(CodeableConcept40_50.convertCodeableConcept(t)); 343 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialCourtesy()) 344 tgte.addSpecialCourtesy(CodeableConcept40_50.convertCodeableConcept(t)); 345 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialArrangement()) 346 tgte.addSpecialArrangement(CodeableConcept40_50.convertCodeableConcept(t)); 347 if (src.hasDestination()) 348 tgt.setDestination(Reference40_50.convertReference(src.getDestination())); 349 if (src.hasDischargeDisposition()) 350 tgt.setDischargeDisposition(CodeableConcept40_50.convertCodeableConcept(src.getDischargeDisposition())); 351 return tgt; 352 } 353 354 public static org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent convertEncounterHospitalizationComponent(org.hl7.fhir.r5.model.Encounter.EncounterAdmissionComponent src, org.hl7.fhir.r5.model.Encounter srce) throws FHIRException { 355 if (src == null) 356 return null; 357 org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent(); 358 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 359 if (src.hasPreAdmissionIdentifier()) 360 tgt.setPreAdmissionIdentifier(Identifier40_50.convertIdentifier(src.getPreAdmissionIdentifier())); 361 if (src.hasOrigin()) 362 tgt.setOrigin(Reference40_50.convertReference(src.getOrigin())); 363 if (src.hasAdmitSource()) 364 tgt.setAdmitSource(CodeableConcept40_50.convertCodeableConcept(src.getAdmitSource())); 365 if (src.hasReAdmission()) 366 tgt.setReAdmission(CodeableConcept40_50.convertCodeableConcept(src.getReAdmission())); 367 for (org.hl7.fhir.r5.model.CodeableConcept t : srce.getDietPreference()) 368 tgt.addDietPreference(CodeableConcept40_50.convertCodeableConcept(t)); 369 for (org.hl7.fhir.r5.model.CodeableConcept t : srce.getSpecialCourtesy()) 370 tgt.addSpecialCourtesy(CodeableConcept40_50.convertCodeableConcept(t)); 371 for (org.hl7.fhir.r5.model.CodeableConcept t : srce.getSpecialArrangement()) 372 tgt.addSpecialArrangement(CodeableConcept40_50.convertCodeableConcept(t)); 373 if (src.hasDestination()) 374 tgt.setDestination(Reference40_50.convertReference(src.getDestination())); 375 if (src.hasDischargeDisposition()) 376 tgt.setDischargeDisposition(CodeableConcept40_50.convertCodeableConcept(src.getDischargeDisposition())); 377 return tgt; 378 } 379 380 public static org.hl7.fhir.r5.model.Encounter.EncounterLocationComponent convertEncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent src) throws FHIRException { 381 if (src == null) 382 return null; 383 org.hl7.fhir.r5.model.Encounter.EncounterLocationComponent tgt = new org.hl7.fhir.r5.model.Encounter.EncounterLocationComponent(); 384 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 385 if (src.hasLocation()) 386 tgt.setLocation(Reference40_50.convertReference(src.getLocation())); 387 if (src.hasStatus()) 388 tgt.setStatusElement(convertEncounterLocationStatus(src.getStatusElement())); 389 if (src.hasPhysicalType()) 390 tgt.setForm(CodeableConcept40_50.convertCodeableConcept(src.getPhysicalType())); 391 if (src.hasPeriod()) 392 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 393 return tgt; 394 } 395 396 public static org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent convertEncounterLocationComponent(org.hl7.fhir.r5.model.Encounter.EncounterLocationComponent src) throws FHIRException { 397 if (src == null) 398 return null; 399 org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent tgt = new org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent(); 400 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 401 if (src.hasLocation()) 402 tgt.setLocation(Reference40_50.convertReference(src.getLocation())); 403 if (src.hasStatus()) 404 tgt.setStatusElement(convertEncounterLocationStatus(src.getStatusElement())); 405 if (src.hasForm()) 406 tgt.setPhysicalType(CodeableConcept40_50.convertCodeableConcept(src.getForm())); 407 if (src.hasPeriod()) 408 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 409 return tgt; 410 } 411 412 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus> convertEncounterLocationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus> src) throws FHIRException { 413 if (src == null || src.isEmpty()) 414 return null; 415 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Encounter.EncounterLocationStatusEnumFactory()); 416 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 417 switch (src.getValue()) { 418 case PLANNED: 419 tgt.setValue(org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus.PLANNED); 420 break; 421 case ACTIVE: 422 tgt.setValue(org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus.ACTIVE); 423 break; 424 case RESERVED: 425 tgt.setValue(org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus.RESERVED); 426 break; 427 case COMPLETED: 428 tgt.setValue(org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus.COMPLETED); 429 break; 430 default: 431 tgt.setValue(org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus.NULL); 432 break; 433 } 434 return tgt; 435 } 436 437 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus> convertEncounterLocationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Encounter.EncounterLocationStatus> src) throws FHIRException { 438 if (src == null || src.isEmpty()) 439 return null; 440 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Encounter.EncounterLocationStatusEnumFactory()); 441 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 442 switch (src.getValue()) { 443 case PLANNED: 444 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.PLANNED); 445 break; 446 case ACTIVE: 447 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.ACTIVE); 448 break; 449 case RESERVED: 450 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.RESERVED); 451 break; 452 case COMPLETED: 453 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.COMPLETED); 454 break; 455 default: 456 tgt.setValue(org.hl7.fhir.r4.model.Encounter.EncounterLocationStatus.NULL); 457 break; 458 } 459 return tgt; 460 } 461}