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.Attachment40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.ContactPoint40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_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.MarkDown40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
012import org.hl7.fhir.exceptions.FHIRException;
013import org.hl7.fhir.r5.model.ExtendedContactDetail;
014
015/*
016  Copyright (c) 2011+, HL7, Inc.
017  All rights reserved.
018  
019  Redistribution and use in source and binary forms, with or without modification, 
020  are permitted provided that the following conditions are met:
021  
022   * Redistributions of source code must retain the above copyright notice, this 
023     list of conditions and the following disclaimer.
024   * Redistributions in binary form must reproduce the above copyright notice, 
025     this list of conditions and the following disclaimer in the documentation 
026     and/or other materials provided with the distribution.
027   * Neither the name of HL7 nor the names of its contributors may be used to 
028     endorse or promote products derived from this software without specific 
029     prior written permission.
030  
031  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
032  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
033  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
034  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
035  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
036  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
037  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
038  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
039  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
040  POSSIBILITY OF SUCH DAMAGE.
041  
042*/
043// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
044public class HealthcareService40_50 {
045
046  public static org.hl7.fhir.r5.model.HealthcareService convertHealthcareService(org.hl7.fhir.r4.model.HealthcareService src) throws FHIRException {
047    if (src == null)
048      return null;
049    org.hl7.fhir.r5.model.HealthcareService tgt = new org.hl7.fhir.r5.model.HealthcareService();
050    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
051    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
052      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
053    if (src.hasActive())
054      tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement()));
055    if (src.hasProvidedBy())
056      tgt.setProvidedBy(Reference40_50.convertReference(src.getProvidedBy()));
057    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
058      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
059    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType())
060      tgt.addType(CodeableConcept40_50.convertCodeableConcept(t));
061    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty())
062      tgt.addSpecialty(CodeableConcept40_50.convertCodeableConcept(t));
063    for (org.hl7.fhir.r4.model.Reference t : src.getLocation()) tgt.addLocation(Reference40_50.convertReference(t));
064    if (src.hasName())
065      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
066    if (src.hasComment())
067      tgt.setCommentElement(String40_50.convertStringToMarkdown(src.getCommentElement()));
068    if (src.hasExtraDetails())
069      tgt.setExtraDetailsElement(MarkDown40_50.convertMarkdown(src.getExtraDetailsElement()));
070    if (src.hasPhoto())
071      tgt.setPhoto(Attachment40_50.convertAttachment(src.getPhoto()));
072    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
073      tgt.getContactFirstRep().addTelecom(ContactPoint40_50.convertContactPoint(t));
074    for (org.hl7.fhir.r4.model.Reference t : src.getCoverageArea())
075      tgt.addCoverageArea(Reference40_50.convertReference(t));
076    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceProvisionCode())
077      tgt.addServiceProvisionCode(CodeableConcept40_50.convertCodeableConcept(t));
078    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent t : src.getEligibility())
079      tgt.addEligibility(convertHealthcareServiceEligibilityComponent(t));
080    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgram())
081      tgt.addProgram(CodeableConcept40_50.convertCodeableConcept(t));
082    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCharacteristic())
083      tgt.addCharacteristic(CodeableConcept40_50.convertCodeableConcept(t));
084    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCommunication())
085      tgt.addCommunication(CodeableConcept40_50.convertCodeableConcept(t));
086    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReferralMethod())
087      tgt.addReferralMethod(CodeableConcept40_50.convertCodeableConcept(t));
088    if (src.hasAppointmentRequired())
089      tgt.setAppointmentRequiredElement(Boolean40_50.convertBoolean(src.getAppointmentRequiredElement()));
090//    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
091//      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
092//    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
093//      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
094//    if (src.hasAvailabilityExceptions())
095//      tgt.setAvailabilityExceptionsElement(String40_50.convertString(src.getAvailabilityExceptionsElement()));
096    for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference40_50.convertReference(t));
097    return tgt;
098  }
099
100  public static org.hl7.fhir.r4.model.HealthcareService convertHealthcareService(org.hl7.fhir.r5.model.HealthcareService src) throws FHIRException {
101    if (src == null)
102      return null;
103    org.hl7.fhir.r4.model.HealthcareService tgt = new org.hl7.fhir.r4.model.HealthcareService();
104    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
105    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
106      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
107    if (src.hasActive())
108      tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement()));
109    if (src.hasProvidedBy())
110      tgt.setProvidedBy(Reference40_50.convertReference(src.getProvidedBy()));
111    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
112      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
113    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType())
114      tgt.addType(CodeableConcept40_50.convertCodeableConcept(t));
115    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty())
116      tgt.addSpecialty(CodeableConcept40_50.convertCodeableConcept(t));
117    for (org.hl7.fhir.r5.model.Reference t : src.getLocation()) tgt.addLocation(Reference40_50.convertReference(t));
118    if (src.hasName())
119      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
120    if (src.hasComment())
121      tgt.setCommentElement(String40_50.convertString(src.getCommentElement()));
122    if (src.hasExtraDetails())
123      tgt.setExtraDetailsElement(MarkDown40_50.convertMarkdown(src.getExtraDetailsElement()));
124    if (src.hasPhoto())
125      tgt.setPhoto(Attachment40_50.convertAttachment(src.getPhoto()));
126    for (ExtendedContactDetail t1 : src.getContact())
127      for (org.hl7.fhir.r5.model.ContactPoint t : t1.getTelecom())
128        tgt.addTelecom(ContactPoint40_50.convertContactPoint(t));
129    for (org.hl7.fhir.r5.model.Reference t : src.getCoverageArea())
130      tgt.addCoverageArea(Reference40_50.convertReference(t));
131    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getServiceProvisionCode())
132      tgt.addServiceProvisionCode(CodeableConcept40_50.convertCodeableConcept(t));
133    for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent t : src.getEligibility())
134      tgt.addEligibility(convertHealthcareServiceEligibilityComponent(t));
135    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getProgram())
136      tgt.addProgram(CodeableConcept40_50.convertCodeableConcept(t));
137    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCharacteristic())
138      tgt.addCharacteristic(CodeableConcept40_50.convertCodeableConcept(t));
139    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCommunication())
140      tgt.addCommunication(CodeableConcept40_50.convertCodeableConcept(t));
141    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReferralMethod())
142      tgt.addReferralMethod(CodeableConcept40_50.convertCodeableConcept(t));
143    if (src.hasAppointmentRequired())
144      tgt.setAppointmentRequiredElement(Boolean40_50.convertBoolean(src.getAppointmentRequiredElement()));
145//    for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
146//      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
147//    for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
148//      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
149//    if (src.hasAvailabilityExceptions())
150//      tgt.setAvailabilityExceptionsElement(String40_50.convertString(src.getAvailabilityExceptionsElement()));
151    for (org.hl7.fhir.r5.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference40_50.convertReference(t));
152    return tgt;
153  }
154
155  public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent convertHealthcareServiceEligibilityComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent src) throws FHIRException {
156    if (src == null)
157      return null;
158    org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent();
159    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
160    if (src.hasCode())
161      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
162    if (src.hasComment())
163      tgt.setCommentElement(MarkDown40_50.convertMarkdown(src.getCommentElement()));
164    return tgt;
165  }
166
167  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent convertHealthcareServiceEligibilityComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent src) throws FHIRException {
168    if (src == null)
169      return null;
170    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent();
171    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
172    if (src.hasCode())
173      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
174    if (src.hasComment())
175      tgt.setCommentElement(MarkDown40_50.convertMarkdown(src.getCommentElement()));
176    return tgt;
177  }
178
179//  public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
180//    if (src == null)
181//      return null;
182//    org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
183//    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
184//    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
185//      .map(HealthcareService40_50::convertDaysOfWeek)
186//      .collect(Collectors.toList()));
187//    if (src.hasAllDay())
188//      tgt.setAllDayElement(Boolean40_50.convertBoolean(src.getAllDayElement()));
189//    if (src.hasAvailableStartTime())
190//      tgt.setAvailableStartTimeElement(Time40_50.convertTime(src.getAvailableStartTimeElement()));
191//    if (src.hasAvailableEndTime())
192//      tgt.setAvailableEndTimeElement(Time40_50.convertTime(src.getAvailableEndTimeElement()));
193//    return tgt;
194//  }
195
196//  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
197//    if (src == null)
198//      return null;
199//    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
200//    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
201//    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
202//      .map(HealthcareService40_50::convertDaysOfWeek)
203//      .collect(Collectors.toList()));
204//    if (src.hasAllDay())
205//      tgt.setAllDayElement(Boolean40_50.convertBoolean(src.getAllDayElement()));
206//    if (src.hasAvailableStartTime())
207//      tgt.setAvailableStartTimeElement(Time40_50.convertTime(src.getAvailableStartTimeElement()));
208//    if (src.hasAvailableEndTime())
209//      tgt.setAvailableEndTimeElement(Time40_50.convertTime(src.getAvailableEndTimeElement()));
210//    return tgt;
211//  }
212
213  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.HealthcareService.DaysOfWeek> src) throws FHIRException {
214    if (src == null || src.isEmpty())
215      return null;
216    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());
217    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
218    switch (src.getValue()) {
219      case MON:
220        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON);
221        break;
222      case TUE:
223        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE);
224        break;
225      case WED:
226        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED);
227        break;
228      case THU:
229        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU);
230        break;
231      case FRI:
232        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI);
233        break;
234      case SAT:
235        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT);
236        break;
237      case SUN:
238        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN);
239        break;
240      default:
241        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL);
242        break;
243    }
244    return tgt;
245  }
246
247  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> src) throws FHIRException {
248    if (src == null || src.isEmpty())
249      return null;
250    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.HealthcareService.DaysOfWeekEnumFactory());
251    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
252    switch (src.getValue()) {
253      case MON:
254        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.MON);
255        break;
256      case TUE:
257        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.TUE);
258        break;
259      case WED:
260        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.WED);
261        break;
262      case THU:
263        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.THU);
264        break;
265      case FRI:
266        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.FRI);
267        break;
268      case SAT:
269        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SAT);
270        break;
271      case SUN:
272        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SUN);
273        break;
274      default:
275        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.NULL);
276        break;
277    }
278    return tgt;
279  }
280//
281//  public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
282//    if (src == null)
283//      return null;
284//    org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent();
285//    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
286//    if (src.hasDescription())
287//      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
288//    if (src.hasDuring())
289//      tgt.setDuring(Period40_50.convertPeriod(src.getDuring()));
290//    return tgt;
291//  }
292//
293//  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
294//    if (src == null)
295//      return null;
296//    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent();
297//    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
298//    if (src.hasDescription())
299//      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
300//    if (src.hasDuring())
301//      tgt.setDuring(Period40_50.convertPeriod(src.getDuring()));
302//    return tgt;
303//  }
304}