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