001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Attachment30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.ContactPoint30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.r5.model.CodeableConcept;
013import org.hl7.fhir.r5.model.ExtendedContactDetail;
014import org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent;
015
016public class HealthcareService30_50 {
017
018  public static org.hl7.fhir.r5.model.HealthcareService convertHealthcareService(org.hl7.fhir.dstu3.model.HealthcareService src) throws FHIRException {
019    if (src == null)
020      return null;
021    org.hl7.fhir.r5.model.HealthcareService tgt = new org.hl7.fhir.r5.model.HealthcareService();
022    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
023    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
024      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
025    if (src.hasActive())
026      tgt.setActiveElement(Boolean30_50.convertBoolean(src.getActiveElement()));
027    if (src.hasProvidedBy())
028      tgt.setProvidedBy(Reference30_50.convertReference(src.getProvidedBy()));
029    if (src.hasCategory())
030      tgt.addCategory(CodeableConcept30_50.convertCodeableConcept(src.getCategory()));
031    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
032      tgt.addType(CodeableConcept30_50.convertCodeableConcept(t));
033    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getSpecialty())
034      tgt.addSpecialty(CodeableConcept30_50.convertCodeableConcept(t));
035    for (org.hl7.fhir.dstu3.model.Reference t : src.getLocation()) tgt.addLocation(Reference30_50.convertReference(t));
036    if (src.hasName())
037      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
038    if (src.hasComment())
039      tgt.setCommentElement(String30_50.convertStringToMarkdown(src.getCommentElement()));
040    if (src.hasExtraDetails())
041      tgt.setExtraDetails(src.getExtraDetails());
042    if (src.hasPhoto())
043      tgt.setPhoto(Attachment30_50.convertAttachment(src.getPhoto()));
044    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
045      tgt.getContactFirstRep().addTelecom(ContactPoint30_50.convertContactPoint(t));
046    for (org.hl7.fhir.dstu3.model.Reference t : src.getCoverageArea())
047      tgt.addCoverageArea(Reference30_50.convertReference(t));
048    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getServiceProvisionCode())
049      tgt.addServiceProvisionCode(CodeableConcept30_50.convertCodeableConcept(t));
050    if (src.hasEligibility() || src.hasEligibilityNote()) {
051      HealthcareServiceEligibilityComponent t = tgt.addEligibility();
052      t.setCode(CodeableConcept30_50.convertCodeableConcept(src.getEligibility()));
053      if (src.hasEligibilityNote())
054        t.setComment(src.getEligibilityNote());
055    }
056    for (org.hl7.fhir.dstu3.model.StringType t : src.getProgramName()) tgt.addProgram().setText(t.getValue());
057    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCharacteristic())
058      tgt.addCharacteristic(CodeableConcept30_50.convertCodeableConcept(t));
059    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReferralMethod())
060      tgt.addReferralMethod(CodeableConcept30_50.convertCodeableConcept(t));
061    if (src.hasAppointmentRequired())
062      tgt.setAppointmentRequiredElement(Boolean30_50.convertBoolean(src.getAppointmentRequiredElement()));
063//    for (org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
064//      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
065//    for (org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
066//      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
067//    if (src.hasAvailabilityExceptions())
068//      tgt.setAvailabilityExceptionsElement(String30_50.convertString(src.getAvailabilityExceptionsElement()));
069    for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference30_50.convertReference(t));
070    return tgt;
071  }
072
073  public static org.hl7.fhir.dstu3.model.HealthcareService convertHealthcareService(org.hl7.fhir.r5.model.HealthcareService src) throws FHIRException {
074    if (src == null)
075      return null;
076    org.hl7.fhir.dstu3.model.HealthcareService tgt = new org.hl7.fhir.dstu3.model.HealthcareService();
077    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
078    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
079      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
080    if (src.hasActive())
081      tgt.setActiveElement(Boolean30_50.convertBoolean(src.getActiveElement()));
082    if (src.hasProvidedBy())
083      tgt.setProvidedBy(Reference30_50.convertReference(src.getProvidedBy()));
084    if (src.hasCategory())
085      tgt.setCategory(CodeableConcept30_50.convertCodeableConcept(src.getCategoryFirstRep()));
086    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType())
087      tgt.addType(CodeableConcept30_50.convertCodeableConcept(t));
088    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty())
089      tgt.addSpecialty(CodeableConcept30_50.convertCodeableConcept(t));
090    for (org.hl7.fhir.r5.model.Reference t : src.getLocation()) tgt.addLocation(Reference30_50.convertReference(t));
091    if (src.hasName())
092      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
093    if (src.hasComment())
094      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
095    if (src.hasExtraDetails())
096      tgt.setExtraDetails(src.getExtraDetails());
097    if (src.hasPhoto())
098      tgt.setPhoto(Attachment30_50.convertAttachment(src.getPhoto()));
099    for (ExtendedContactDetail t1 : src.getContact())
100      for (org.hl7.fhir.r5.model.ContactPoint t : t1.getTelecom())
101        tgt.addTelecom(ContactPoint30_50.convertContactPoint(t));
102    for (org.hl7.fhir.r5.model.Reference t : src.getCoverageArea())
103      tgt.addCoverageArea(Reference30_50.convertReference(t));
104    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getServiceProvisionCode())
105      tgt.addServiceProvisionCode(CodeableConcept30_50.convertCodeableConcept(t));
106    if (src.hasEligibility()) {
107      tgt.setEligibility(CodeableConcept30_50.convertCodeableConcept(src.getEligibilityFirstRep().getCode()));
108      if (src.getEligibilityFirstRep().hasComment())
109        tgt.setEligibilityNoteElement(String30_50.convertString(src.getCommentElement()));
110    }
111    for (CodeableConcept t : src.getProgram()) tgt.addProgramName(t.getText());
112    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCharacteristic())
113      tgt.addCharacteristic(CodeableConcept30_50.convertCodeableConcept(t));
114    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReferralMethod())
115      tgt.addReferralMethod(CodeableConcept30_50.convertCodeableConcept(t));
116    if (src.hasAppointmentRequired())
117      tgt.setAppointmentRequiredElement(Boolean30_50.convertBoolean(src.getAppointmentRequiredElement()));
118//    for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime())
119//      tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t));
120//    for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable())
121//      tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t));
122//    if (src.hasAvailabilityExceptions())
123//      tgt.setAvailabilityExceptionsElement(String30_50.convertString(src.getAvailabilityExceptionsElement()));
124    for (org.hl7.fhir.r5.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference30_50.convertReference(t));
125    return tgt;
126  }
127
128//  public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
129//    if (src == null)
130//      return null;
131//    org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
132//    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
133//    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
134//      .map(HealthcareService30_50::convertDaysOfWeek)
135//      .collect(Collectors.toList()));
136//    if (src.hasAllDay())
137//      tgt.setAllDayElement(Boolean30_50.convertBoolean(src.getAllDayElement()));
138//    if (src.hasAvailableStartTime())
139//      tgt.setAvailableStartTimeElement(Time30_50.convertTime(src.getAvailableStartTimeElement()));
140//    if (src.hasAvailableEndTime())
141//      tgt.setAvailableEndTimeElement(Time30_50.convertTime(src.getAvailableEndTimeElement()));
142//    return tgt;
143//  }
144//
145//  public static org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException {
146//    if (src == null)
147//      return null;
148//    org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceAvailableTimeComponent();
149//    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
150//    tgt.setDaysOfWeek(src.getDaysOfWeek().stream()
151//      .map(HealthcareService30_50::convertDaysOfWeek)
152//      .collect(Collectors.toList()));
153//    if (src.hasAllDay())
154//      tgt.setAllDayElement(Boolean30_50.convertBoolean(src.getAllDayElement()));
155//    if (src.hasAvailableStartTime())
156//      tgt.setAvailableStartTimeElement(Time30_50.convertTime(src.getAvailableStartTimeElement()));
157//    if (src.hasAvailableEndTime())
158//      tgt.setAvailableEndTimeElement(Time30_50.convertTime(src.getAvailableEndTimeElement()));
159//    return tgt;
160//  }
161
162  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> src) throws FHIRException {
163    if (src == null || src.isEmpty())
164      return null;
165    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());
166    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
167    switch (src.getValue()) {
168      case MON:
169        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.MON);
170        break;
171      case TUE:
172        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.TUE);
173        break;
174      case WED:
175        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.WED);
176        break;
177      case THU:
178        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.THU);
179        break;
180      case FRI:
181        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.FRI);
182        break;
183      case SAT:
184        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.SAT);
185        break;
186      case SUN:
187        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.SUN);
188        break;
189      default:
190        tgt.setValue(org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek.NULL);
191        break;
192    }
193    return tgt;
194  }
195
196  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.HealthcareService.DaysOfWeek> src) throws FHIRException {
197    if (src == null || src.isEmpty())
198      return null;
199    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());
200    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
201    switch (src.getValue()) {
202      case MON:
203        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON);
204        break;
205      case TUE:
206        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE);
207        break;
208      case WED:
209        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED);
210        break;
211      case THU:
212        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU);
213        break;
214      case FRI:
215        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI);
216        break;
217      case SAT:
218        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT);
219        break;
220      case SUN:
221        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN);
222        break;
223      default:
224        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL);
225        break;
226    }
227    return tgt;
228  }
229//
230//  public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
231//    if (src == null)
232//      return null;
233//    org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent();
234//    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
235//    if (src.hasDescription())
236//      tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
237//    if (src.hasDuring())
238//      tgt.setDuring(Period30_50.convertPeriod(src.getDuring()));
239//    return tgt;
240//  }
241//
242//  public static org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException {
243//    if (src == null)
244//      return null;
245//    org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.dstu3.model.HealthcareService.HealthcareServiceNotAvailableComponent();
246//    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
247//    if (src.hasDescription())
248//      tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement()));
249//    if (src.hasDuring())
250//      tgt.setDuring(Period30_50.convertPeriod(src.getDuring()));
251//    return tgt;
252//  }
253}