We have application which transforms HL7 ADT message to FHIR Bundle . We have AllergyIntolerance Resource which contains property "severity" which accepts enum values of AllergyIntoleranceSeverity.
When we pass AllergyIntoleranceSeverity.NULL value to setSeverity and then do a encodeResource to String of the FHIR Bundle , the severity is set as "?" , expectation is to be set as empty string "".
Why is this happening ?
public static void main(String[] args) {
//creating fhirContext
FhirContext r4Context = FhirContext.forR4();
//create fhir bundle
Bundle bundle = new Bundle();
bundle.setId("bundle-uuid");
// create AllergyIntolerance Fhir Resource
AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
allergyIntolerance.setId("alergy-uuid");
// create reaction property of AllergyIntolerance Resource
AllergyIntolerance.AllergyIntoleranceReactionComponent reaction= new AllergyIntolerance.AllergyIntoleranceReactionComponent();
//AL1-4 = "U"
// if AL1-4 == "U" then as per the code mapping the severity is NULL
reaction.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.NULL);
// add reaction to AllergyIntolerance Resource
allergyIntolerance.addReaction(reaction);
// add AllergyIntolerance Resource to Fhir Bundle
bundle.addEntry().setResource(allergyIntolerance);
// Convert Fhir Bundle to Json String
String fhirJson = r4Context.newJsonParser().encodeResourceToString(bundle);
System.out.println(fhirJson);
}
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-r4</artifactId>
<version>6.6.2</version>
</dependency>
2023-08-03 12:40:54.943 [main] INFO ca.uhn.fhir.util.VersionUtil:? -HAPI FHIR version 6.6.2 - Rev 8d55781507
2023-08-03 12:40:54.986 [main] INFO ca.uhn.fhir.context.FhirContext:? -Creating new FHIR context for FHIR version [R4]
{
"resourceType": "Bundle",
"id": "bundle-uuid",
"entry": [
{
"resource": {
"resourceType": "AllergyIntolerance",
"id": "alergy-uuid",
"reaction": [
{
"severity": "?"
}
]
}
}
]
}
Any input will be helpful .
FHIR does not allow empty fields, so trying to set the severity to an empty string will not work, or if it works, will not result in valid FHIR.
The values possible for the severity field are 'mild', 'moderate' or 'severe', according to the ValueSet that is bound to the field: http://hl7.org/fhir/R4/valueset-reaction-event-severity.html. If you have no value, then you do not set the field.