Notes on FHIR extensions

Russell Bateman
February 2024
last update:



"This exchange specification is based on generally agreed common requirements across healthcare—covering many jurisdictions, domains, and different functional approaches. It is common for specific implementations to have valid requirements that are not part of these agreed common requirements. Incorporating all valid requirements would make this specification very cumbersome and difficult to implement. Instead, this specification expects that additional valid requirements will be implemented as extensions.

"As such, extensibility is a fundamental part of the design of this specification. Every element in a resource can have extension child elements to represent additional information that is not part of the basic definition of the resource. Applications should not reject resources merely because they contain extensions, though they may need to reject resources because of the specific contents of the extensions."

There is no stigma attached to the use or non-use of extensions by any FHIR application or project.

In summary, extensions are used to inject information, data, etc. into the FHIR resource that has no other supported or standard representation in FHIR.

Extensions fall immediately after any id:

public class Element
{
  String                  id;
  List< Extension > extension;
}

Example:

<Patient>
  <id value="..." />
  <extension url="...">
    ...
  </extension>
  ...
</Patient>

...and are composed thus:

public class Extension
{
  String                  url;
  List< Extension > extension;
}

Example(s):

  <extension url="...">
    <extension url="...">
      <valueCoding>
        <system value="typically a URL" />
        <code value="..." />
        <display value="(human-readable value/name)" />
      </valueCoding>
    </extension>
  </extension>

  <extension url="...">
      <valueCode value="...">
  </extension>

Race: a real-world example:

<extension url="http://hl7.org/fhir/us/core/StructureDefinition/us-core-race">
  <extension url="ombCategory">
    <valueCoding>
      <system value="urn:oid:2.16.840.1.113883.6.238"/>
      <code value="2106-3"/>
      <display value="White"/>
    </valueCoding>
  </extension>
  <extension url="text">
    <valueString value="White"/>
  </extension>
</extension>

A "third-party" extension:

<extension url="http://synthetichealth.github.io/synthea/quality-adjusted-life-years">
  <valueDecimal value="24.798958438190017"/>
</extension>