FHIR’s Data Absent Reason Extension

A FHIR element with a minimum cardinality of 1 is mandatory. There must be at least one.

Very few elements in FHIR resources are mandatory — it’s a forgiving standard. The few elements that are mandatory make logical sense to be so.

Here are some examples:

  • A Procedure must have a “subject”
  • A MedicationRequest must have a “medication”
  • A Claim must have a “provider”
  • Many resources must have a “status”

If any of these mandatory elements are missing, a create or update request will fail as the resource will be non-conformant.

I’d like to say it really is that simple and that you can always rely on mandatory elements to be populated as expected. But FHIR is a real-world standard where the unexpected happens all the time.

A Procedure might not have a recognizable subject if the data is masked for some reason.

A MediactionRequest might not have a medication if the source system suffered an error and was unable to provide it.

In these and other situations it is perfectly valid to populate the mandatory element for which the data is missing with a “Data Absent Reason” extension.

This is an official HL7 extension that can be used on any element on any resource in FHIR. Its presence “Provides a reason why the expected value or elements in the element are missing.”

That reason is a “code” taken from a predefined set of codes. Here’s the ValueSet.

Back to our Procedure without a subject. Here’s an example that does NOT fail validation and is fully conformant — even though the subject is missing.

Github

The lesson here is that if you’re building an application that depends on mandatory elements being populated with expected values, you could be in for a surprise.

Unless you have full control over the data flow you should build and code defensively and expect the unexpected.

The extension: https://www.hl7.org/fhir/R4/extension-data-absent-reason.html

---

Ways to Work With Me

Discover more from Darren Devitt

Subscribe now to keep reading and get access to the full archive.

Continue reading