001package org.hl7.fhir.convertors.conv10_50;
002
003import org.hl7.fhir.convertors.VersionConvertor_10_50;
004import org.hl7.fhir.exceptions.FHIRException;
005
006public class AppointmentResponse10_50 {
007
008    public static org.hl7.fhir.dstu2.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.r5.model.AppointmentResponse src) throws FHIRException {
009        if (src == null || src.isEmpty())
010            return null;
011        org.hl7.fhir.dstu2.model.AppointmentResponse tgt = new org.hl7.fhir.dstu2.model.AppointmentResponse();
012        VersionConvertor_10_50.copyDomainResource(src, tgt);
013        for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_50.convertIdentifier(t));
014        if (src.hasAppointment())
015            tgt.setAppointment(VersionConvertor_10_50.convertReference(src.getAppointment()));
016        if (src.hasStartElement())
017            tgt.setStartElement(VersionConvertor_10_50.convertInstant(src.getStartElement()));
018        if (src.hasEndElement())
019            tgt.setEndElement(VersionConvertor_10_50.convertInstant(src.getEndElement()));
020        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getParticipantType()) tgt.addParticipantType(VersionConvertor_10_50.convertCodeableConcept(t));
021        if (src.hasActor())
022            tgt.setActor(VersionConvertor_10_50.convertReference(src.getActor()));
023        if (src.hasParticipantStatus())
024            tgt.setParticipantStatusElement(convertParticipantStatus(src.getParticipantStatusElement()));
025        if (src.hasCommentElement())
026            tgt.setCommentElement(VersionConvertor_10_50.convertString(src.getCommentElement()));
027        return tgt;
028    }
029
030    public static org.hl7.fhir.r5.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.dstu2.model.AppointmentResponse src) throws FHIRException {
031        if (src == null || src.isEmpty())
032            return null;
033        org.hl7.fhir.r5.model.AppointmentResponse tgt = new org.hl7.fhir.r5.model.AppointmentResponse();
034        VersionConvertor_10_50.copyDomainResource(src, tgt);
035        for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_50.convertIdentifier(t));
036        if (src.hasAppointment())
037            tgt.setAppointment(VersionConvertor_10_50.convertReference(src.getAppointment()));
038        if (src.hasStartElement())
039            tgt.setStartElement(VersionConvertor_10_50.convertInstant(src.getStartElement()));
040        if (src.hasEndElement())
041            tgt.setEndElement(VersionConvertor_10_50.convertInstant(src.getEndElement()));
042        for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getParticipantType()) tgt.addParticipantType(VersionConvertor_10_50.convertCodeableConcept(t));
043        if (src.hasActor())
044            tgt.setActor(VersionConvertor_10_50.convertReference(src.getActor()));
045        if (src.hasParticipantStatus())
046            tgt.setParticipantStatusElement(convertParticipantStatus(src.getParticipantStatusElement()));
047        if (src.hasCommentElement())
048            tgt.setCommentElement(VersionConvertor_10_50.convertString(src.getCommentElement()));
049        return tgt;
050    }
051
052    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus> convertParticipantStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ParticipationStatus> src) throws FHIRException {
053        if (src == null || src.isEmpty())
054            return null;
055        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatusEnumFactory());
056        VersionConvertor_10_50.copyElement(src, tgt);
057        switch(src.getValue()) {
058            case ACCEPTED:
059                tgt.setValue(org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus.ACCEPTED);
060                break;
061            case DECLINED:
062                tgt.setValue(org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus.DECLINED);
063                break;
064            case TENTATIVE:
065                tgt.setValue(org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus.TENTATIVE);
066                break;
067            case NEEDSACTION:
068                tgt.setValue(org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus.NEEDSACTION);
069                break;
070            default:
071                tgt.setValue(org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus.NULL);
072                break;
073        }
074        return tgt;
075    }
076
077    static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ParticipationStatus> convertParticipantStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AppointmentResponse.ParticipantStatus> src) throws FHIRException {
078        if (src == null || src.isEmpty())
079            return null;
080        org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ParticipationStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.ParticipationStatusEnumFactory());
081        VersionConvertor_10_50.copyElement(src, tgt);
082        switch(src.getValue()) {
083            case ACCEPTED:
084                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.ACCEPTED);
085                break;
086            case DECLINED:
087                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.DECLINED);
088                break;
089            case TENTATIVE:
090                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.TENTATIVE);
091                break;
092            case INPROCESS:
093                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.ACCEPTED);
094                break;
095            case COMPLETED:
096                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.ACCEPTED);
097                break;
098            case NEEDSACTION:
099                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.NEEDSACTION);
100                break;
101            default:
102                tgt.setValue(org.hl7.fhir.r5.model.Enumerations.ParticipationStatus.NULL);
103                break;
104        }
105        return tgt;
106    }
107}