001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext43_50;
004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Instant43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r5.model.CodeableReference;
012
013/*
014  Copyright (c) 2011+, HL7, Inc.
015  All rights reserved.
016  
017  Redistribution and use in source and binary forms, with or without modification, 
018  are permitted provided that the following conditions are met:
019  
020   * Redistributions of source code must retain the above copyright notice, this 
021     list of conditions and the following disclaimer.
022   * Redistributions in binary form must reproduce the above copyright notice, 
023     this list of conditions and the following disclaimer in the documentation 
024     and/or other materials provided with the distribution.
025   * Neither the name of HL7 nor the names of its contributors may be used to 
026     endorse or promote products derived from this software without specific 
027     prior written permission.
028  
029  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
030  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
031  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
032  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
033  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
034  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
035  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
036  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
037  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
038  POSSIBILITY OF SUCH DAMAGE.
039  
040*/
041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
042public class Slot43_50 {
043
044  public static org.hl7.fhir.r5.model.Slot convertSlot(org.hl7.fhir.r4b.model.Slot src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.Slot tgt = new org.hl7.fhir.r5.model.Slot();
048    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
051    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getServiceCategory())
052      tgt.addServiceCategory(CodeableConcept43_50.convertCodeableConcept(t));
053    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getServiceType())
054      tgt.addServiceType(new CodeableReference().setConcept(CodeableConcept43_50.convertCodeableConcept(t)));
055    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getSpecialty())
056      tgt.addSpecialty(CodeableConcept43_50.convertCodeableConcept(t));
057    if (src.hasAppointmentType())
058      tgt.addAppointmentType(CodeableConcept43_50.convertCodeableConcept(src.getAppointmentType()));
059    if (src.hasSchedule())
060      tgt.setSchedule(Reference43_50.convertReference(src.getSchedule()));
061    if (src.hasStatus())
062      tgt.setStatusElement(convertSlotStatus(src.getStatusElement()));
063    if (src.hasStart())
064      tgt.setStartElement(Instant43_50.convertInstant(src.getStartElement()));
065    if (src.hasEnd())
066      tgt.setEndElement(Instant43_50.convertInstant(src.getEndElement()));
067    if (src.hasOverbooked())
068      tgt.setOverbookedElement(Boolean43_50.convertBoolean(src.getOverbookedElement()));
069    if (src.hasComment())
070      tgt.setCommentElement(String43_50.convertString(src.getCommentElement()));
071    return tgt;
072  }
073
074  public static org.hl7.fhir.r4b.model.Slot convertSlot(org.hl7.fhir.r5.model.Slot src) throws FHIRException {
075    if (src == null)
076      return null;
077    org.hl7.fhir.r4b.model.Slot tgt = new org.hl7.fhir.r4b.model.Slot();
078    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
079    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
080      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
081    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getServiceCategory())
082      tgt.addServiceCategory(CodeableConcept43_50.convertCodeableConcept(t));
083    for (CodeableReference t : src.getServiceType())
084      if (t.hasConcept())
085        tgt.addServiceType(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
086    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty())
087      tgt.addSpecialty(CodeableConcept43_50.convertCodeableConcept(t));
088    if (src.hasAppointmentType())
089      tgt.setAppointmentType(CodeableConcept43_50.convertCodeableConcept(src.getAppointmentTypeFirstRep()));
090    if (src.hasSchedule())
091      tgt.setSchedule(Reference43_50.convertReference(src.getSchedule()));
092    if (src.hasStatus())
093      tgt.setStatusElement(convertSlotStatus(src.getStatusElement()));
094    if (src.hasStart())
095      tgt.setStartElement(Instant43_50.convertInstant(src.getStartElement()));
096    if (src.hasEnd())
097      tgt.setEndElement(Instant43_50.convertInstant(src.getEndElement()));
098    if (src.hasOverbooked())
099      tgt.setOverbookedElement(Boolean43_50.convertBoolean(src.getOverbookedElement()));
100    if (src.hasComment())
101      tgt.setCommentElement(String43_50.convertString(src.getCommentElement()));
102    return tgt;
103  }
104
105  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Slot.SlotStatus> convertSlotStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Slot.SlotStatus> src) throws FHIRException {
106    if (src == null || src.isEmpty())
107      return null;
108    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());
109    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
110    switch (src.getValue()) {
111      case BUSY:
112        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSY);
113        break;
114      case FREE:
115        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.FREE);
116        break;
117      case BUSYUNAVAILABLE:
118        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYUNAVAILABLE);
119        break;
120      case BUSYTENTATIVE:
121        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.BUSYTENTATIVE);
122        break;
123      case ENTEREDINERROR:
124        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.ENTEREDINERROR);
125        break;
126      default:
127        tgt.setValue(org.hl7.fhir.r5.model.Slot.SlotStatus.NULL);
128        break;
129    }
130    return tgt;
131  }
132
133  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Slot.SlotStatus> convertSlotStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Slot.SlotStatus> src) throws FHIRException {
134    if (src == null || src.isEmpty())
135      return null;
136    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Slot.SlotStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Slot.SlotStatusEnumFactory());
137    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
138    switch (src.getValue()) {
139      case BUSY:
140        tgt.setValue(org.hl7.fhir.r4b.model.Slot.SlotStatus.BUSY);
141        break;
142      case FREE:
143        tgt.setValue(org.hl7.fhir.r4b.model.Slot.SlotStatus.FREE);
144        break;
145      case BUSYUNAVAILABLE:
146        tgt.setValue(org.hl7.fhir.r4b.model.Slot.SlotStatus.BUSYUNAVAILABLE);
147        break;
148      case BUSYTENTATIVE:
149        tgt.setValue(org.hl7.fhir.r4b.model.Slot.SlotStatus.BUSYTENTATIVE);
150        break;
151      case ENTEREDINERROR:
152        tgt.setValue(org.hl7.fhir.r4b.model.Slot.SlotStatus.ENTEREDINERROR);
153        break;
154      default:
155        tgt.setValue(org.hl7.fhir.r4b.model.Slot.SlotStatus.NULL);
156        break;
157    }
158    return tgt;
159  }
160}