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