001package org.hl7.fhir.convertors.conv40_50.resources40_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext40_50; 004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.*; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Time40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 010import org.hl7.fhir.exceptions.FHIRException; 011 012import java.util.stream.Collectors; 013 014/* 015 Copyright (c) 2011+, HL7, Inc. 016 All rights reserved. 017 018 Redistribution and use in source and binary forms, with or without modification, 019 are permitted provided that the following conditions are met: 020 021 * Redistributions of source code must retain the above copyright notice, this 022 list of conditions and the following disclaimer. 023 * Redistributions in binary form must reproduce the above copyright notice, 024 this list of conditions and the following disclaimer in the documentation 025 and/or other materials provided with the distribution. 026 * Neither the name of HL7 nor the names of its contributors may be used to 027 endorse or promote products derived from this software without specific 028 prior written permission. 029 030 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 031 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 032 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 033 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 034 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 035 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 036 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 037 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 039 POSSIBILITY OF SUCH DAMAGE. 040 041*/ 042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 043public class HealthcareService40_50 { 044 045 public static org.hl7.fhir.r5.model.HealthcareService convertHealthcareService(org.hl7.fhir.r4.model.HealthcareService src) throws FHIRException { 046 if (src == null) 047 return null; 048 org.hl7.fhir.r5.model.HealthcareService tgt = new org.hl7.fhir.r5.model.HealthcareService(); 049 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 050 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 051 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 052 if (src.hasActive()) 053 tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement())); 054 if (src.hasProvidedBy()) 055 tgt.setProvidedBy(Reference40_50.convertReference(src.getProvidedBy())); 056 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) 057 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 058 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) 059 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 060 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSpecialty()) 061 tgt.addSpecialty(CodeableConcept40_50.convertCodeableConcept(t)); 062 for (org.hl7.fhir.r4.model.Reference t : src.getLocation()) tgt.addLocation(Reference40_50.convertReference(t)); 063 if (src.hasName()) 064 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 065 if (src.hasComment()) 066 tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); 067 if (src.hasExtraDetails()) 068 tgt.setExtraDetailsElement(MarkDown40_50.convertMarkdown(src.getExtraDetailsElement())); 069 if (src.hasPhoto()) 070 tgt.setPhoto(Attachment40_50.convertAttachment(src.getPhoto())); 071 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 072 tgt.addTelecom(ContactPoint40_50.convertContactPoint(t)); 073 for (org.hl7.fhir.r4.model.Reference t : src.getCoverageArea()) 074 tgt.addCoverageArea(Reference40_50.convertReference(t)); 075 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getServiceProvisionCode()) 076 tgt.addServiceProvisionCode(CodeableConcept40_50.convertCodeableConcept(t)); 077 for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent t : src.getEligibility()) 078 tgt.addEligibility(convertHealthcareServiceEligibilityComponent(t)); 079 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgram()) 080 tgt.addProgram(CodeableConcept40_50.convertCodeableConcept(t)); 081 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCharacteristic()) 082 tgt.addCharacteristic(CodeableConcept40_50.convertCodeableConcept(t)); 083 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCommunication()) 084 tgt.addCommunication(CodeableConcept40_50.convertCodeableConcept(t)); 085 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReferralMethod()) 086 tgt.addReferralMethod(CodeableConcept40_50.convertCodeableConcept(t)); 087 if (src.hasAppointmentRequired()) 088 tgt.setAppointmentRequiredElement(Boolean40_50.convertBoolean(src.getAppointmentRequiredElement())); 089 for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime()) 090 tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t)); 091 for (org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable()) 092 tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t)); 093 if (src.hasAvailabilityExceptions()) 094 tgt.setAvailabilityExceptionsElement(String40_50.convertString(src.getAvailabilityExceptionsElement())); 095 for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference40_50.convertReference(t)); 096 return tgt; 097 } 098 099 public static org.hl7.fhir.r4.model.HealthcareService convertHealthcareService(org.hl7.fhir.r5.model.HealthcareService src) throws FHIRException { 100 if (src == null) 101 return null; 102 org.hl7.fhir.r4.model.HealthcareService tgt = new org.hl7.fhir.r4.model.HealthcareService(); 103 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 104 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 105 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 106 if (src.hasActive()) 107 tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement())); 108 if (src.hasProvidedBy()) 109 tgt.setProvidedBy(Reference40_50.convertReference(src.getProvidedBy())); 110 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 111 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 112 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 113 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 114 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSpecialty()) 115 tgt.addSpecialty(CodeableConcept40_50.convertCodeableConcept(t)); 116 for (org.hl7.fhir.r5.model.Reference t : src.getLocation()) tgt.addLocation(Reference40_50.convertReference(t)); 117 if (src.hasName()) 118 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 119 if (src.hasComment()) 120 tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); 121 if (src.hasExtraDetails()) 122 tgt.setExtraDetailsElement(MarkDown40_50.convertMarkdown(src.getExtraDetailsElement())); 123 if (src.hasPhoto()) 124 tgt.setPhoto(Attachment40_50.convertAttachment(src.getPhoto())); 125 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 126 tgt.addTelecom(ContactPoint40_50.convertContactPoint(t)); 127 for (org.hl7.fhir.r5.model.Reference t : src.getCoverageArea()) 128 tgt.addCoverageArea(Reference40_50.convertReference(t)); 129 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getServiceProvisionCode()) 130 tgt.addServiceProvisionCode(CodeableConcept40_50.convertCodeableConcept(t)); 131 for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent t : src.getEligibility()) 132 tgt.addEligibility(convertHealthcareServiceEligibilityComponent(t)); 133 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getProgram()) 134 tgt.addProgram(CodeableConcept40_50.convertCodeableConcept(t)); 135 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCharacteristic()) 136 tgt.addCharacteristic(CodeableConcept40_50.convertCodeableConcept(t)); 137 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCommunication()) 138 tgt.addCommunication(CodeableConcept40_50.convertCodeableConcept(t)); 139 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getReferralMethod()) 140 tgt.addReferralMethod(CodeableConcept40_50.convertCodeableConcept(t)); 141 if (src.hasAppointmentRequired()) 142 tgt.setAppointmentRequiredElement(Boolean40_50.convertBoolean(src.getAppointmentRequiredElement())); 143 for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent t : src.getAvailableTime()) 144 tgt.addAvailableTime(convertHealthcareServiceAvailableTimeComponent(t)); 145 for (org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent t : src.getNotAvailable()) 146 tgt.addNotAvailable(convertHealthcareServiceNotAvailableComponent(t)); 147 if (src.hasAvailabilityExceptions()) 148 tgt.setAvailabilityExceptionsElement(String40_50.convertString(src.getAvailabilityExceptionsElement())); 149 for (org.hl7.fhir.r5.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference40_50.convertReference(t)); 150 return tgt; 151 } 152 153 public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent convertHealthcareServiceEligibilityComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent src) throws FHIRException { 154 if (src == null) 155 return null; 156 org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent(); 157 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 158 if (src.hasCode()) 159 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 160 if (src.hasComment()) 161 tgt.setCommentElement(MarkDown40_50.convertMarkdown(src.getCommentElement())); 162 return tgt; 163 } 164 165 public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent convertHealthcareServiceEligibilityComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceEligibilityComponent src) throws FHIRException { 166 if (src == null) 167 return null; 168 org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceEligibilityComponent(); 169 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 170 if (src.hasCode()) 171 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 172 if (src.hasComment()) 173 tgt.setCommentElement(MarkDown40_50.convertMarkdown(src.getCommentElement())); 174 return tgt; 175 } 176 177 public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException { 178 if (src == null) 179 return null; 180 org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent(); 181 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 182 tgt.setDaysOfWeek(src.getDaysOfWeek().stream() 183 .map(HealthcareService40_50::convertDaysOfWeek) 184 .collect(Collectors.toList())); 185 if (src.hasAllDay()) 186 tgt.setAllDayElement(Boolean40_50.convertBoolean(src.getAllDayElement())); 187 if (src.hasAvailableStartTime()) 188 tgt.setAvailableStartTimeElement(Time40_50.convertTime(src.getAvailableStartTimeElement())); 189 if (src.hasAvailableEndTime()) 190 tgt.setAvailableEndTimeElement(Time40_50.convertTime(src.getAvailableEndTimeElement())); 191 return tgt; 192 } 193 194 public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent convertHealthcareServiceAvailableTimeComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceAvailableTimeComponent src) throws FHIRException { 195 if (src == null) 196 return null; 197 org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceAvailableTimeComponent(); 198 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 199 tgt.setDaysOfWeek(src.getDaysOfWeek().stream() 200 .map(HealthcareService40_50::convertDaysOfWeek) 201 .collect(Collectors.toList())); 202 if (src.hasAllDay()) 203 tgt.setAllDayElement(Boolean40_50.convertBoolean(src.getAllDayElement())); 204 if (src.hasAvailableStartTime()) 205 tgt.setAvailableStartTimeElement(Time40_50.convertTime(src.getAvailableStartTimeElement())); 206 if (src.hasAvailableEndTime()) 207 tgt.setAvailableEndTimeElement(Time40_50.convertTime(src.getAvailableEndTimeElement())); 208 return tgt; 209 } 210 211 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> src) throws FHIRException { 212 if (src == null || src.isEmpty()) 213 return null; 214 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()); 215 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 216 switch (src.getValue()) { 217 case MON: 218 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); 219 break; 220 case TUE: 221 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); 222 break; 223 case WED: 224 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); 225 break; 226 case THU: 227 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); 228 break; 229 case FRI: 230 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); 231 break; 232 case SAT: 233 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); 234 break; 235 case SUN: 236 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); 237 break; 238 default: 239 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); 240 break; 241 } 242 return tgt; 243 } 244 245 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> src) throws FHIRException { 246 if (src == null || src.isEmpty()) 247 return null; 248 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()); 249 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 250 switch (src.getValue()) { 251 case MON: 252 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.MON); 253 break; 254 case TUE: 255 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.TUE); 256 break; 257 case WED: 258 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.WED); 259 break; 260 case THU: 261 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.THU); 262 break; 263 case FRI: 264 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.FRI); 265 break; 266 case SAT: 267 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SAT); 268 break; 269 case SUN: 270 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.SUN); 271 break; 272 default: 273 tgt.setValue(org.hl7.fhir.r4.model.HealthcareService.DaysOfWeek.NULL); 274 break; 275 } 276 return tgt; 277 } 278 279 public static org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException { 280 if (src == null) 281 return null; 282 org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent(); 283 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 284 if (src.hasDescription()) 285 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 286 if (src.hasDuring()) 287 tgt.setDuring(Period40_50.convertPeriod(src.getDuring())); 288 return tgt; 289 } 290 291 public static org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent convertHealthcareServiceNotAvailableComponent(org.hl7.fhir.r5.model.HealthcareService.HealthcareServiceNotAvailableComponent src) throws FHIRException { 292 if (src == null) 293 return null; 294 org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent tgt = new org.hl7.fhir.r4.model.HealthcareService.HealthcareServiceNotAvailableComponent(); 295 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 296 if (src.hasDescription()) 297 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 298 if (src.hasDuring()) 299 tgt.setDuring(Period40_50.convertPeriod(src.getDuring())); 300 return tgt; 301 } 302}