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