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