001package org.hl7.fhir.convertors.conv43_50.resources43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Annotation43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.SimpleQuantity43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Decimal43_50; 010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Integer43_50; 011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; 012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 013import org.hl7.fhir.exceptions.FHIRException; 014 015/* 016 Copyright (c) 2011+, HL7, Inc. 017 All rights reserved. 018 019 Redistribution and use in source and binary forms, with or without modification, 020 are permitted provided that the following conditions are met: 021 022 * Redistributions of source code must retain the above copyright notice, this 023 list of conditions and the following disclaimer. 024 * Redistributions in binary form must reproduce the above copyright notice, 025 this list of conditions and the following disclaimer in the documentation 026 and/or other materials provided with the distribution. 027 * Neither the name of HL7 nor the names of its contributors may be used to 028 endorse or promote products derived from this software without specific 029 prior written permission. 030 031 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 032 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 033 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 034 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 035 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 036 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 037 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 038 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 039 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 040 POSSIBILITY OF SUCH DAMAGE. 041 042*/ 043// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 044public class VisionPrescription43_50 { 045 046 public static org.hl7.fhir.r5.model.VisionPrescription convertVisionPrescription(org.hl7.fhir.r4b.model.VisionPrescription src) throws FHIRException { 047 if (src == null) 048 return null; 049 org.hl7.fhir.r5.model.VisionPrescription tgt = new org.hl7.fhir.r5.model.VisionPrescription(); 050 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 051 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 052 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 053 if (src.hasStatus()) 054 tgt.setStatusElement(convertVisionStatus(src.getStatusElement())); 055 if (src.hasCreated()) 056 tgt.setCreatedElement(DateTime43_50.convertDateTime(src.getCreatedElement())); 057 if (src.hasPatient()) 058 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 059 if (src.hasEncounter()) 060 tgt.setEncounter(Reference43_50.convertReference(src.getEncounter())); 061 if (src.hasDateWritten()) 062 tgt.setDateWrittenElement(DateTime43_50.convertDateTime(src.getDateWrittenElement())); 063 if (src.hasPrescriber()) 064 tgt.setPrescriber(Reference43_50.convertReference(src.getPrescriber())); 065 for (org.hl7.fhir.r4b.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent t : src.getLensSpecification()) 066 tgt.addLensSpecification(convertVisionPrescriptionLensSpecificationComponent(t)); 067 return tgt; 068 } 069 070 public static org.hl7.fhir.r4b.model.VisionPrescription convertVisionPrescription(org.hl7.fhir.r5.model.VisionPrescription src) throws FHIRException { 071 if (src == null) 072 return null; 073 org.hl7.fhir.r4b.model.VisionPrescription tgt = new org.hl7.fhir.r4b.model.VisionPrescription(); 074 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 075 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 076 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 077 if (src.hasStatus()) 078 tgt.setStatusElement(convertVisionStatus(src.getStatusElement())); 079 if (src.hasCreated()) 080 tgt.setCreatedElement(DateTime43_50.convertDateTime(src.getCreatedElement())); 081 if (src.hasPatient()) 082 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 083 if (src.hasEncounter()) 084 tgt.setEncounter(Reference43_50.convertReference(src.getEncounter())); 085 if (src.hasDateWritten()) 086 tgt.setDateWrittenElement(DateTime43_50.convertDateTime(src.getDateWrittenElement())); 087 if (src.hasPrescriber()) 088 tgt.setPrescriber(Reference43_50.convertReference(src.getPrescriber())); 089 for (org.hl7.fhir.r5.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent t : src.getLensSpecification()) 090 tgt.addLensSpecification(convertVisionPrescriptionLensSpecificationComponent(t)); 091 return tgt; 092 } 093 094 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> convertVisionStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException { 095 if (src == null || src.isEmpty()) 096 return null; 097 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodesEnumFactory()); 098 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 099 switch (src.getValue()) { 100 case ACTIVE: 101 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ACTIVE); 102 break; 103 case CANCELLED: 104 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.CANCELLED); 105 break; 106 case DRAFT: 107 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.DRAFT); 108 break; 109 case ENTEREDINERROR: 110 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR); 111 break; 112 default: 113 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.NULL); 114 break; 115 } 116 return tgt; 117 } 118 119 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> convertVisionStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException { 120 if (src == null || src.isEmpty()) 121 return null; 122 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodesEnumFactory()); 123 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 124 switch (src.getValue()) { 125 case ACTIVE: 126 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ACTIVE); 127 break; 128 case CANCELLED: 129 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.CANCELLED); 130 break; 131 case DRAFT: 132 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.DRAFT); 133 break; 134 case ENTEREDINERROR: 135 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR); 136 break; 137 default: 138 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.NULL); 139 break; 140 } 141 return tgt; 142 } 143 144 public static org.hl7.fhir.r5.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent convertVisionPrescriptionLensSpecificationComponent(org.hl7.fhir.r4b.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent src) throws FHIRException { 145 if (src == null) 146 return null; 147 org.hl7.fhir.r5.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent tgt = new org.hl7.fhir.r5.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent(); 148 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 149 if (src.hasProduct()) 150 tgt.setProduct(CodeableConcept43_50.convertCodeableConcept(src.getProduct())); 151 if (src.hasEye()) 152 tgt.setEyeElement(convertVisionEyes(src.getEyeElement())); 153 if (src.hasSphere()) 154 tgt.setSphereElement(Decimal43_50.convertDecimal(src.getSphereElement())); 155 if (src.hasCylinder()) 156 tgt.setCylinderElement(Decimal43_50.convertDecimal(src.getCylinderElement())); 157 if (src.hasAxis()) 158 tgt.setAxisElement(Integer43_50.convertInteger(src.getAxisElement())); 159 for (org.hl7.fhir.r4b.model.VisionPrescription.PrismComponent t : src.getPrism()) 160 tgt.addPrism(convertPrismComponent(t)); 161 if (src.hasAdd()) 162 tgt.setAddElement(Decimal43_50.convertDecimal(src.getAddElement())); 163 if (src.hasPower()) 164 tgt.setPowerElement(Decimal43_50.convertDecimal(src.getPowerElement())); 165 if (src.hasBackCurve()) 166 tgt.setBackCurveElement(Decimal43_50.convertDecimal(src.getBackCurveElement())); 167 if (src.hasDiameter()) 168 tgt.setDiameterElement(Decimal43_50.convertDecimal(src.getDiameterElement())); 169 if (src.hasDuration()) 170 tgt.setDuration(SimpleQuantity43_50.convertSimpleQuantity(src.getDuration())); 171 if (src.hasColor()) 172 tgt.setColorElement(String43_50.convertString(src.getColorElement())); 173 if (src.hasBrand()) 174 tgt.setBrandElement(String43_50.convertString(src.getBrandElement())); 175 for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t)); 176 return tgt; 177 } 178 179 public static org.hl7.fhir.r4b.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent convertVisionPrescriptionLensSpecificationComponent(org.hl7.fhir.r5.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent src) throws FHIRException { 180 if (src == null) 181 return null; 182 org.hl7.fhir.r4b.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent tgt = new org.hl7.fhir.r4b.model.VisionPrescription.VisionPrescriptionLensSpecificationComponent(); 183 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 184 if (src.hasProduct()) 185 tgt.setProduct(CodeableConcept43_50.convertCodeableConcept(src.getProduct())); 186 if (src.hasEye()) 187 tgt.setEyeElement(convertVisionEyes(src.getEyeElement())); 188 if (src.hasSphere()) 189 tgt.setSphereElement(Decimal43_50.convertDecimal(src.getSphereElement())); 190 if (src.hasCylinder()) 191 tgt.setCylinderElement(Decimal43_50.convertDecimal(src.getCylinderElement())); 192 if (src.hasAxis()) 193 tgt.setAxisElement(Integer43_50.convertInteger(src.getAxisElement())); 194 for (org.hl7.fhir.r5.model.VisionPrescription.PrismComponent t : src.getPrism()) 195 tgt.addPrism(convertPrismComponent(t)); 196 if (src.hasAdd()) 197 tgt.setAddElement(Decimal43_50.convertDecimal(src.getAddElement())); 198 if (src.hasPower()) 199 tgt.setPowerElement(Decimal43_50.convertDecimal(src.getPowerElement())); 200 if (src.hasBackCurve()) 201 tgt.setBackCurveElement(Decimal43_50.convertDecimal(src.getBackCurveElement())); 202 if (src.hasDiameter()) 203 tgt.setDiameterElement(Decimal43_50.convertDecimal(src.getDiameterElement())); 204 if (src.hasDuration()) 205 tgt.setDuration(SimpleQuantity43_50.convertSimpleQuantity(src.getDuration())); 206 if (src.hasColor()) 207 tgt.setColorElement(String43_50.convertString(src.getColorElement())); 208 if (src.hasBrand()) 209 tgt.setBrandElement(String43_50.convertString(src.getBrandElement())); 210 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t)); 211 return tgt; 212 } 213 214 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.VisionPrescription.VisionEyes> convertVisionEyes(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.VisionPrescription.VisionEyes> src) throws FHIRException { 215 if (src == null || src.isEmpty()) 216 return null; 217 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.VisionPrescription.VisionEyes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.VisionPrescription.VisionEyesEnumFactory()); 218 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 219 switch (src.getValue()) { 220 case RIGHT: 221 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionEyes.RIGHT); 222 break; 223 case LEFT: 224 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionEyes.LEFT); 225 break; 226 default: 227 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionEyes.NULL); 228 break; 229 } 230 return tgt; 231 } 232 233 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.VisionPrescription.VisionEyes> convertVisionEyes(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.VisionPrescription.VisionEyes> src) throws FHIRException { 234 if (src == null || src.isEmpty()) 235 return null; 236 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.VisionPrescription.VisionEyes> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.VisionPrescription.VisionEyesEnumFactory()); 237 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 238 switch (src.getValue()) { 239 case RIGHT: 240 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionEyes.RIGHT); 241 break; 242 case LEFT: 243 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionEyes.LEFT); 244 break; 245 default: 246 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionEyes.NULL); 247 break; 248 } 249 return tgt; 250 } 251 252 public static org.hl7.fhir.r5.model.VisionPrescription.PrismComponent convertPrismComponent(org.hl7.fhir.r4b.model.VisionPrescription.PrismComponent src) throws FHIRException { 253 if (src == null) 254 return null; 255 org.hl7.fhir.r5.model.VisionPrescription.PrismComponent tgt = new org.hl7.fhir.r5.model.VisionPrescription.PrismComponent(); 256 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 257 if (src.hasAmount()) 258 tgt.setAmountElement(Decimal43_50.convertDecimal(src.getAmountElement())); 259 if (src.hasBase()) 260 tgt.setBaseElement(convertVisionBase(src.getBaseElement())); 261 return tgt; 262 } 263 264 public static org.hl7.fhir.r4b.model.VisionPrescription.PrismComponent convertPrismComponent(org.hl7.fhir.r5.model.VisionPrescription.PrismComponent src) throws FHIRException { 265 if (src == null) 266 return null; 267 org.hl7.fhir.r4b.model.VisionPrescription.PrismComponent tgt = new org.hl7.fhir.r4b.model.VisionPrescription.PrismComponent(); 268 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 269 if (src.hasAmount()) 270 tgt.setAmountElement(Decimal43_50.convertDecimal(src.getAmountElement())); 271 if (src.hasBase()) 272 tgt.setBaseElement(convertVisionBase(src.getBaseElement())); 273 return tgt; 274 } 275 276 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.VisionPrescription.VisionBase> convertVisionBase(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.VisionPrescription.VisionBase> src) throws FHIRException { 277 if (src == null || src.isEmpty()) 278 return null; 279 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.VisionPrescription.VisionBase> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.VisionPrescription.VisionBaseEnumFactory()); 280 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 281 switch (src.getValue()) { 282 case UP: 283 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionBase.UP); 284 break; 285 case DOWN: 286 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionBase.DOWN); 287 break; 288 case IN: 289 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionBase.IN); 290 break; 291 case OUT: 292 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionBase.OUT); 293 break; 294 default: 295 tgt.setValue(org.hl7.fhir.r5.model.VisionPrescription.VisionBase.NULL); 296 break; 297 } 298 return tgt; 299 } 300 301 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.VisionPrescription.VisionBase> convertVisionBase(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.VisionPrescription.VisionBase> src) throws FHIRException { 302 if (src == null || src.isEmpty()) 303 return null; 304 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.VisionPrescription.VisionBase> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.VisionPrescription.VisionBaseEnumFactory()); 305 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 306 switch (src.getValue()) { 307 case UP: 308 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionBase.UP); 309 break; 310 case DOWN: 311 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionBase.DOWN); 312 break; 313 case IN: 314 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionBase.IN); 315 break; 316 case OUT: 317 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionBase.OUT); 318 break; 319 default: 320 tgt.setValue(org.hl7.fhir.r4b.model.VisionPrescription.VisionBase.NULL); 321 break; 322 } 323 return tgt; 324 } 325}