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.Period40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Instant40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.PositiveInt40_50; 011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 013import org.hl7.fhir.exceptions.FHIRException; 014import org.hl7.fhir.r4.model.UnsignedIntType; 015import org.hl7.fhir.r5.model.CodeableConcept; 016import org.hl7.fhir.r5.model.CodeableReference; 017 018/* 019 Copyright (c) 2011+, HL7, Inc. 020 All rights reserved. 021 022 Redistribution and use in source and binary forms, with or without modification, 023 are permitted provided that the following conditions are met: 024 025 * Redistributions of source code must retain the above copyright notice, this 026 list of conditions and the following disclaimer. 027 * Redistributions in binary form must reproduce the above copyright notice, 028 this list of conditions and the following disclaimer in the documentation 029 and/or other materials provided with the distribution. 030 * Neither the name of HL7 nor the names of its contributors may be used to 031 endorse or promote products derived from this software without specific 032 prior written permission. 033 034 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 035 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 036 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 037 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 038 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 039 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 040 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 041 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 042 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 043 POSSIBILITY OF SUCH DAMAGE. 044 045*/ 046// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 047public class Appointment40_50 { 048 049 public static org.hl7.fhir.r5.model.Appointment convertAppointment(org.hl7.fhir.r4.model.Appointment src) throws FHIRException { 050 if (src == null) 051 return null; 052 org.hl7.fhir.r5.model.Appointment tgt = new org.hl7.fhir.r5.model.Appointment(); 053 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 054 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 055 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 056 if (src.hasStatus()) 057 tgt.setStatusElement(convertAppointmentStatus(src.getStatusElement())); 058 if (src.hasCancelationReason()) 059 tgt.setCancellationReason(CodeableConcept40_50.convertCodeableConcept(src.getCancelationReason())); 060 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceCategory()) 061 tgt.addServiceCategory(CodeableConcept40_50.convertCodeableConcept(t)); 062 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType()) 063 tgt.addServiceType().setConcept(CodeableConcept40_50.convertCodeableConcept(t)); 064 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty()) 065 tgt.addSpecialty(CodeableConcept40_50.convertCodeableConcept(t)); 066 if (src.hasAppointmentType()) 067 tgt.setAppointmentType(CodeableConcept40_50.convertCodeableConcept(src.getAppointmentType())); 068 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) 069 tgt.addReason(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t)); 070 for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference()) 071 tgt.addReason(Reference40_50.convertReferenceToCodeableReference(t)); 072 if (src.hasPriority()) 073 tgt.setPriority(convertAppointmentPriority(src.getPriorityElement())); 074 if (src.hasDescription()) 075 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 076 for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInformation()) 077 tgt.addSupportingInformation(Reference40_50.convertReference(t)); 078 if (src.hasStart()) 079 tgt.setStartElement(Instant40_50.convertInstant(src.getStartElement())); 080 if (src.hasEnd()) 081 tgt.setEndElement(Instant40_50.convertInstant(src.getEndElement())); 082 if (src.hasMinutesDuration()) 083 tgt.setMinutesDurationElement(PositiveInt40_50.convertPositiveInt(src.getMinutesDurationElement())); 084 for (org.hl7.fhir.r4.model.Reference t : src.getSlot()) tgt.addSlot(Reference40_50.convertReference(t)); 085 if (src.hasCreated()) 086 tgt.setCreatedElement(DateTime40_50.convertDateTime(src.getCreatedElement())); 087 if (src.hasComment()) 088 tgt.getNoteFirstRep().setTextElement(MarkDown40_50.convertStringToMarkdown(src.getCommentElement())); 089// if (src.hasPatientInstruction()) 090// tgt.setPatientInstructionElement(String40_50.convertString(src.getPatientInstructionElement())); 091 for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 092 for (org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent t : src.getParticipant()) 093 tgt.addParticipant(convertAppointmentParticipantComponent(t)); 094 for (org.hl7.fhir.r4.model.Period t : src.getRequestedPeriod()) 095 tgt.addRequestedPeriod(Period40_50.convertPeriod(t)); 096 return tgt; 097 } 098 099 public static org.hl7.fhir.r4.model.Appointment convertAppointment(org.hl7.fhir.r5.model.Appointment src) throws FHIRException { 100 if (src == null) 101 return null; 102 org.hl7.fhir.r4.model.Appointment tgt = new org.hl7.fhir.r4.model.Appointment(); 103 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 104 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 105 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 106 if (src.hasStatus()) 107 tgt.setStatusElement(convertAppointmentStatus(src.getStatusElement())); 108 if (src.hasCancellationReason()) 109 tgt.setCancelationReason(CodeableConcept40_50.convertCodeableConcept(src.getCancellationReason())); 110 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getServiceCategory()) 111 tgt.addServiceCategory(CodeableConcept40_50.convertCodeableConcept(t)); 112 for (org.hl7.fhir.r5.model.CodeableReference t : src.getServiceType()) 113 tgt.addServiceType(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 114 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty()) 115 tgt.addSpecialty(CodeableConcept40_50.convertCodeableConcept(t)); 116 if (src.hasAppointmentType()) 117 tgt.setAppointmentType(CodeableConcept40_50.convertCodeableConcept(src.getAppointmentType())); 118 for (CodeableReference t : src.getReason()) 119 if (t.hasConcept()) 120 tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 121 for (CodeableReference t : src.getReason()) 122 if (t.hasReference()) 123 tgt.addReasonReference(Reference40_50.convertReference(t.getReference())); 124 if (src.hasPriority()) 125 tgt.setPriorityElement(convertAppointmentPriority(src.getPriority())); 126 if (src.hasDescription()) 127 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 128 for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInformation()) 129 tgt.addSupportingInformation(Reference40_50.convertReference(t)); 130 if (src.hasStart()) 131 tgt.setStartElement(Instant40_50.convertInstant(src.getStartElement())); 132 if (src.hasEnd()) 133 tgt.setEndElement(Instant40_50.convertInstant(src.getEndElement())); 134 if (src.hasMinutesDuration()) 135 tgt.setMinutesDurationElement(PositiveInt40_50.convertPositiveInt(src.getMinutesDurationElement())); 136 for (org.hl7.fhir.r5.model.Reference t : src.getSlot()) tgt.addSlot(Reference40_50.convertReference(t)); 137 if (src.hasCreated()) 138 tgt.setCreatedElement(DateTime40_50.convertDateTime(src.getCreatedElement())); 139 if (src.hasNote()) 140 tgt.setCommentElement(String40_50.convertString(src.getNoteFirstRep().getTextElement())); 141// if (src.hasPatientInstruction()) 142// tgt.setPatientInstructionElement(String40_50.convertString(src.getPatientInstructionElement())); 143 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 144 for (org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent t : src.getParticipant()) 145 tgt.addParticipant(convertAppointmentParticipantComponent(t)); 146 for (org.hl7.fhir.r5.model.Period t : src.getRequestedPeriod()) 147 tgt.addRequestedPeriod(Period40_50.convertPeriod(t)); 148 return tgt; 149 } 150 151 152 private static UnsignedIntType convertAppointmentPriority(CodeableConcept src) { 153 UnsignedIntType tgt = new UnsignedIntType(convertAppointmentPriorityFromR5(src)); 154 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 155 return tgt; 156 } 157 158 private static CodeableConcept convertAppointmentPriority(UnsignedIntType src) { 159 CodeableConcept tgt = src.hasValue() ? convertAppointmentPriorityToR5(src.getValue()) : new CodeableConcept(); 160 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 161 return tgt; 162 } 163 164 public static org.hl7.fhir.r5.model.CodeableConcept convertAppointmentPriorityToR5(int priority) { 165 return null; 166 } 167 168 public static int convertAppointmentPriorityFromR5(org.hl7.fhir.r5.model.CodeableConcept priority) { 169 return 0; 170 } 171 172 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.AppointmentStatus> convertAppointmentStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.AppointmentStatus> src) throws FHIRException { 173 if (src == null || src.isEmpty()) 174 return null; 175 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.AppointmentStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Appointment.AppointmentStatusEnumFactory()); 176 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 177 switch (src.getValue()) { 178 case PROPOSED: 179 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.PROPOSED); 180 break; 181 case PENDING: 182 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.PENDING); 183 break; 184 case BOOKED: 185 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.BOOKED); 186 break; 187 case ARRIVED: 188 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.ARRIVED); 189 break; 190 case FULFILLED: 191 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.FULFILLED); 192 break; 193 case CANCELLED: 194 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.CANCELLED); 195 break; 196 case NOSHOW: 197 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.NOSHOW); 198 break; 199 case ENTEREDINERROR: 200 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.ENTEREDINERROR); 201 break; 202 case CHECKEDIN: 203 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.CHECKEDIN); 204 break; 205 case WAITLIST: 206 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.WAITLIST); 207 break; 208 default: 209 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.NULL); 210 break; 211 } 212 return tgt; 213 } 214 215 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.AppointmentStatus> convertAppointmentStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.AppointmentStatus> src) throws FHIRException { 216 if (src == null || src.isEmpty()) 217 return null; 218 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.AppointmentStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Appointment.AppointmentStatusEnumFactory()); 219 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 220 switch (src.getValue()) { 221 case PROPOSED: 222 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.PROPOSED); 223 break; 224 case PENDING: 225 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.PENDING); 226 break; 227 case BOOKED: 228 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.BOOKED); 229 break; 230 case ARRIVED: 231 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.ARRIVED); 232 break; 233 case FULFILLED: 234 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.FULFILLED); 235 break; 236 case CANCELLED: 237 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.CANCELLED); 238 break; 239 case NOSHOW: 240 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.NOSHOW); 241 break; 242 case ENTEREDINERROR: 243 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.ENTEREDINERROR); 244 break; 245 case CHECKEDIN: 246 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.CHECKEDIN); 247 break; 248 case WAITLIST: 249 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.WAITLIST); 250 break; 251 default: 252 tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.NULL); 253 break; 254 } 255 return tgt; 256 } 257 258 public static org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { 259 if (src == null) 260 return null; 261 org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent(); 262 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 263 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) 264 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 265 if (src.hasActor()) 266 tgt.setActor(Reference40_50.convertReference(src.getActor())); 267 if (src.hasRequired()) 268 tgt.setRequiredElement(convertParticipantRequired(src.getRequiredElement())); 269 if (src.hasStatus()) 270 tgt.setStatusElement(convertParticipationStatus(src.getStatusElement())); 271 if (src.hasPeriod()) 272 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 273 return tgt; 274 } 275 276 public static org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { 277 if (src == null) 278 return null; 279 org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent(); 280 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 281 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 282 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 283 if (src.hasActor()) 284 tgt.setActor(Reference40_50.convertReference(src.getActor())); 285 if (src.hasRequired()) 286 tgt.setRequiredElement(convertParticipantRequired(src.getRequiredElement())); 287 if (src.hasStatus()) 288 tgt.setStatusElement(convertParticipationStatus(src.getStatusElement())); 289 if (src.hasPeriod()) 290 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 291 return tgt; 292 } 293 294 static public org.hl7.fhir.r5.model.BooleanType convertParticipantRequired(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipantRequired> src) throws FHIRException { 295 if (src == null || src.isEmpty()) 296 return null; 297 org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(); 298 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 299 switch (src.getValue()) { 300 case REQUIRED: 301 tgt.setValue(true); 302 break; 303 case OPTIONAL: 304 tgt.setValue(false); 305 break; 306 case INFORMATIONONLY: 307 tgt.setValue(false); 308 break; 309 default: 310 break; 311 } 312 return tgt; 313 } 314 315 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipantRequired> convertParticipantRequired(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { 316 if (src == null || src.isEmpty()) 317 return null; 318 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipantRequired> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Appointment.ParticipantRequiredEnumFactory()); 319 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 320 if (src.getValue()) { // case REQUIRED: 321 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipantRequired.REQUIRED); 322 } else { // case OPTIONAL + others: 323 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipantRequired.OPTIONAL); 324 } 325 return tgt; 326 } 327 328 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.ParticipationStatus> convertParticipationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipationStatus> src) throws FHIRException { 329 if (src == null || src.isEmpty()) 330 return null; 331 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.ParticipationStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Appointment.ParticipationStatusEnumFactory()); 332 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 333 switch (src.getValue()) { 334 case ACCEPTED: 335 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.ACCEPTED); 336 break; 337 case DECLINED: 338 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.DECLINED); 339 break; 340 case TENTATIVE: 341 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.TENTATIVE); 342 break; 343 case NEEDSACTION: 344 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.NEEDSACTION); 345 break; 346 default: 347 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.NULL); 348 break; 349 } 350 return tgt; 351 } 352 353 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipationStatus> convertParticipationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.ParticipationStatus> src) throws FHIRException { 354 if (src == null || src.isEmpty()) 355 return null; 356 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Appointment.ParticipationStatusEnumFactory()); 357 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 358 switch (src.getValue()) { 359 case ACCEPTED: 360 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.ACCEPTED); 361 break; 362 case DECLINED: 363 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.DECLINED); 364 break; 365 case TENTATIVE: 366 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.TENTATIVE); 367 break; 368 case NEEDSACTION: 369 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NEEDSACTION); 370 break; 371 default: 372 tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NULL); 373 break; 374 } 375 return tgt; 376 } 377}