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