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