This page is part of the FHIR Specification (v4.4.0: R5 Preview #2). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions
The base definition for all elements contained inside a resource. All elements, whether defined as
a Data Type (including primitives) or as part of a resource structure,
have this base content:
Complex data types, that add their own children (all of which are also elements)
BackboneElement, A specialization that adds modifierExtension, which is the super-type of all the element types defined in resource definitions (e.g. Patient.contact)
Note that resources themselves all specialize the base type Resource.
As the base type for all elements included in a resource, Element
is an important structural element of FHIR. Even the primitive types inherit
the base features and representation rules that apply to the Element type.
This constraint exists to reduce syntactical variation in resource contents.
If an element has no children, then it is always omitted from the resource,
as opposed to optionally present without any content.
2.24.0.2.1 XML and JSON Representation of Elements
XML
Elements are represented by an XML element. The name of the element comes from
the context in which it is used, not from the type. The internal id
is represented as an attribute (similar to xml:id, but see below about scope).
Extensions are represented as XML elements. E.g., for example, where the element
is named use:
<use id="[internal id]">
<extension url="..."/>
... if there are any extensions
<extension>
.. elements for sub-type...
</use>
JSON
Elements (except for primitive types, see below) are represented by a JSON
object property. The name of the property comes from
the context in which it is used, not from the type. The internal id
is represented as a JSON string property named "id". Extensions are represented
in a JSON array of objects named "extension". E.g., for example, where the element
is named use:
Note that there are special rules for representation of Primitive types - see below.
2.24.0.2.2 Internal Id Scope
The id property of the element is defined to allow implementers
to build implementation functionality that makes use of internal references
inside the resource. This specification does not define any general use for
the internal id, though some resources (e.g. StructureDefinition) and
extensions (e.g. originalText, narrativeLink) make use of it.
The internal id is unique within the scope of the resource that contains it.
Specifically, this means:
The id SHALL be unique within a given resource
The uniqueness boundary extends into contained resources. i.e. a contained resource cannot have the same id as any element in the resource that contains it or any other contained resource
The uniqueness boundary is broken at Bundle.entry.resource and Parameters.parameter.resource, since these are elements that aggregate different resources
The id element does not have extensions itself
These rules ensure that there is no need to change internal identifiers while exchanging resources.
The base definition for complex elements defined as part of a resource definition - that is, elements that have children that are defined in the resource. Data Type elements do not use this type.
For instance, Patient.contact is an element that is defined as part of the patient resource, so it automatically
has the type BackboneElement.
Note that the descendant types of BackboneElement are all declared implicitly as
part of the definitions of the resources.
2.24.0.6.1 XML and JSON Representation of Primitive Types
XML
The actual primitive value appears as an XML attribute named value.
For example, a property of type code named
status will be represented like this:
<status id="[internal id]" value="[value of code]"">
<extension url="..."/>
<extension>
</status>
JSON
The actual primitive value appears as a JSON string or number property with
the name of the element. If an internal id or extensions are present,
they appear as a JSON object with the name of the primitive value property with
"_" prepended. For example, a property of type code named
status will be represented like this: