001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Instant10_40;
008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.PositiveInt10_40;
009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40;
010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.UnsignedInt10_40;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class Appointment10_40 {
014
015  public static org.hl7.fhir.r4.model.Appointment convertAppointment(org.hl7.fhir.dstu2.model.Appointment src) throws FHIRException {
016    if (src == null || src.isEmpty())
017      return null;
018    org.hl7.fhir.r4.model.Appointment tgt = new org.hl7.fhir.r4.model.Appointment();
019    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
020    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
021      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
022    if (src.hasStatus())
023      tgt.setStatusElement(convertAppointmentStatus(src.getStatusElement()));
024    if (src.hasType())
025      tgt.addServiceType(CodeableConcept10_40.convertCodeableConcept(src.getType()));
026    if (src.hasPriorityElement())
027      tgt.setPriorityElement(UnsignedInt10_40.convertUnsignedInt(src.getPriorityElement()));
028    if (src.hasDescriptionElement())
029      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
030    if (src.hasStartElement())
031      tgt.setStartElement(Instant10_40.convertInstant(src.getStartElement()));
032    if (src.hasEndElement())
033      tgt.setEndElement(Instant10_40.convertInstant(src.getEndElement()));
034    if (src.hasMinutesDurationElement())
035      tgt.setMinutesDurationElement(PositiveInt10_40.convertPositiveInt(src.getMinutesDurationElement()));
036    for (org.hl7.fhir.dstu2.model.Reference t : src.getSlot()) tgt.addSlot(Reference10_40.convertReference(t));
037    if (src.hasCommentElement())
038      tgt.setCommentElement(String10_40.convertString(src.getCommentElement()));
039    for (org.hl7.fhir.dstu2.model.Appointment.AppointmentParticipantComponent t : src.getParticipant())
040      tgt.addParticipant(convertAppointmentParticipantComponent(t));
041    return tgt;
042  }
043
044  public static org.hl7.fhir.dstu2.model.Appointment convertAppointment(org.hl7.fhir.r4.model.Appointment src) throws FHIRException {
045    if (src == null || src.isEmpty())
046      return null;
047    org.hl7.fhir.dstu2.model.Appointment tgt = new org.hl7.fhir.dstu2.model.Appointment();
048    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
051    if (src.hasStatus())
052      tgt.setStatusElement(convertAppointmentStatus(src.getStatusElement()));
053    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceType())
054      tgt.setType(CodeableConcept10_40.convertCodeableConcept(t));
055    if (src.hasPriorityElement())
056      tgt.setPriorityElement(UnsignedInt10_40.convertUnsignedInt(src.getPriorityElement()));
057    if (src.hasDescriptionElement())
058      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
059    if (src.hasStartElement())
060      tgt.setStartElement(Instant10_40.convertInstant(src.getStartElement()));
061    if (src.hasEndElement())
062      tgt.setEndElement(Instant10_40.convertInstant(src.getEndElement()));
063    if (src.hasMinutesDurationElement())
064      tgt.setMinutesDurationElement(PositiveInt10_40.convertPositiveInt(src.getMinutesDurationElement()));
065    for (org.hl7.fhir.r4.model.Reference t : src.getSlot()) tgt.addSlot(Reference10_40.convertReference(t));
066    if (src.hasCommentElement())
067      tgt.setCommentElement(String10_40.convertString(src.getCommentElement()));
068    for (org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent t : src.getParticipant())
069      tgt.addParticipant(convertAppointmentParticipantComponent(t));
070    return tgt;
071  }
072
073  public static org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.dstu2.model.Appointment.AppointmentParticipantComponent src) throws FHIRException {
074    if (src == null || src.isEmpty())
075      return null;
076    org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent();
077    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
078    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getType())
079      tgt.addType(CodeableConcept10_40.convertCodeableConcept(t));
080    if (src.hasActor())
081      tgt.setActor(Reference10_40.convertReference(src.getActor()));
082    if (src.hasRequired())
083      tgt.setRequiredElement(convertParticipantRequired(src.getRequiredElement()));
084    if (src.hasStatus())
085      tgt.setStatusElement(convertParticipationStatus(src.getStatusElement()));
086    return tgt;
087  }
088
089  public static org.hl7.fhir.dstu2.model.Appointment.AppointmentParticipantComponent convertAppointmentParticipantComponent(org.hl7.fhir.r4.model.Appointment.AppointmentParticipantComponent src) throws FHIRException {
090    if (src == null || src.isEmpty())
091      return null;
092    org.hl7.fhir.dstu2.model.Appointment.AppointmentParticipantComponent tgt = new org.hl7.fhir.dstu2.model.Appointment.AppointmentParticipantComponent();
093    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
094    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
095      tgt.addType(CodeableConcept10_40.convertCodeableConcept(t));
096    if (src.hasActor())
097      tgt.setActor(Reference10_40.convertReference(src.getActor()));
098    if (src.hasRequired())
099      tgt.setRequiredElement(convertParticipantRequired(src.getRequiredElement()));
100    if (src.hasStatus())
101      tgt.setStatusElement(convertParticipationStatus(src.getStatusElement()));
102    return tgt;
103  }
104
105  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus> convertAppointmentStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.AppointmentStatus> src) throws FHIRException {
106    if (src == null || src.isEmpty())
107      return null;
108    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Appointment.AppointmentStatusEnumFactory());
109    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
110    switch (src.getValue()) {
111      case PROPOSED:
112        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.PROPOSED);
113        break;
114      case PENDING:
115        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.PENDING);
116        break;
117      case BOOKED:
118        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.BOOKED);
119        break;
120      case ARRIVED:
121        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.ARRIVED);
122        break;
123      case FULFILLED:
124        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.FULFILLED);
125        break;
126      case CANCELLED:
127        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.CANCELLED);
128        break;
129      case NOSHOW:
130        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.NOSHOW);
131        break;
132      default:
133        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus.NULL);
134        break;
135    }
136    return tgt;
137  }
138
139  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.AppointmentStatus> convertAppointmentStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.AppointmentStatus> src) throws FHIRException {
140    if (src == null || src.isEmpty())
141      return null;
142    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());
143    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
144    switch (src.getValue()) {
145      case PROPOSED:
146        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.PROPOSED);
147        break;
148      case PENDING:
149        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.PENDING);
150        break;
151      case BOOKED:
152        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.BOOKED);
153        break;
154      case ARRIVED:
155        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.ARRIVED);
156        break;
157      case FULFILLED:
158        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.FULFILLED);
159        break;
160      case CANCELLED:
161        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.CANCELLED);
162        break;
163      case NOSHOW:
164        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.NOSHOW);
165        break;
166      default:
167        tgt.setValue(org.hl7.fhir.r4.model.Appointment.AppointmentStatus.NULL);
168        break;
169    }
170    return tgt;
171  }
172
173  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipantRequired> convertParticipantRequired(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired> src) throws FHIRException {
174    if (src == null || src.isEmpty())
175      return null;
176    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());
177    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
178    switch (src.getValue()) {
179      case REQUIRED:
180        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipantRequired.REQUIRED);
181        break;
182      case OPTIONAL:
183        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipantRequired.OPTIONAL);
184        break;
185      case INFORMATIONONLY:
186        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipantRequired.INFORMATIONONLY);
187        break;
188      default:
189        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipantRequired.NULL);
190        break;
191    }
192    return tgt;
193  }
194
195  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired> convertParticipantRequired(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipantRequired> src) throws FHIRException {
196    if (src == null || src.isEmpty())
197      return null;
198    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Appointment.ParticipantRequiredEnumFactory());
199    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
200    switch (src.getValue()) {
201      case REQUIRED:
202        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired.REQUIRED);
203        break;
204      case OPTIONAL:
205        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired.OPTIONAL);
206        break;
207      case INFORMATIONONLY:
208        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired.INFORMATIONONLY);
209        break;
210      default:
211        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipantRequired.NULL);
212        break;
213    }
214    return tgt;
215  }
216
217  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus> convertParticipationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipationStatus> src) throws FHIRException {
218    if (src == null || src.isEmpty())
219      return null;
220    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Appointment.ParticipationStatusEnumFactory());
221    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
222    switch (src.getValue()) {
223      case ACCEPTED:
224        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus.ACCEPTED);
225        break;
226      case DECLINED:
227        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus.DECLINED);
228        break;
229      case TENTATIVE:
230        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus.TENTATIVE);
231        break;
232      case NEEDSACTION:
233        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus.NEEDSACTION);
234        break;
235      default:
236        tgt.setValue(org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus.NULL);
237        break;
238    }
239    return tgt;
240  }
241
242  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Appointment.ParticipationStatus> convertParticipationStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Appointment.ParticipationStatus> src) throws FHIRException {
243    if (src == null || src.isEmpty())
244      return null;
245    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());
246    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
247    switch (src.getValue()) {
248      case ACCEPTED:
249        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.ACCEPTED);
250        break;
251      case DECLINED:
252        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.DECLINED);
253        break;
254      case TENTATIVE:
255        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.TENTATIVE);
256        break;
257      case NEEDSACTION:
258        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NEEDSACTION);
259        break;
260      default:
261        tgt.setValue(org.hl7.fhir.r4.model.Appointment.ParticipationStatus.NULL);
262        break;
263    }
264    return tgt;
265  }
266}