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