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.Boolean30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Instant30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
010import org.hl7.fhir.exceptions.FHIRException;
011
012public class Slot30_50 {
013
014  public static org.hl7.fhir.r5.model.Slot convertSlot(org.hl7.fhir.dstu3.model.Slot src) throws FHIRException {
015    if (src == null)
016      return null;
017    org.hl7.fhir.r5.model.Slot tgt = new org.hl7.fhir.r5.model.Slot();
018    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
019    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
020      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
021    if (src.hasServiceCategory())
022      tgt.addServiceCategory(CodeableConcept30_50.convertCodeableConcept(src.getServiceCategory()));
023    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceType())
024      tgt.addServiceType(CodeableConcept30_50.convertCodeableConcept(t));
025    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
026      tgt.addSpecialty(CodeableConcept30_50.convertCodeableConcept(t));
027    if (src.hasAppointmentType())
028      tgt.addAppointmentType(CodeableConcept30_50.convertCodeableConcept(src.getAppointmentType()));
029    if (src.hasSchedule())
030      tgt.setSchedule(Reference30_50.convertReference(src.getSchedule()));
031    if (src.hasStatus())
032      tgt.setStatusElement(convertSlotStatus(src.getStatusElement()));
033    if (src.hasStart())
034      tgt.setStartElement(Instant30_50.convertInstant(src.getStartElement()));
035    if (src.hasEnd())
036      tgt.setEndElement(Instant30_50.convertInstant(src.getEndElement()));
037    if (src.hasOverbooked())
038      tgt.setOverbookedElement(Boolean30_50.convertBoolean(src.getOverbookedElement()));
039    if (src.hasComment())
040      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
041    return tgt;
042  }
043
044  public static org.hl7.fhir.dstu3.model.Slot convertSlot(org.hl7.fhir.r5.model.Slot src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.dstu3.model.Slot tgt = new org.hl7.fhir.dstu3.model.Slot();
048    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
051    if (src.hasServiceCategory())
052      tgt.setServiceCategory(CodeableConcept30_50.convertCodeableConcept(src.getServiceCategoryFirstRep()));
053    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getServiceType())
054      tgt.addServiceType(CodeableConcept30_50.convertCodeableConcept(t));
055    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty())
056      tgt.addSpecialty(CodeableConcept30_50.convertCodeableConcept(t));
057    if (src.hasAppointmentType())
058      tgt.setAppointmentType(CodeableConcept30_50.convertCodeableConcept(src.getAppointmentTypeFirstRep()));
059    if (src.hasSchedule())
060      tgt.setSchedule(Reference30_50.convertReference(src.getSchedule()));
061    if (src.hasStatus())
062      tgt.setStatusElement(convertSlotStatus(src.getStatusElement()));
063    if (src.hasStart())
064      tgt.setStartElement(Instant30_50.convertInstant(src.getStartElement()));
065    if (src.hasEnd())
066      tgt.setEndElement(Instant30_50.convertInstant(src.getEndElement()));
067    if (src.hasOverbooked())
068      tgt.setOverbookedElement(Boolean30_50.convertBoolean(src.getOverbookedElement()));
069    if (src.hasComment())
070      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
071    return tgt;
072  }
073
074  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Slot.SlotStatus> convertSlotStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Slot.SlotStatus> src) throws FHIRException {
075    if (src == null || src.isEmpty())
076      return null;
077    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Slot.SlotStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Slot.SlotStatusEnumFactory());
078    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
079    switch (src.getValue()) {
080      case BUSY:
081        tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSY);
082        break;
083      case FREE:
084        tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.FREE);
085        break;
086      case BUSYUNAVAILABLE:
087        tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYUNAVAILABLE);
088        break;
089      case BUSYTENTATIVE:
090        tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.BUSYTENTATIVE);
091        break;
092      case ENTEREDINERROR:
093        tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.ENTEREDINERROR);
094        break;
095      default:
096        tgt.setValue(org.hl7.fhir.dstu3.model.Slot.SlotStatus.NULL);
097        break;
098    }
099    return tgt;
100  }
101
102  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Slot.SlotStatus> convertSlotStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Slot.SlotStatus> src) throws FHIRException {
103    if (src == null || src.isEmpty())
104      return null;
105    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Slot.SlotStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Slot.SlotStatusEnumFactory());
106    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
107    switch (src.getValue()) {
108      case BUSY:
109        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSY);
110        break;
111      case FREE:
112        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.FREE);
113        break;
114      case BUSYUNAVAILABLE:
115        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYUNAVAILABLE);
116        break;
117      case BUSYTENTATIVE:
118        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYTENTATIVE);
119        break;
120      case ENTEREDINERROR:
121        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.ENTEREDINERROR);
122        break;
123      default:
124        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.NULL);
125        break;
126    }
127    return tgt;
128  }
129}