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