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