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