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