001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Instant30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
009import org.hl7.fhir.exceptions.FHIRException;
010
011public class AppointmentResponse30_50 {
012
013  public static org.hl7.fhir.r5.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.dstu3.model.AppointmentResponse src) throws FHIRException {
014    if (src == null)
015      return null;
016    org.hl7.fhir.r5.model.AppointmentResponse tgt = new org.hl7.fhir.r5.model.AppointmentResponse();
017    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
018    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
019      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
020    if (src.hasAppointment())
021      tgt.setAppointment(Reference30_50.convertReference(src.getAppointment()));
022    if (src.hasStart())
023      tgt.setStartElement(Instant30_50.convertInstant(src.getStartElement()));
024    if (src.hasEnd())
025      tgt.setEndElement(Instant30_50.convertInstant(src.getEndElement()));
026    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getParticipantType())
027      tgt.addParticipantType(CodeableConcept30_50.convertCodeableConcept(t));
028    if (src.hasActor())
029      tgt.setActor(Reference30_50.convertReference(src.getActor()));
030    if (src.hasParticipantStatus())
031      tgt.setParticipantStatusElement(convertParticipantStatus(src.getParticipantStatusElement()));
032    if (src.hasComment())
033      tgt.setCommentElement(String30_50.convertStringToMarkdown(src.getCommentElement()));
034    return tgt;
035  }
036
037  public static org.hl7.fhir.dstu3.model.AppointmentResponse convertAppointmentResponse(org.hl7.fhir.r5.model.AppointmentResponse src) throws FHIRException {
038    if (src == null)
039      return null;
040    org.hl7.fhir.dstu3.model.AppointmentResponse tgt = new org.hl7.fhir.dstu3.model.AppointmentResponse();
041    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
042    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
043      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
044    if (src.hasAppointment())
045      tgt.setAppointment(Reference30_50.convertReference(src.getAppointment()));
046    if (src.hasStart())
047      tgt.setStartElement(Instant30_50.convertInstant(src.getStartElement()));
048    if (src.hasEnd())
049      tgt.setEndElement(Instant30_50.convertInstant(src.getEndElement()));
050    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getParticipantType())
051      tgt.addParticipantType(CodeableConcept30_50.convertCodeableConcept(t));
052    if (src.hasActor())
053      tgt.setActor(Reference30_50.convertReference(src.getActor()));
054    if (src.hasParticipantStatus())
055      tgt.setParticipantStatusElement(convertParticipantStatus(src.getParticipantStatusElement()));
056    if (src.hasComment())
057      tgt.setCommentElement(String30_50.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.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.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    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().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 NEEDSACTION:
077        tgt.setValue(org.hl7.fhir.dstu3.model.AppointmentResponse.ParticipantStatus.NEEDSACTION);
078        break;
079      default:
080        tgt.setValue(org.hl7.fhir.dstu3.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.dstu3.model.Enumeration<org.hl7.fhir.dstu3.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    ConversionContext30_50.INSTANCE.getVersionConvertor_30_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 NEEDSACTION:
102        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.NEEDSACTION);
103        break;
104      default:
105        tgt.setValue(org.hl7.fhir.r5.model.AppointmentResponse.AppointmentResponseStatus.NULL);
106        break;
107    }
108    return tgt;
109  }
110}