001package org.hl7.fhir.convertors.conv10_30.resources10_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_30; 004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Extension10_30; 005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30; 006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Annotation10_30; 007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.CodeableConcept10_30; 008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Identifier10_30; 009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.DateTime10_30; 010import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 011import org.hl7.fhir.dstu2.model.AllergyIntolerance; 012import org.hl7.fhir.exceptions.FHIRException; 013 014public class AllergyIntolerance10_30 { 015 public static org.hl7.fhir.dstu3.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.dstu2.model.AllergyIntolerance src) throws FHIRException { 016 if (src == null) 017 return null; 018 org.hl7.fhir.dstu3.model.AllergyIntolerance tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance(); 019 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 020 for (org.hl7.fhir.dstu2.model.Identifier identifier : src.getIdentifier()) 021 tgt.addIdentifier(Identifier10_30.convertIdentifier(identifier)); 022 if (src.hasOnset()) 023 tgt.setOnset(DateTime10_30.convertDateTime(src.getOnsetElement())); 024 if (src.hasRecordedDate()) 025 tgt.setAssertedDateElement(DateTime10_30.convertDateTime(src.getRecordedDateElement())); 026 if (src.hasRecorder()) 027 tgt.setRecorder(Reference10_30.convertReference(src.getRecorder())); 028 if (src.hasPatient()) 029 tgt.setPatient(Reference10_30.convertReference(src.getPatient())); 030 if (src.hasReporter()) 031 tgt.setAsserter(Reference10_30.convertReference(src.getReporter())); 032 if (src.hasSubstance()) 033 tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getSubstance())); 034 if (src.hasStatus()) { 035 if (src.getStatus() != org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceStatus.REFUTED 036 && src.getStatus() != org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceStatus.ENTEREDINERROR) { 037 tgt.setClinicalStatus(translateAllergyIntoleranceClinicalStatus(src.getStatus())); 038 } 039 if (src.getStatus() != org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceStatus.ACTIVE 040 && src.getStatus() != org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceStatus.RESOLVED) { 041 tgt.setVerificationStatus(translateAllergyIntoleranceVerificationStatus(src.getStatus())); 042 } 043 } 044 if (src.hasCriticality()) 045 tgt.setCriticality(translateAllergyIntoleranceCriticality(src.getCriticality())); 046 if (src.hasType()) 047 tgt.setType(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.fromCode(src.getType().toCode())); 048 if (src.hasCategory()) 049 tgt.addCategory(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.fromCode(src.getCategory().toCode())); 050 if (src.hasLastOccurence()) 051 tgt.setLastOccurrenceElement(DateTime10_30.convertDateTime(src.getLastOccurenceElement())); 052 if (src.hasNote()) 053 tgt.addNote(Annotation10_30.convertAnnotation(src.getNote())); 054 for (org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceReactionComponent reaction : src.getReaction()) 055 tgt.addReaction(algReaction(reaction)); 056 return tgt; 057 } 058 059 private static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent algReaction(AllergyIntolerance.AllergyIntoleranceReactionComponent src) { 060 if (src == null) 061 return null; 062 org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent(); 063 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 064 for (org.hl7.fhir.dstu2.model.Extension extension : src.getModifierExtension()) 065 tgt.addExtension(Extension10_30.convertExtension(extension)); 066 if (src.hasSubstance()) 067 tgt.setSubstance(CodeableConcept10_30.convertCodeableConcept(src.getSubstance())); 068 if (src.hasCertainty()) 069 tgt.addExtension(new org.hl7.fhir.dstu3.model.Extension( 070 "http://hl7.org/fhir/AllergyIntolerance-r2-certainty", 071 new org.hl7.fhir.dstu3.model.StringType(src.getCertainty().toCode()) 072 )); 073 for (org.hl7.fhir.dstu2.model.CodeableConcept concept : src.getManifestation()) 074 tgt.addManifestation(CodeableConcept10_30.convertCodeableConcept(concept)); 075 if (src.hasDescription()) 076 tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 077 if (src.hasOnset()) 078 tgt.setOnsetElement(DateTime10_30.convertDateTime(src.getOnsetElement())); 079 if (src.hasSeverity()) 080 tgt.setSeverity(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.fromCode(src.getSeverity().toCode())); 081 if (src.hasExposureRoute()) 082 tgt.setExposureRoute(CodeableConcept10_30.convertCodeableConcept(src.getExposureRoute())); 083 if (src.hasNote()) 084 tgt.addNote(Annotation10_30.convertAnnotation(src.getNote())); 085 return tgt; 086 } 087 088 public static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus translateAllergyIntoleranceVerificationStatus(org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceStatus src) { 089 switch (src) { 090 case UNCONFIRMED: 091 case INACTIVE: 092 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.UNCONFIRMED; 093 case CONFIRMED: 094 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.CONFIRMED; 095 case REFUTED: 096 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.REFUTED; 097 case ENTEREDINERROR: 098 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.ENTEREDINERROR; 099 default: 100 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.NULL; 101 } 102 } 103 104 public static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus translateAllergyIntoleranceClinicalStatus(org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceStatus src) { 105 switch (src) { 106 case ACTIVE: 107 case UNCONFIRMED: 108 case CONFIRMED: 109 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE; 110 case INACTIVE: 111 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.INACTIVE; 112 case RESOLVED: 113 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.RESOLVED; 114 default: 115 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.NULL; 116 } 117 } 118 119 public static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality translateAllergyIntoleranceCriticality(org.hl7.fhir.dstu2.model.AllergyIntolerance.AllergyIntoleranceCriticality src) { 120 switch (src) { 121 case CRITL: 122 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.LOW; 123 case CRITH: 124 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.HIGH; 125 case CRITU: 126 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS; 127 default: 128 return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.NULL; 129 } 130 } 131 132}