001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Period30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50; 009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Instant30_50; 010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.PositiveInt30_50; 011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 012import org.hl7.fhir.dstu3.model.UnsignedIntType; 013import org.hl7.fhir.exceptions.FHIRException; 014import org.hl7.fhir.r5.model.CodeableConcept; 015import org.hl7.fhir.r5.model.CodeableReference; 016 017public class Appointment30_50 { 018 019 public static org.hl7.fhir.dstu3.model.Appointment convertAppointment(org.hl7.fhir.r5.model.Appointment src) throws FHIRException { 020 if (src == null) 021 return null; 022 org.hl7.fhir.dstu3.model.Appointment tgt = new org.hl7.fhir.dstu3.model.Appointment(); 023 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 024 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 025 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 026 if (src.hasStatus()) 027 tgt.setStatusElement(convertAppointmentStatus(src.getStatusElement())); 028 if (src.hasServiceCategory()) 029 tgt.setServiceCategory(CodeableConcept30_50.convertCodeableConcept(src.getServiceCategoryFirstRep())); 030 for (org.hl7.fhir.r5.model.CodeableReference t : src.getServiceType()) 031 tgt.addServiceType(CodeableConcept30_50.convertCodeableConcept(t.getConcept())); 032 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty()) 033 tgt.addSpecialty(CodeableConcept30_50.convertCodeableConcept(t)); 034 if (src.hasAppointmentType()) 035 tgt.setAppointmentType(CodeableConcept30_50.convertCodeableConcept(src.getAppointmentType())); 036 for (CodeableReference t : src.getReason()) 037 if (t.hasConcept()) 038 tgt.addReason(CodeableConcept30_50.convertCodeableConcept(t.getConcept())); 039 for (CodeableReference t : src.getReason()) 040 if (t.hasReference()) 041 tgt.addIndication(Reference30_50.convertReference(t.getReference())); 042 if (src.hasPriority()) 043 tgt.setPriorityElement(convertAppointmentPriority(src.getPriority())); 044 if (src.hasDescription()) 045 tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement())); 046 for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInformation()) 047 tgt.addSupportingInformation(Reference30_50.convertReference(t)); 048 if (src.hasStart()) 049 tgt.setStartElement(Instant30_50.convertInstant(src.getStartElement())); 050 if (src.hasEnd()) 051 tgt.setEndElement(Instant30_50.convertInstant(src.getEndElement())); 052 if (src.hasMinutesDuration()) 053 tgt.setMinutesDurationElement(PositiveInt30_50.convertPositiveInt(src.getMinutesDurationElement())); 054 for (org.hl7.fhir.r5.model.Reference t : src.getSlot()) tgt.addSlot(Reference30_50.convertReference(t)); 055 if (src.hasCreated()) 056 tgt.setCreatedElement(DateTime30_50.convertDateTime(src.getCreatedElement())); 057 if (src.hasNote()) 058 tgt.setCommentElement(String30_50.convertString(src.getNoteFirstRep().getTextElement())); 059 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) 060 tgt.addIncomingReferral(Reference30_50.convertReference(t)); 061 for (org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent t : src.getParticipant()) 062 tgt.addParticipant(convertAppointmentParticipantComponent(t)); 063 for (org.hl7.fhir.r5.model.Period t : src.getRequestedPeriod()) 064 tgt.addRequestedPeriod(Period30_50.convertPeriod(t)); 065 return tgt; 066 } 067 068 069 private static UnsignedIntType convertAppointmentPriority(CodeableConcept src) { 070 UnsignedIntType tgt = new UnsignedIntType(convertAppointmentPriorityFromR5(src)); 071 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 072 return tgt; 073 } 074 075 private static CodeableConcept convertAppointmentPriority(UnsignedIntType src) { 076 CodeableConcept tgt = src.hasValue() ? convertAppointmentPriorityToR5(src.getValue()) : new CodeableConcept(); 077 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 078 return tgt; 079 } 080 081 public static org.hl7.fhir.r5.model.CodeableConcept convertAppointmentPriorityToR5(int priority) { 082 return null; 083 } 084 085 public static int convertAppointmentPriorityFromR5(org.hl7.fhir.r5.model.CodeableConcept priority) { 086 return 0; 087 } 088 089 public static org.hl7.fhir.r5.model.Appointment convertAppointment(org.hl7.fhir.dstu3.model.Appointment src) throws FHIRException { 090 if (src == null) 091 return null; 092 org.hl7.fhir.r5.model.Appointment tgt = new org.hl7.fhir.r5.model.Appointment(); 093 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 094 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 095 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 096 if (src.hasStatus()) 097 tgt.setStatusElement(convertAppointmentStatus(src.getStatusElement())); 098 if (src.hasServiceCategory()) 099 tgt.addServiceCategory(CodeableConcept30_50.convertCodeableConcept(src.getServiceCategory())); 100 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceType()) 101 tgt.addServiceType().setConcept(CodeableConcept30_50.convertCodeableConcept(t)); 102 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty()) 103 tgt.addSpecialty(CodeableConcept30_50.convertCodeableConcept(t)); 104 if (src.hasAppointmentType()) 105 tgt.setAppointmentType(CodeableConcept30_50.convertCodeableConcept(src.getAppointmentType())); 106 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReason()) 107 tgt.addReason(Reference30_50.convertCodeableConceptToCodableReference(t)); 108 for (org.hl7.fhir.dstu3.model.Reference t : src.getIndication()) 109 tgt.addReason(Reference30_50.convertReferenceToCodableReference(t)); 110 if (src.hasPriority()) 111 tgt.setPriority(convertAppointmentPriority(src.getPriorityElement())); 112 if (src.hasDescription()) 113 tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement())); 114 for (org.hl7.fhir.dstu3.model.Reference t : src.getSupportingInformation()) 115 tgt.addSupportingInformation(Reference30_50.convertReference(t)); 116 if (src.hasStart()) 117 tgt.setStartElement(Instant30_50.convertInstant(src.getStartElement())); 118 if (src.hasEnd()) 119 tgt.setEndElement(Instant30_50.convertInstant(src.getEndElement())); 120 if (src.hasMinutesDuration()) 121 tgt.setMinutesDurationElement(PositiveInt30_50.convertPositiveInt(src.getMinutesDurationElement())); 122 for (org.hl7.fhir.dstu3.model.Reference t : src.getSlot()) tgt.addSlot(Reference30_50.convertReference(t)); 123 if (src.hasCreated()) 124 tgt.setCreatedElement(DateTime30_50.convertDateTime(src.getCreatedElement())); 125 if (src.hasComment()) 126 tgt.getNoteFirstRep().setTextElement(String30_50.convertStringToMarkdown(src.getCommentElement())); 127 for (org.hl7.fhir.dstu3.model.Reference t : src.getIncomingReferral()) 128 tgt.addBasedOn(Reference30_50.convertReference(t)); 129 for (org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent t : src.getParticipant()) 130 tgt.addParticipant(convertAppointmentParticipantComponent(t)); 131 for (org.hl7.fhir.dstu3.model.Period t : src.getRequestedPeriod()) 132 tgt.addRequestedPeriod(Period30_50.convertPeriod(t)); 133 return tgt; 134 } 135 136 public static org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { 137 if (src == null) 138 return null; 139 org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent(); 140 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 141 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 142 tgt.addType(CodeableConcept30_50.convertCodeableConcept(t)); 143 if (src.hasActor()) 144 tgt.setActor(Reference30_50.convertReference(src.getActor())); 145 if (src.hasRequired()) 146 tgt.setRequiredElement(convertParticipantRequired(src.getRequiredElement())); 147 if (src.hasStatus()) 148 tgt.setStatusElement(convertParticipationStatus(src.getStatusElement())); 149 return tgt; 150 } 151 152 public static org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.dstu3.model.Appointment.AppointmentParticipantComponent src) throws FHIRException { 153 if (src == null) 154 return null; 155 org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r5.model.Appointment.AppointmentParticipantComponent(); 156 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 157 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType()) 158 tgt.addType(CodeableConcept30_50.convertCodeableConcept(t)); 159 if (src.hasActor()) 160 tgt.setActor(Reference30_50.convertReference(src.getActor())); 161 if (src.hasRequired()) 162 tgt.setRequiredElement(convertParticipantRequired(src.getRequiredElement())); 163 if (src.hasStatus()) 164 tgt.setStatusElement(convertParticipationStatus(src.getStatusElement())); 165 return tgt; 166 } 167 168 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus> convertAppointmentStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.AppointmentStatus> src) throws FHIRException { 169 if (src == null || src.isEmpty()) 170 return null; 171 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Appointment.AppointmentStatusEnumFactory()); 172 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 173 switch (src.getValue()) { 174 case PROPOSED: 175 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.PROPOSED); 176 break; 177 case PENDING: 178 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.PENDING); 179 break; 180 case BOOKED: 181 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.BOOKED); 182 break; 183 case ARRIVED: 184 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ARRIVED); 185 break; 186 case FULFILLED: 187 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.FULFILLED); 188 break; 189 case CANCELLED: 190 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.CANCELLED); 191 break; 192 case NOSHOW: 193 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.NOSHOW); 194 break; 195 case ENTEREDINERROR: 196 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR); 197 break; 198 default: 199 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.NULL); 200 break; 201 } 202 return tgt; 203 } 204 205 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.AppointmentStatus> convertAppointmentStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus> src) throws FHIRException { 206 if (src == null || src.isEmpty()) 207 return null; 208 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()); 209 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 210 switch (src.getValue()) { 211 case PROPOSED: 212 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.PROPOSED); 213 break; 214 case PENDING: 215 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.PENDING); 216 break; 217 case BOOKED: 218 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.BOOKED); 219 break; 220 case ARRIVED: 221 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.ARRIVED); 222 break; 223 case FULFILLED: 224 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.FULFILLED); 225 break; 226 case CANCELLED: 227 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.CANCELLED); 228 break; 229 case NOSHOW: 230 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.NOSHOW); 231 break; 232 case ENTEREDINERROR: 233 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.ENTEREDINERROR); 234 break; 235 default: 236 tgt.setValue(org.hl7.fhir.r5.model.Appointment.AppointmentStatus.NULL); 237 break; 238 } 239 return tgt; 240 } 241 242 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired> convertParticipantRequired(org.hl7.fhir.r5.model.BooleanType src) throws FHIRException { 243 if (src == null || src.isEmpty()) 244 return null; 245 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Appointment.ParticipantRequiredEnumFactory()); 246 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 247 if (src.getValue()) { // case REQUIRED: 248 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired.REQUIRED); 249 } else { // case OPTIONAL and others: 250 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired.OPTIONAL); 251 } 252 return tgt; 253 } 254 255 static public org.hl7.fhir.r5.model.BooleanType convertParticipantRequired(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.ParticipantRequired> src) throws FHIRException { 256 if (src == null || src.isEmpty()) 257 return null; 258 org.hl7.fhir.r5.model.BooleanType tgt = new org.hl7.fhir.r5.model.BooleanType(); 259 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 260 switch (src.getValue()) { 261 case REQUIRED: 262 tgt.setValue(true); 263 break; 264 case OPTIONAL: 265 tgt.setValue(false); 266 break; 267 case INFORMATIONONLY: 268 tgt.setValue(false); 269 break; 270 default: 271 break; 272 } 273 return tgt; 274 } 275 276 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus> convertParticipationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.ParticipationStatus> src) throws FHIRException { 277 if (src == null || src.isEmpty()) 278 return null; 279 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Appointment.ParticipationStatusEnumFactory()); 280 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 281 switch (src.getValue()) { 282 case ACCEPTED: 283 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.ACCEPTED); 284 break; 285 case DECLINED: 286 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.DECLINED); 287 break; 288 case TENTATIVE: 289 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.TENTATIVE); 290 break; 291 case NEEDSACTION: 292 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.NEEDSACTION); 293 break; 294 default: 295 tgt.setValue(org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus.NULL); 296 break; 297 } 298 return tgt; 299 } 300 301 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Appointment.ParticipationStatus> convertParticipationStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Appointment.ParticipationStatus> src) throws FHIRException { 302 if (src == null || src.isEmpty()) 303 return null; 304 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()); 305 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 306 switch (src.getValue()) { 307 case ACCEPTED: 308 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.ACCEPTED); 309 break; 310 case DECLINED: 311 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.DECLINED); 312 break; 313 case TENTATIVE: 314 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.TENTATIVE); 315 break; 316 case NEEDSACTION: 317 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.NEEDSACTION); 318 break; 319 default: 320 tgt.setValue(org.hl7.fhir.r5.model.Appointment.ParticipationStatus.NULL); 321 break; 322 } 323 return tgt; 324 } 325}