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