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