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.ContactPoint43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
010import org.hl7.fhir.exceptions.FHIRException;
011
012/*
013  Copyright (c) 2011+, HL7, Inc.
014  All rights reserved.
015  
016  Redistribution and use in source and binary forms, with or without modification, 
017  are permitted provided that the following conditions are met:
018  
019   * Redistributions of source code must retain the above copyright notice, this 
020     list of conditions and the following disclaimer.
021   * Redistributions in binary form must reproduce the above copyright notice, 
022     this list of conditions and the following disclaimer in the documentation 
023     and/or other materials provided with the distribution.
024   * Neither the name of HL7 nor the names of its contributors may be used to 
025     endorse or promote products derived from this software without specific 
026     prior written permission.
027  
028  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
029  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
030  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
031  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
032  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
033  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
034  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
035  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
036  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
037  POSSIBILITY OF SUCH DAMAGE.
038  
039*/
040// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
041public class PractitionerRole43_50 {
042
043  public static org.hl7.fhir.r5.model.PractitionerRole convertPractitionerRole(org.hl7.fhir.r4b.model.PractitionerRole src) throws FHIRException {
044    if (src == null)
045      return null;
046    org.hl7.fhir.r5.model.PractitionerRole tgt = new org.hl7.fhir.r5.model.PractitionerRole();
047    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
048    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
049      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
050    if (src.hasActive())
051      tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement()));
052    if (src.hasPeriod())
053      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
054    if (src.hasPractitioner())
055      tgt.setPractitioner(Reference43_50.convertReference(src.getPractitioner()));
056    if (src.hasOrganization())
057      tgt.setOrganization(Reference43_50.convertReference(src.getOrganization()));
058    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCode())
059      tgt.addCode(CodeableConcept43_50.convertCodeableConcept(t));
060    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getSpecialty())
061      tgt.addSpecialty(CodeableConcept43_50.convertCodeableConcept(t));
062    for (org.hl7.fhir.r4b.model.Reference t : src.getLocation()) tgt.addLocation(Reference43_50.convertReference(t));
063    for (org.hl7.fhir.r4b.model.Reference t : src.getHealthcareService())
064      tgt.addHealthcareService(Reference43_50.convertReference(t));
065    for (org.hl7.fhir.r4b.model.ContactPoint t : src.getTelecom())
066      tgt.getContactFirstRep().addTelecom(ContactPoint43_50.convertContactPoint(t));
067//    for (org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleAvailableTimeComponent t : src.getAvailableTime())
068//      tgt.addAvailableTime(convertPractitionerRoleAvailableTimeComponent(t));
069//    for (org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleNotAvailableComponent t : src.getNotAvailable())
070//      tgt.addNotAvailable(convertPractitionerRoleNotAvailableComponent(t));
071//    if (src.hasAvailabilityExceptions())
072//      tgt.setAvailabilityExceptionsElement(String43_50.convertString(src.getAvailabilityExceptionsElement()));
073    for (org.hl7.fhir.r4b.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference43_50.convertReference(t));
074    return tgt;
075  }
076
077  public static org.hl7.fhir.r4b.model.PractitionerRole convertPractitionerRole(org.hl7.fhir.r5.model.PractitionerRole src) throws FHIRException {
078    if (src == null)
079      return null;
080    org.hl7.fhir.r4b.model.PractitionerRole tgt = new org.hl7.fhir.r4b.model.PractitionerRole();
081    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
082    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
083      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
084    if (src.hasActive())
085      tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement()));
086    if (src.hasPeriod())
087      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
088    if (src.hasPractitioner())
089      tgt.setPractitioner(Reference43_50.convertReference(src.getPractitioner()));
090    if (src.hasOrganization())
091      tgt.setOrganization(Reference43_50.convertReference(src.getOrganization()));
092    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCode())
093      tgt.addCode(CodeableConcept43_50.convertCodeableConcept(t));
094    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty())
095      tgt.addSpecialty(CodeableConcept43_50.convertCodeableConcept(t));
096    for (org.hl7.fhir.r5.model.Reference t : src.getLocation()) tgt.addLocation(Reference43_50.convertReference(t));
097    for (org.hl7.fhir.r5.model.Reference t : src.getHealthcareService())
098      tgt.addHealthcareService(Reference43_50.convertReference(t));
099    for (org.hl7.fhir.r5.model.ExtendedContactDetail t1 : src.getContact())
100      for (org.hl7.fhir.r5.model.ContactPoint t : t1.getTelecom())
101        tgt.addTelecom(ContactPoint43_50.convertContactPoint(t));
102//    for (org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleAvailableTimeComponent t : src.getAvailableTime())
103//      tgt.addAvailableTime(convertPractitionerRoleAvailableTimeComponent(t));
104//    for (org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleNotAvailableComponent t : src.getNotAvailable())
105//      tgt.addNotAvailable(convertPractitionerRoleNotAvailableComponent(t));
106//    if (src.hasAvailabilityExceptions())
107//      tgt.setAvailabilityExceptionsElement(String43_50.convertString(src.getAvailabilityExceptionsElement()));
108    for (org.hl7.fhir.r5.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference43_50.convertReference(t));
109    return tgt;
110  }
111
112//  public static org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleAvailableTimeComponent convertPractitionerRoleAvailableTimeComponent(org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleAvailableTimeComponent src) throws FHIRException {
113//    if (src == null)
114//      return null;
115//    org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleAvailableTimeComponent tgt = new org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleAvailableTimeComponent();
116//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
117//    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
118//      .map(PractitionerRole43_50::convertDaysOfWeek)
119//      .collect(Collectors.toList()));
120//    if (src.hasAllDay())
121//      tgt.setAllDayElement(Boolean43_50.convertBoolean(src.getAllDayElement()));
122//    if (src.hasAvailableStartTime())
123//      tgt.setAvailableStartTimeElement(Time43_50.convertTime(src.getAvailableStartTimeElement()));
124//    if (src.hasAvailableEndTime())
125//      tgt.setAvailableEndTimeElement(Time43_50.convertTime(src.getAvailableEndTimeElement()));
126//    return tgt;
127//  }
128//
129//  public static org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleAvailableTimeComponent convertPractitionerRoleAvailableTimeComponent(org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleAvailableTimeComponent src) throws FHIRException {
130//    if (src == null)
131//      return null;
132//    org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleAvailableTimeComponent tgt = new org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleAvailableTimeComponent();
133//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
134//    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
135//      .map(PractitionerRole43_50::convertDaysOfWeek)
136//      .collect(Collectors.toList()));
137//    if (src.hasAllDay())
138//      tgt.setAllDayElement(Boolean43_50.convertBoolean(src.getAllDayElement()));
139//    if (src.hasAvailableStartTime())
140//      tgt.setAvailableStartTimeElement(Time43_50.convertTime(src.getAvailableStartTimeElement()));
141//    if (src.hasAvailableEndTime())
142//      tgt.setAvailableEndTimeElement(Time43_50.convertTime(src.getAvailableEndTimeElement()));
143//    return tgt;
144//  }
145//
146//  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek> src) throws FHIRException {
147//    if (src == null || src.isEmpty())
148//      return null;
149//    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory());
150//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
151//    switch (src.getValue()) {
152//      case MON:
153//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON);
154//        break;
155//      case TUE:
156//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE);
157//        break;
158//      case WED:
159//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED);
160//        break;
161//      case THU:
162//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU);
163//        break;
164//      case FRI:
165//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI);
166//        break;
167//      case SAT:
168//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT);
169//        break;
170//      case SUN:
171//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN);
172//        break;
173//      default:
174//        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL);
175//        break;
176//    }
177//    return tgt;
178//  }
179//
180//  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> src) throws FHIRException {
181//    if (src == null || src.isEmpty())
182//      return null;
183//    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.DaysOfWeekEnumFactory());
184//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
185//    switch (src.getValue()) {
186//      case MON:
187//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.MON);
188//        break;
189//      case TUE:
190//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.TUE);
191//        break;
192//      case WED:
193//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.WED);
194//        break;
195//      case THU:
196//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.THU);
197//        break;
198//      case FRI:
199//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.FRI);
200//        break;
201//      case SAT:
202//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.SAT);
203//        break;
204//      case SUN:
205//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.SUN);
206//        break;
207//      default:
208//        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DaysOfWeek.NULL);
209//        break;
210//    }
211//    return tgt;
212//  }
213//
214//  public static org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleNotAvailableComponent convertPractitionerRoleNotAvailableComponent(org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleNotAvailableComponent src) throws FHIRException {
215//    if (src == null)
216//      return null;
217//    org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleNotAvailableComponent tgt = new org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleNotAvailableComponent();
218//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
219//    if (src.hasDescription())
220//      tgt.setDescriptionElement(String43_50.convertString(src.getDescriptionElement()));
221//    if (src.hasDuring())
222//      tgt.setDuring(Period43_50.convertPeriod(src.getDuring()));
223//    return tgt;
224//  }
225//
226//  public static org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleNotAvailableComponent convertPractitionerRoleNotAvailableComponent(org.hl7.fhir.r5.model.PractitionerRole.PractitionerRoleNotAvailableComponent src) throws FHIRException {
227//    if (src == null)
228//      return null;
229//    org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleNotAvailableComponent tgt = new org.hl7.fhir.r4b.model.PractitionerRole.PractitionerRoleNotAvailableComponent();
230//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
231//    if (src.hasDescription())
232//      tgt.setDescriptionElement(String43_50.convertString(src.getDescriptionElement()));
233//    if (src.hasDuring())
234//      tgt.setDuring(Period43_50.convertPeriod(src.getDuring()));
235//    return tgt;
236//  }
237}