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