#14. Unexpected status values not handled

Over half of all FHIR resource types have a mandatory status element. It’s heavily used in search queries to filter results, and in code to determine courses of action. Many resources have their own set of statuses with different meanings, all of which need to be handled by consuming applications.

They almost never are.

Applications make assumptions, often based on happy-path scenarios. These assumptions can lead developers to the conclusion that only a small subset of status values is expected or valid. This in turn leads to resources not being returned in search queries, and to system crashes or silent failures when perfectly valid but unexpected statuses are encountered.

Here’s an example from a real-world application.

A DiagnosticReport was produced on the back of a series of physician findings and blood test results. The resource was created with a preliminary status while the patient was present and moved to a final status only when the blood test results were returned and recorded days later.

Screens were built and PDFs produced around these two statuses. Everything worked until a doctor made a change to the report after it was finalized, correctly moving the resource status to amended. Report screens failed to load the amended report as its status now fell outside the expected values, and the PDF document was missing sections as the rendering code fell over.

The DiagnosticReport resource is a good example, as it contains a number of status values with precise meaning that are often not catered for by consuming applications. Examples are corrected and appended, each of which has a different meaning to amended and can occur after a report is finalized.

A common status value across resource types is entered-in-error. Applications that expect a given set of statuses may never check for this value, assuming that all resources will always contain one of the anticipated statuses.

In happy-path scenarios, they will. In production scenarios, they may not. At which point the data being displayed or actioned in code is incomplete, incorrect or invalid.

Check that your code understands and can handle all statuses in some way. Check that search queries do not unintentionally exclude resources with unexpected statuses.

---

Download my “FHIR Architecture Decisions” book

FHIR Weekly

Join 1,100+ business and technical leaders.