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.Address40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.ContactPoint40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Decimal40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 012import org.hl7.fhir.exceptions.FHIRException; 013import org.hl7.fhir.r5.model.ContactPoint; 014import org.hl7.fhir.r5.model.ExtendedContactDetail; 015 016/* 017 Copyright (c) 2011+, HL7, Inc. 018 All rights reserved. 019 020 Redistribution and use in source and binary forms, with or without modification, 021 are permitted provided that the following conditions are met: 022 023 * Redistributions of source code must retain the above copyright notice, this 024 list of conditions and the following disclaimer. 025 * Redistributions in binary form must reproduce the above copyright notice, 026 this list of conditions and the following disclaimer in the documentation 027 and/or other materials provided with the distribution. 028 * Neither the name of HL7 nor the names of its contributors may be used to 029 endorse or promote products derived from this software without specific 030 prior written permission. 031 032 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 033 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 034 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 035 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 036 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 037 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 038 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 039 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 040 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 041 POSSIBILITY OF SUCH DAMAGE. 042 043*/ 044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 045public class Location40_50 { 046 047 public static org.hl7.fhir.r5.model.Location convertLocation(org.hl7.fhir.r4.model.Location src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r5.model.Location tgt = new org.hl7.fhir.r5.model.Location(); 051 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 052 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 053 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 054 if (src.hasStatus()) 055 tgt.setStatusElement(convertLocationStatus(src.getStatusElement())); 056 if (src.hasOperationalStatus()) 057 tgt.setOperationalStatus(Coding40_50.convertCoding(src.getOperationalStatus())); 058 if (src.hasName()) 059 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 060 for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.getAlias().add(String40_50.convertString(t)); 061 if (src.hasDescription()) 062 tgt.setDescriptionElement(String40_50.convertStringToMarkdown(src.getDescriptionElement())); 063 if (src.hasMode()) 064 tgt.setModeElement(convertLocationMode(src.getModeElement())); 065 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getType()) 066 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 067 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 068 tgt.getContactFirstRep().addTelecom(ContactPoint40_50.convertContactPoint(t)); 069 if (src.hasAddress()) 070 tgt.setAddress(Address40_50.convertAddress(src.getAddress())); 071 if (src.hasPhysicalType()) 072 tgt.setForm(CodeableConcept40_50.convertCodeableConcept(src.getPhysicalType())); 073 if (src.hasPosition()) 074 tgt.setPosition(convertLocationPositionComponent(src.getPosition())); 075 if (src.hasManagingOrganization()) 076 tgt.setManagingOrganization(Reference40_50.convertReference(src.getManagingOrganization())); 077 if (src.hasPartOf()) 078 tgt.setPartOf(Reference40_50.convertReference(src.getPartOf())); 079// for (org.hl7.fhir.r4.model.Location.LocationHoursOfOperationComponent t : src.getHoursOfOperation()) 080// tgt.addHoursOfOperation(convertLocationHoursOfOperationComponent(t)); 081// if (src.hasAvailabilityExceptions()) 082// tgt.setAvailabilityExceptionsElement(String40_50.convertString(src.getAvailabilityExceptionsElement())); 083 for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference40_50.convertReference(t)); 084 return tgt; 085 } 086 087 public static org.hl7.fhir.r4.model.Location convertLocation(org.hl7.fhir.r5.model.Location src) throws FHIRException { 088 if (src == null) 089 return null; 090 org.hl7.fhir.r4.model.Location tgt = new org.hl7.fhir.r4.model.Location(); 091 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 092 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 093 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 094 if (src.hasStatus()) 095 tgt.setStatusElement(convertLocationStatus(src.getStatusElement())); 096 if (src.hasOperationalStatus()) 097 tgt.setOperationalStatus(Coding40_50.convertCoding(src.getOperationalStatus())); 098 if (src.hasName()) 099 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 100 for (org.hl7.fhir.r5.model.StringType t : src.getAlias()) tgt.getAlias().add(String40_50.convertString(t)); 101 if (src.hasDescription()) 102 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 103 if (src.hasMode()) 104 tgt.setModeElement(convertLocationMode(src.getModeElement())); 105 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 106 tgt.addType(CodeableConcept40_50.convertCodeableConcept(t)); 107 for (ExtendedContactDetail t1 : src.getContact()) 108 for (ContactPoint t : t1.getTelecom()) 109 tgt.addTelecom(ContactPoint40_50.convertContactPoint(t)); 110 if (src.hasAddress()) 111 tgt.setAddress(Address40_50.convertAddress(src.getAddress())); 112 if (src.hasForm()) 113 tgt.setPhysicalType(CodeableConcept40_50.convertCodeableConcept(src.getForm())); 114 if (src.hasPosition()) 115 tgt.setPosition(convertLocationPositionComponent(src.getPosition())); 116 if (src.hasManagingOrganization()) 117 tgt.setManagingOrganization(Reference40_50.convertReference(src.getManagingOrganization())); 118 if (src.hasPartOf()) 119 tgt.setPartOf(Reference40_50.convertReference(src.getPartOf())); 120// for (org.hl7.fhir.r5.model.Location.LocationHoursOfOperationComponent t : src.getHoursOfOperation()) 121// tgt.addHoursOfOperation(convertLocationHoursOfOperationComponent(t)); 122// if (src.hasAvailabilityExceptions()) 123// tgt.setAvailabilityExceptionsElement(String40_50.convertString(src.getAvailabilityExceptionsElement())); 124 for (org.hl7.fhir.r5.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference40_50.convertReference(t)); 125 return tgt; 126 } 127 128 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Location.LocationStatus> convertLocationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationStatus> src) throws FHIRException { 129 if (src == null || src.isEmpty()) 130 return null; 131 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Location.LocationStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Location.LocationStatusEnumFactory()); 132 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 133 switch (src.getValue()) { 134 case ACTIVE: 135 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationStatus.ACTIVE); 136 break; 137 case SUSPENDED: 138 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationStatus.SUSPENDED); 139 break; 140 case INACTIVE: 141 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationStatus.INACTIVE); 142 break; 143 default: 144 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationStatus.NULL); 145 break; 146 } 147 return tgt; 148 } 149 150 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationStatus> convertLocationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Location.LocationStatus> src) throws FHIRException { 151 if (src == null || src.isEmpty()) 152 return null; 153 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Location.LocationStatusEnumFactory()); 154 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 155 switch (src.getValue()) { 156 case ACTIVE: 157 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationStatus.ACTIVE); 158 break; 159 case SUSPENDED: 160 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationStatus.SUSPENDED); 161 break; 162 case INACTIVE: 163 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationStatus.INACTIVE); 164 break; 165 default: 166 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationStatus.NULL); 167 break; 168 } 169 return tgt; 170 } 171 172 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Location.LocationMode> convertLocationMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationMode> src) throws FHIRException { 173 if (src == null || src.isEmpty()) 174 return null; 175 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Location.LocationMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Location.LocationModeEnumFactory()); 176 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 177 switch (src.getValue()) { 178 case INSTANCE: 179 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationMode.INSTANCE); 180 break; 181 case KIND: 182 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationMode.KIND); 183 break; 184 default: 185 tgt.setValue(org.hl7.fhir.r5.model.Location.LocationMode.NULL); 186 break; 187 } 188 return tgt; 189 } 190 191 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationMode> convertLocationMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Location.LocationMode> src) throws FHIRException { 192 if (src == null || src.isEmpty()) 193 return null; 194 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Location.LocationModeEnumFactory()); 195 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 196 switch (src.getValue()) { 197 case INSTANCE: 198 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationMode.INSTANCE); 199 break; 200 case KIND: 201 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationMode.KIND); 202 break; 203 default: 204 tgt.setValue(org.hl7.fhir.r4.model.Location.LocationMode.NULL); 205 break; 206 } 207 return tgt; 208 } 209 210 public static org.hl7.fhir.r5.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent src) throws FHIRException { 211 if (src == null) 212 return null; 213 org.hl7.fhir.r5.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.r5.model.Location.LocationPositionComponent(); 214 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 215 if (src.hasLongitude()) 216 tgt.setLongitudeElement(Decimal40_50.convertDecimal(src.getLongitudeElement())); 217 if (src.hasLatitude()) 218 tgt.setLatitudeElement(Decimal40_50.convertDecimal(src.getLatitudeElement())); 219 if (src.hasAltitude()) 220 tgt.setAltitudeElement(Decimal40_50.convertDecimal(src.getAltitudeElement())); 221 return tgt; 222 } 223 224 public static org.hl7.fhir.r4.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.r5.model.Location.LocationPositionComponent src) throws FHIRException { 225 if (src == null) 226 return null; 227 org.hl7.fhir.r4.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.r4.model.Location.LocationPositionComponent(); 228 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 229 if (src.hasLongitude()) 230 tgt.setLongitudeElement(Decimal40_50.convertDecimal(src.getLongitudeElement())); 231 if (src.hasLatitude()) 232 tgt.setLatitudeElement(Decimal40_50.convertDecimal(src.getLatitudeElement())); 233 if (src.hasAltitude()) 234 tgt.setAltitudeElement(Decimal40_50.convertDecimal(src.getAltitudeElement())); 235 return tgt; 236 } 237// 238// public static org.hl7.fhir.r5.model.Location.LocationHoursOfOperationComponent convertLocationHoursOfOperationComponent(org.hl7.fhir.r4.model.Location.LocationHoursOfOperationComponent src) throws FHIRException { 239// if (src == null) 240// return null; 241// org.hl7.fhir.r5.model.Location.LocationHoursOfOperationComponent tgt = new org.hl7.fhir.r5.model.Location.LocationHoursOfOperationComponent(); 242// ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 243// tgt.setDaysOfWeek(src.getDaysOfWeek().stream() 244// .map(Location40_50::convertDaysOfWeek) 245// .collect(Collectors.toList())); 246// if (src.hasAllDay()) 247// tgt.setAllDayElement(Boolean40_50.convertBoolean(src.getAllDayElement())); 248// if (src.hasOpeningTime()) 249// tgt.setOpeningTimeElement(Time40_50.convertTime(src.getOpeningTimeElement())); 250// if (src.hasClosingTime()) 251// tgt.setClosingTimeElement(Time40_50.convertTime(src.getClosingTimeElement())); 252// return tgt; 253// } 254// 255// public static org.hl7.fhir.r4.model.Location.LocationHoursOfOperationComponent convertLocationHoursOfOperationComponent(org.hl7.fhir.r5.model.Location.LocationHoursOfOperationComponent src) throws FHIRException { 256// if (src == null) 257// return null; 258// org.hl7.fhir.r4.model.Location.LocationHoursOfOperationComponent tgt = new org.hl7.fhir.r4.model.Location.LocationHoursOfOperationComponent(); 259// ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 260// tgt.setDaysOfWeek(src.getDaysOfWeek().stream() 261// .map(Location40_50::convertDaysOfWeek) 262// .collect(Collectors.toList())); 263// if (src.hasAllDay()) 264// tgt.setAllDayElement(Boolean40_50.convertBoolean(src.getAllDayElement())); 265// if (src.hasOpeningTime()) 266// tgt.setOpeningTimeElement(Time40_50.convertTime(src.getOpeningTimeElement())); 267// if (src.hasClosingTime()) 268// tgt.setClosingTimeElement(Time40_50.convertTime(src.getClosingTimeElement())); 269// return tgt; 270// } 271 272 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.Location.DaysOfWeek> src) throws FHIRException { 273 if (src == null || src.isEmpty()) 274 return null; 275 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()); 276 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 277 switch (src.getValue()) { 278 case MON: 279 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.MON); 280 break; 281 case TUE: 282 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.TUE); 283 break; 284 case WED: 285 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.WED); 286 break; 287 case THU: 288 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.THU); 289 break; 290 case FRI: 291 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.FRI); 292 break; 293 case SAT: 294 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SAT); 295 break; 296 case SUN: 297 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.SUN); 298 break; 299 default: 300 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.DaysOfWeek.NULL); 301 break; 302 } 303 return tgt; 304 } 305 306 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.DaysOfWeek> convertDaysOfWeek(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> src) throws FHIRException { 307 if (src == null || src.isEmpty()) 308 return null; 309 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.DaysOfWeek> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Location.DaysOfWeekEnumFactory()); 310 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 311 switch (src.getValue()) { 312 case MON: 313 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.MON); 314 break; 315 case TUE: 316 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.TUE); 317 break; 318 case WED: 319 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.WED); 320 break; 321 case THU: 322 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.THU); 323 break; 324 case FRI: 325 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.FRI); 326 break; 327 case SAT: 328 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.SAT); 329 break; 330 case SUN: 331 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.SUN); 332 break; 333 default: 334 tgt.setValue(org.hl7.fhir.r4.model.Location.DaysOfWeek.NULL); 335 break; 336 } 337 return tgt; 338 } 339}