001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import java.util.stream.Collectors;
004
005import org.hl7.fhir.convertors.context.ConversionContext10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Attachment10_40;
008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40;
010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40;
011import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Period10_40;
012import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Boolean10_40;
013import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40;
014import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Time10_40;
015import org.hl7.fhir.exceptions.FHIRException;
016
017public class HealthcareService10_40 {
018
019  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek> src) throws FHIRException {
020    if (src == null || src.isEmpty())
021      return null;
022    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());
023    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
024    switch (src.getValue()) {
025      case MON:
026        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.MON);
027        break;
028      case TUE:
029        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.TUE);
030        break;
031      case WED:
032        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.WED);
033        break;
034      case THU:
035        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.THU);
036        break;
037      case FRI:
038        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.FRI);
039        break;
040      case SAT:
041        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SAT);
042        break;
043      case SUN:
044        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SUN);
045        break;
046      default:
047        tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.NULL);
048        break;
049    }
050    return tgt;
051  }
052
053  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> src) throws FHIRException {
054    if (src == null || src.isEmpty())
055      return null;
056    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeekEnumFactory());
057    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
058    switch (src.getValue()) {
059      case MON:
060        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.MON);
061        break;
062      case TUE:
063        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.TUE);
064        break;
065      case WED:
066        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.WED);
067        break;
068      case THU:
069        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.THU);
070        break;
071      case FRI:
072        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.FRI);
073        break;
074      case SAT:
075        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.SAT);
076        break;
077      case SUN:
078        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.SUN);
079        break;
080      default:
081        tgt.setValue(org.hl7.fhir.dstu2.model.HealthcareService.DaysOfWeek.NULL);
082        break;
083    }
084    return tgt;
085  }
086
087  public static org.hl7.fhir.r4.model.HealthcareService convertHealthcareService(org.hl7.fhir.dstu2.model.HealthcareService src) throws FHIRException {
088    if (src == null || src.isEmpty())
089      return null;
090    org.hl7.fhir.r4.model.HealthcareService tgt = new org.hl7.fhir.r4.model.HealthcareService();
091    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
092    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
093      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
094    if (src.hasProvidedBy())
095      tgt.setProvidedBy(Reference10_40.convertReference(src.getProvidedBy()));
096    for (org.hl7.fhir.dstu2.model.HealthcareService.ServiceTypeComponent t : src.getServiceType()) {
097      for (org.hl7.fhir.dstu2.model.CodeableConcept tj : t.getSpecialty())
098        tgt.addSpecialty(CodeableConcept10_40.convertCodeableConcept(tj));
099    }
100    if (src.hasLocation())
101      tgt.addLocation(Reference10_40.convertReference(src.getLocation()));
102    if (src.hasCommentElement())
103      tgt.setCommentElement(String10_40.convertString(src.getCommentElement()));
104    if (src.hasExtraDetails())
105      tgt.setExtraDetails(src.getExtraDetails());
106    if (src.hasPhoto())
107      tgt.setPhoto(Attachment10_40.convertAttachment(src.getPhoto()));
108    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
109      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
110    for (org.hl7.fhir.dstu2.model.Reference t : src.getCoverageArea())
111      tgt.addCoverageArea(Reference10_40.convertReference(t));
112    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getServiceProvisionCode())
113      tgt.addServiceProvisionCode(CodeableConcept10_40.convertCodeableConcept(t));
114    if (src.hasEligibility())
115      tgt.getEligibilityFirstRep().setCode(CodeableConcept10_40.convertCodeableConcept(src.getEligibility()));
116    if (src.hasEligibilityNote())
117      tgt.getEligibilityFirstRep().setComment(src.getEligibilityNote());
118    for (org.hl7.fhir.dstu2.model.StringType t : src.getProgramName()) tgt.addProgram().setText(t.getValue());
119    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getCharacteristic())
120      tgt.addCharacteristic(CodeableConcept10_40.convertCodeableConcept(t));
121    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getReferralMethod())
122      tgt.addReferralMethod(CodeableConcept10_40.convertCodeableConcept(t));
123    if (src.hasAppointmentRequiredElement())
124      tgt.setAppointmentRequiredElement(Boolean10_40.convertBoolean(src.getAppointmentRequiredElement()));
125    for (org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
126      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
127    for (org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
128      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
129    if (src.hasAvailabilityExceptionsElement())
130      tgt.setAvailabilityExceptionsElement(String10_40.convertString(src.getAvailabilityExceptionsElement()));
131    return tgt;
132  }
133
134  public static org.hl7.fhir.dstu2.model.HealthcareService convertHealthcareService(org.hl7.fhir.r4.model.HealthcareService src) throws FHIRException {
135    if (src == null || src.isEmpty())
136      return null;
137    org.hl7.fhir.dstu2.model.HealthcareService tgt = new org.hl7.fhir.dstu2.model.HealthcareService();
138    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
139    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
140      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
141    if (src.hasProvidedBy())
142      tgt.setProvidedBy(Reference10_40.convertReference(src.getProvidedBy()));
143    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty()) {
144      if (!tgt.hasServiceType())
145        tgt.addServiceType();
146      tgt.getServiceType().get(0).addSpecialty(CodeableConcept10_40.convertCodeableConcept(t));
147    }
148    for (org.hl7.fhir.r4.model.Reference t : src.getLocation()) tgt.setLocation(Reference10_40.convertReference(t));
149    if (src.hasCommentElement())
150      tgt.setCommentElement(String10_40.convertString(src.getCommentElement()));
151    if (src.hasExtraDetails())
152      tgt.setExtraDetails(src.getExtraDetails());
153    if (src.hasPhoto())
154      tgt.setPhoto(Attachment10_40.convertAttachment(src.getPhoto()));
155    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
156      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
157    for (org.hl7.fhir.r4.model.Reference t : src.getCoverageArea())
158      tgt.addCoverageArea(Reference10_40.convertReference(t));
159    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceProvisionCode())
160      tgt.addServiceProvisionCode(CodeableConcept10_40.convertCodeableConcept(t));
161    tgt.setEligibility(CodeableConcept10_40.convertCodeableConcept(src.getEligibilityFirstRep().getCode()));
162    if (src.hasCommentElement())
163      tgt.setEligibilityNoteElement(String10_40.convertString(src.getCommentElement()));
164    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgram())
165      if (t.hasText())
166        tgt.addProgramName(t.getText());
167    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCharacteristic())
168      tgt.addCharacteristic(CodeableConcept10_40.convertCodeableConcept(t));
169    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReferralMethod())
170      tgt.addReferralMethod(CodeableConcept10_40.convertCodeableConcept(t));
171    if (src.hasAppointmentRequiredElement())
172      tgt.setAppointmentRequiredElement(Boolean10_40.convertBoolean(src.getAppointmentRequiredElement()));
173    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
174      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
175    for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
176      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
177    if (src.hasAvailabilityExceptionsElement())
178      tgt.setAvailabilityExceptionsElement(String10_40.convertString(src.getAvailabilityExceptionsElement()));
179    return tgt;
180  }
181
182  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
183    if (src == null || src.isEmpty())
184      return null;
185    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
186    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
187    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
188      .map(HealthcareService10_40::convertDaysOfWeek)
189      .collect(Collectors.toList()));
190    if (src.hasAllDayElement())
191      tgt.setAllDayElement(Boolean10_40.convertBoolean(src.getAllDayElement()));
192    if (src.hasAvailableStartTimeElement())
193      tgt.setAvailableStartTimeElement(Time10_40.convertTime(src.getAvailableStartTimeElement()));
194    if (src.hasAvailableEndTimeElement())
195      tgt.setAvailableEndTimeElement(Time10_40.convertTime(src.getAvailableEndTimeElement()));
196    return tgt;
197  }
198
199  public static org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
200    if (src == null || src.isEmpty())
201      return null;
202    org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
203    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
204    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
205      .map(HealthcareService10_40::convertDaysOfWeek)
206      .collect(Collectors.toList()));
207    if (src.hasAllDayElement())
208      tgt.setAllDayElement(Boolean10_40.convertBoolean(src.getAllDayElement()));
209    if (src.hasAvailableStartTimeElement())
210      tgt.setAvailableStartTimeElement(Time10_40.convertTime(src.getAvailableStartTimeElement()));
211    if (src.hasAvailableEndTimeElement())
212      tgt.setAvailableEndTimeElement(Time10_40.convertTime(src.getAvailableEndTimeElement()));
213    return tgt;
214  }
215
216  public static org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
217    if (src == null || src.isEmpty())
218      return null;
219    org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceNotAvailableComponent();
220    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
221    if (src.hasDescriptionElement())
222      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
223    if (src.hasDuring())
224      tgt.setDuring(Period10_40.convertPeriod(src.getDuring()));
225    return tgt;
226  }
227
228  public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.dstu2.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
229    if (src == null || src.isEmpty())
230      return null;
231    org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent();
232    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
233    if (src.hasDescriptionElement())
234      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
235    if (src.hasDuring())
236      tgt.setDuring(Period10_40.convertPeriod(src.getDuring()));
237    return tgt;
238  }
239}