001package org.hl7.fhir.convertors.conv10_50.resources10_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_50;
004import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Reference10_50;
005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.CodeableConcept10_50;
006import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Identifier10_50;
007import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Instant10_50;
008import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.String10_50;
009import org.hl7.fhir.exceptions.FHIRException;
010
011public class AppointmentResponse10_50 {
012
013  public static org.hl7.fhir.dstu2.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.r5.model.AppointmentResponse src) throws FHIRException {
014    if (src == null || src.isEmpty())
015      return null;
016    org.hl7.fhir.dstu2.model.AppointmentResponse tgt = new org.hl7.fhir.dstu2.model.AppointmentResponse();
017    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
018    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
019      tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
020    if (src.hasAppointment())
021      tgt.setAppointment(Reference10_50.convertReference(src.getAppointment()));
022    if (src.hasStartElement())
023      tgt.setStartElement(Instant10_50.convertInstant(src.getStartElement()));
024    if (src.hasEndElement())
025      tgt.setEndElement(Instant10_50.convertInstant(src.getEndElement()));
026    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getParticipantType())
027      tgt.addParticipantType(CodeableConcept10_50.convertCodeableConcept(t));
028    if (src.hasActor())
029      tgt.setActor(Reference10_50.convertReference(src.getActor()));
030    if (src.hasParticipantStatus())
031      tgt.setParticipantStatusElement(convertParticipantStatus(src.getParticipantStatusElement()));
032    if (src.hasCommentElement())
033      tgt.setCommentElement(String10_50.convertString(src.getCommentElement()));
034    return tgt;
035  }
036
037  public static org.hl7.fhir.r5.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.dstu2.model.AppointmentResponse src) throws FHIRException {
038    if (src == null || src.isEmpty())
039      return null;
040    org.hl7.fhir.r5.model.AppointmentResponse tgt = new org.hl7.fhir.r5.model.AppointmentResponse();
041    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
042    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
043      tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
044    if (src.hasAppointment())
045      tgt.setAppointment(Reference10_50.convertReference(src.getAppointment()));
046    if (src.hasStartElement())
047      tgt.setStartElement(Instant10_50.convertInstant(src.getStartElement()));
048    if (src.hasEndElement())
049      tgt.setEndElement(Instant10_50.convertInstant(src.getEndElement()));
050    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getParticipantType())
051      tgt.addParticipantType(CodeableConcept10_50.convertCodeableConcept(t));
052    if (src.hasActor())
053      tgt.setActor(Reference10_50.convertReference(src.getActor()));
054    if (src.hasParticipantStatus())
055      tgt.setParticipantStatusElement(convertParticipantStatus(src.getParticipantStatusElement()));
056    if (src.hasCommentElement())
057      tgt.setCommentElement(String10_50.convertStringToMarkdown(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.r5.model.Enumeration<org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus> 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_50.INSTANCE.getVersionConvertor_10_50().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.r5.model.Enumeration<org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus> 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.r5.model.Enumeration<org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatusEnumFactory());
090    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
091    switch (src.getValue()) {
092      case ACCEPTED:
093        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.ACCEPTED);
094        break;
095      case DECLINED:
096        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.DECLINED);
097        break;
098      case TENTATIVE:
099        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.TENTATIVE);
100        break;
101      case INPROCESS:
102        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.ACCEPTED);
103        break;
104      case COMPLETED:
105        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.ACCEPTED);
106        break;
107      case NEEDSACTION:
108        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.NEEDSACTION);
109        break;
110      default:
111        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.NULL);
112        break;
113    }
114    return tgt;
115  }
116}