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