
001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import java.util.stream.Collectors; 004 005import org.hl7.fhir.convertors.context.ConversionContext30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Annotation30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50; 011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 012import org.hl7.fhir.exceptions.FHIRException; 013import org.hl7.fhir.r5.model.*; 014import org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceParticipantComponent; 015 016public class AllergyIntolerance30_50 { 017 018 public static org.hl7.fhir.dstu3.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.r5.model.AllergyIntolerance src) throws FHIRException { 019 if (src == null) 020 return null; 021 org.hl7.fhir.dstu3.model.AllergyIntolerance tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance(); 022 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 023 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 024 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 025 if (src.hasClinicalStatus()) 026 tgt.setClinicalStatus(convertAllergyIntoleranceClinicalStatus(src.getClinicalStatus())); 027 if (src.hasVerificationStatus()) 028 tgt.setVerificationStatus(convertAllergyIntoleranceVerificationStatus(src.getVerificationStatus())); 029 if (src.hasType()) 030 tgt.setTypeElement(convertAllergyIntoleranceType(src.getType())); 031 tgt.setCategory(src.getCategory().stream() 032 .map(AllergyIntolerance30_50::convertAllergyIntoleranceCategory) 033 .collect(Collectors.toList())); 034 if (src.hasCriticality()) 035 tgt.setCriticalityElement(convertAllergyIntoleranceCriticality(src.getCriticalityElement())); 036 if (src.hasCode()) 037 tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 038 if (src.hasPatient()) 039 tgt.setPatient(Reference30_50.convertReference(src.getPatient())); 040 if (src.hasOnset()) 041 tgt.setOnset(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getOnset())); 042 if (src.hasRecordedDate()) 043 tgt.setAssertedDateElement(DateTime30_50.convertDateTime(src.getRecordedDateElement())); 044 for (AllergyIntoleranceParticipantComponent t : src.getParticipant()) { 045 if (t.getFunction().hasCoding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "author")) 046 tgt.setRecorder(Reference30_50.convertReference(t.getActor())); 047 if (t.getFunction().hasCoding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "attester")) 048 tgt.setAsserter(Reference30_50.convertReference(t.getActor())); 049 } 050 if (src.hasLastOccurrence()) 051 tgt.setLastOccurrenceElement(DateTime30_50.convertDateTime(src.getLastOccurrenceElement())); 052 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 053 for (org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceReactionComponent t : src.getReaction()) 054 tgt.addReaction(convertAllergyIntoleranceReactionComponent(t)); 055 return tgt; 056 } 057 058 public static org.hl7.fhir.r5.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance src) throws FHIRException { 059 if (src == null) 060 return null; 061 org.hl7.fhir.r5.model.AllergyIntolerance tgt = new org.hl7.fhir.r5.model.AllergyIntolerance(); 062 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 063 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 064 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 065 if (src.hasClinicalStatus()) 066 tgt.setClinicalStatus(convertAllergyIntoleranceClinicalStatus(src.getClinicalStatus())); 067 if (src.hasVerificationStatus()) 068 tgt.setVerificationStatus(convertAllergyIntoleranceVerificationStatus(src.getVerificationStatus())); 069 if (src.hasType()) 070 tgt.setType(convertAllergyIntoleranceType(src.getTypeElement())); 071 tgt.setCategory(src.getCategory().stream() 072 .map(AllergyIntolerance30_50::convertAllergyIntoleranceCategory) 073 .collect(Collectors.toList())); 074 if (src.hasCriticality()) 075 tgt.setCriticalityElement(convertAllergyIntoleranceCriticality(src.getCriticalityElement())); 076 if (src.hasCode()) 077 tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 078 if (src.hasPatient()) 079 tgt.setPatient(Reference30_50.convertReference(src.getPatient())); 080 if (src.hasOnset()) 081 tgt.setOnset(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getOnset())); 082 if (src.hasAssertedDate()) 083 tgt.setRecordedDateElement(DateTime30_50.convertDateTime(src.getAssertedDateElement())); 084 if (src.hasRecorder()) 085 tgt.addParticipant(new AllergyIntoleranceParticipantComponent() 086 .setFunction(new CodeableConcept().addCoding(new Coding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "author", "Author"))) 087 .setActor(Reference30_50.convertReference(src.getRecorder()))); 088 if (src.hasAsserter()) 089 tgt.addParticipant(new AllergyIntoleranceParticipantComponent() 090 .setFunction(new CodeableConcept().addCoding(new Coding("http://terminology.hl7.org/CodeSystem/provenance-participant-type", "attester", "Attester"))) 091 .setActor(Reference30_50.convertReference(src.getRecorder()))); 092 if (src.hasLastOccurrence()) 093 tgt.setLastOccurrenceElement(DateTime30_50.convertDateTime(src.getLastOccurrenceElement())); 094 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 095 for (org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent t : src.getReaction()) 096 tgt.addReaction(convertAllergyIntoleranceReactionComponent(t)); 097 return tgt; 098 } 099 100 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceCategory> convertAllergyIntoleranceCategory(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> src) throws FHIRException { 101 if (src == null || src.isEmpty()) 102 return null; 103 Enumeration<AllergyIntolerance.AllergyIntoleranceCategory> tgt = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory()); 104 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 105 if (src.getValue() == null) { 106 tgt.setValue(null); 107 } else { 108 switch (src.getValue()) { 109 case FOOD: 110 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCategory.FOOD); 111 break; 112 case MEDICATION: 113 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION); 114 break; 115 case ENVIRONMENT: 116 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT); 117 break; 118 case BIOLOGIC: 119 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCategory.BIOLOGIC); 120 break; 121 default: 122 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCategory.NULL); 123 break; 124 } 125 } 126 return tgt; 127 } 128 129 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> convertAllergyIntoleranceCategory(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceCategory> src) throws FHIRException { 130 if (src == null || src.isEmpty()) 131 return null; 132 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory()); 133 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 134 if (src.getValue() == null) { 135 tgt.setValue(null); 136 } else { 137 switch (src.getValue()) { 138 case FOOD: 139 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.FOOD); 140 break; 141 case MEDICATION: 142 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION); 143 break; 144 case ENVIRONMENT: 145 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT); 146 break; 147 case BIOLOGIC: 148 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.BIOLOGIC); 149 break; 150 default: 151 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.NULL); 152 break; 153 } 154 } 155 return tgt; 156 } 157 158 static public org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus convertAllergyIntoleranceClinicalStatus(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { 159 if (src == null) 160 return null; 161 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "active")) 162 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE; 163 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "inactive")) 164 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.INACTIVE; 165 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "resolved")) 166 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.RESOLVED; 167 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.NULL; 168 } 169 170 static public org.hl7.fhir.r5.model.CodeableConcept convertAllergyIntoleranceClinicalStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus src) throws FHIRException { 171 if (src == null) 172 return null; 173 switch (src) { 174 case ACTIVE: 175 return new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical").setCode("active")); 176 case INACTIVE: 177 return new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical").setCode("inactive")); 178 case RESOLVED: 179 new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical").setCode("resolved")); 180 default: 181 return null; 182 } 183 } 184 185 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality> convertAllergyIntoleranceCriticality(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceCriticality> src) throws FHIRException { 186 if (src == null || src.isEmpty()) 187 return null; 188 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticalityEnumFactory()); 189 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 190 if (src.getValue() == null) { 191 tgt.setValue(null); 192 } else { 193 switch (src.getValue()) { 194 case LOW: 195 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.LOW); 196 break; 197 case HIGH: 198 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.HIGH); 199 break; 200 case UNABLETOASSESS: 201 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS); 202 break; 203 default: 204 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.NULL); 205 break; 206 } 207 } 208 return tgt; 209 } 210 211 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceCriticality> convertAllergyIntoleranceCriticality(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality> src) throws FHIRException { 212 if (src == null || src.isEmpty()) 213 return null; 214 Enumeration<AllergyIntolerance.AllergyIntoleranceCriticality> tgt = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCriticalityEnumFactory()); 215 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 216 if (src.getValue() == null) { 217 tgt.setValue(null); 218 } else { 219 switch (src.getValue()) { 220 case LOW: 221 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCriticality.LOW); 222 break; 223 case HIGH: 224 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCriticality.HIGH); 225 break; 226 case UNABLETOASSESS: 227 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS); 228 break; 229 default: 230 tgt.setValue(AllergyIntolerance.AllergyIntoleranceCriticality.NULL); 231 break; 232 } 233 } 234 return tgt; 235 } 236 237 public static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent convertAllergyIntoleranceReactionComponent(org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceReactionComponent src) throws FHIRException { 238 if (src == null) 239 return null; 240 org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent(); 241 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 242 if (src.hasSubstance()) 243 tgt.setSubstance(CodeableConcept30_50.convertCodeableConcept(src.getSubstance())); 244 for (CodeableReference t : src.getManifestation()) 245 if (t.hasConcept()) tgt.addManifestation(CodeableConcept30_50.convertCodeableConcept(t.getConcept())); 246 if (src.hasDescription()) 247 tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement())); 248 if (src.hasOnset()) 249 tgt.setOnsetElement(DateTime30_50.convertDateTime(src.getOnsetElement())); 250 if (src.hasSeverity()) 251 tgt.setSeverityElement(convertAllergyIntoleranceSeverity(src.getSeverityElement())); 252 if (src.hasExposureRoute()) 253 tgt.setExposureRoute(CodeableConcept30_50.convertCodeableConcept(src.getExposureRoute())); 254 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 255 return tgt; 256 } 257 258 public static org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceReactionComponent convertAllergyIntoleranceReactionComponent(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent src) throws FHIRException { 259 if (src == null) 260 return null; 261 org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceReactionComponent(); 262 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 263 if (src.hasSubstance()) 264 tgt.setSubstance(CodeableConcept30_50.convertCodeableConcept(src.getSubstance())); 265 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getManifestation()) 266 tgt.addManifestation(new CodeableReference(CodeableConcept30_50.convertCodeableConcept(t))); 267 if (src.hasDescription()) 268 tgt.setDescriptionElement(String30_50.convertString(src.getDescriptionElement())); 269 if (src.hasOnset()) 270 tgt.setOnsetElement(DateTime30_50.convertDateTime(src.getOnsetElement())); 271 if (src.hasSeverity()) 272 tgt.setSeverityElement(convertAllergyIntoleranceSeverity(src.getSeverityElement())); 273 if (src.hasExposureRoute()) 274 tgt.setExposureRoute(CodeableConcept30_50.convertCodeableConcept(src.getExposureRoute())); 275 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t)); 276 return tgt; 277 } 278 279 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceSeverity> convertAllergyIntoleranceSeverity(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity> src) throws FHIRException { 280 if (src == null || src.isEmpty()) 281 return null; 282 Enumeration<AllergyIntolerance.AllergyIntoleranceSeverity> tgt = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceSeverityEnumFactory()); 283 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 284 if (src.getValue() == null) { 285 tgt.setValue(null); 286 } else { 287 switch (src.getValue()) { 288 case MILD: 289 tgt.setValue(AllergyIntolerance.AllergyIntoleranceSeverity.MILD); 290 break; 291 case MODERATE: 292 tgt.setValue(AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE); 293 break; 294 case SEVERE: 295 tgt.setValue(AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE); 296 break; 297 default: 298 tgt.setValue(AllergyIntolerance.AllergyIntoleranceSeverity.NULL); 299 break; 300 } 301 } 302 return tgt; 303 } 304 305 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity> convertAllergyIntoleranceSeverity(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AllergyIntolerance.AllergyIntoleranceSeverity> src) throws FHIRException { 306 if (src == null || src.isEmpty()) 307 return null; 308 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverityEnumFactory()); 309 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 310 if (src.getValue() == null) { 311 tgt.setValue(null); 312 } else { 313 switch (src.getValue()) { 314 case MILD: 315 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.MILD); 316 break; 317 case MODERATE: 318 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE); 319 break; 320 case SEVERE: 321 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE); 322 break; 323 default: 324 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.NULL); 325 break; 326 } 327 } 328 return tgt; 329 } 330 331 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType> convertAllergyIntoleranceType(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { 332 if (src == null || src.isEmpty()) 333 return null; 334 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceTypeEnumFactory()); 335 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 336 if (src.hasCoding("http://hl7.org/fhir/allergy-intolerance-type", "allergy")) { 337 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.ALLERGY); 338 } else if (src.hasCoding("http://hl7.org/fhir/allergy-intolerance-type", "intolerance")) { 339 tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.INTOLERANCE); 340 } 341 return tgt; 342 } 343 344 static public org.hl7.fhir.r5.model.CodeableConcept convertAllergyIntoleranceType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType> src) throws FHIRException { 345 if (src == null || src.isEmpty()) 346 return null; 347 CodeableConcept tgt = new CodeableConcept(); 348 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 349 if (src.getValue() == null) { 350 // Add nothing 351 } else { 352 switch (src.getValue()) { 353 case ALLERGY: 354 tgt.addCoding("http://hl7.org/fhir/allergy-intolerance-type", "allergy", "Allergy"); 355 break; 356 case INTOLERANCE: 357 tgt.addCoding("http://hl7.org/fhir/allergy-intolerance-type", "intolerance", "Intolerance"); 358 break; 359 default: 360 break; 361 } 362 } 363 return tgt; 364 } 365 366 static public org.hl7.fhir.r5.model.CodeableConcept convertAllergyIntoleranceVerificationStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus src) throws FHIRException { 367 if (src == null) 368 return null; 369 switch (src) { 370 case UNCONFIRMED: 371 return new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("unconfirmed")); 372 case CONFIRMED: 373 return new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("confirmed")); 374 case REFUTED: 375 return new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("refuted")); 376 case ENTEREDINERROR: 377 return new org.hl7.fhir.r5.model.CodeableConcept(new org.hl7.fhir.r5.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("entered-in-error")); 378 default: 379 return null; 380 } 381 } 382 383 static public org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus convertAllergyIntoleranceVerificationStatus(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { 384 if (src == null) 385 return null; 386 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "unconfirmed")) 387 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.UNCONFIRMED; 388 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "confirmed")) 389 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.CONFIRMED; 390 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "refuted")) 391 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.REFUTED; 392 if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "entered-in-error")) 393 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.ENTEREDINERROR; 394 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.NULL; 395 } 396}