This is the Continuous Integration Build of FHIR (will be incorrect/inconsistent at times).
See the Directory of published versions
FHIR Infrastructure ![]() |
Maturity Level: Normative | Standards Status: Normative |
Types Framework Cross Reference: Base Types | Datatypes | Resources | Patterns
The definition of an element in a resource or an extension. The definition includes:
The ElementDefinition type is the core of the FHIR metadata layer, and is closely (conceptually) aligned to ISO 11179. All the data elements defined in this specification are published as a collection of data elements (XML or JSON).
ElementDefinition is used in StructureDefinition
Constraints
id | Level | Location | Description | Expression |
![]() |
Rule | (base) | Min <= Max | min.empty() or max.empty() or (max = '*') or iif(max != '*', min <= max.toInteger()) |
![]() |
Rule | ElementDefinition.max | Max SHALL be a number or "*" | empty() or ($this = '*') or (toInteger() >= 0) |
![]() |
Rule | ElementDefinition.type | Aggregation may only be specified if one of the allowed types for the element is a reference | aggregation.empty() or (code = 'Reference') or (code = 'canonical') or (code = 'CodeableReference') |
![]() |
Rule | (base) | if the element definition has a contentReference, it cannot have type, defaultValue, fixed, pattern, example, minValue, maxValue, maxLength, or binding | contentReference.empty() or (type.empty() and defaultValue.empty() and fixed.empty() and pattern.empty() and example.empty() and minValue.empty() and maxValue.empty() and maxLength.empty() and binding.empty()) |
![]() |
Rule | (base) | Fixed value may only be specified if there is one type | fixed.empty() or (type.count() <= 1) |
![]() |
Rule | (base) | Pattern may only be specified if there is one type | pattern.empty() or (type.count() <= 1) |
![]() |
Rule | (base) | Pattern and fixed are mutually exclusive | pattern.empty() or fixed.empty() |
![]() |
Rule | (base) | Binding can only be present for coded elements, string, and uri if using FHIR-defined types | binding.empty() or type.code.empty() or type.code.contains(':') or type.select((code = 'code') or (code = 'Coding') or (code='CodeableConcept') or (code = 'Quantity') or (code = 'string') or (code = 'uri') or (code = 'Duration')).exists() |
![]() |
Rule | ElementDefinition.binding | ValueSet SHALL start with http:// or https:// or urn: or # | valueSet.exists() implies (valueSet.startsWith('http:') or valueSet.startsWith('https') or valueSet.startsWith('urn:') or valueSet.startsWith('#')) |
![]() |
Rule | (base) | Types must be unique by code | type.select(code).isDistinct() |
![]() |
Rule | (base) | Constraints must be unique by key | constraint.select(key).isDistinct() |
![]() |
Rule | (base) | default value and meaningWhenMissing are mutually exclusive | defaultValue.empty() or meaningWhenMissing.empty() |
![]() |
Rule | (base) | sliceName must be composed of proper tokens separated by "/" | sliceName.empty() or sliceName.matches('^[a-zA-Z0-9\\/\\-_\\[\\]\\@]+$') |
![]() |
Rule | ElementDefinition.type | targetProfile is only allowed if the type is Reference or canonical | (code='Reference' or code = 'canonical' or code = 'CodeableReference') or targetProfile.empty() |
![]() |
Rule | (base) | Must have a modifier reason if isModifier = true | (isModifier.exists() and isModifier) implies isModifierReason.exists() |
![]() |
Rule | (base) | Element path SHALL be expressed as a set of '.'-separated components with each component restricted to a maximum of 64 characters and with some limits on the allowed choice of characters | path.matches('^[^\\s\\.,:;\\\'"\\/|?!@#$%&*()\\[\\]{}]{1,64}(\\.[^\\s\\.,:;\\\'"\\/|?!@#$%&*()\\[\\]{}]{1,64}(\\[x\\])?(\\:[^\\s\\.]+)?)*$') |
![]() |
Warning | (base) | The first component of the path should be UpperCamelCase. Additional components (following a '.') should be lowerCamelCase. If this syntax is not adhered to, code generation tools may be broken. Logical models may be less concerned about this implication. | path.matches('^[A-Za-z][A-Za-z0-9]{0,63}(\\.[a-z][A-Za-z0-9]{0,63}(\\[x])?)*$') |
![]() |
Warning | ElementDefinition.constraint | Constraints should have an expression or else validators will not be able to enforce them | expression.exists() |
![]() |
Rule | (base) | sliceIsConstraining can only appear if slicename is present | sliceIsConstraining.exists() implies sliceName.exists() |
![]() |
Rule | ElementDefinition.binding | binding SHALL have either description or valueSet | description.exists() or valueSet.exists() |
![]() |
Guideline | (base) | pattern[x] should be used rather than fixed[x] | fixed.exists().not() This is (only) a best practice guideline because:
|
![]() |
Warning | (base) | Order has no meaning (and cannot be asserted to have meaning), so enforcing rules on order is improper | orderMeaning.empty() implies slicing.where(rules='openAtEnd' or ordered).exists().not() |
![]() |
Rule | ElementDefinition.constraint | Errors cannot be suppressed | (severity = 'error') implies suppress.empty() |
![]() |
Warning | (base) | Mappings SHOULD be unique by key | mapping.select(identity).isDistinct() |
![]() |
Rule | (base) | Can't have valueAlternatives if mustHaveValue is true | mustHaveValue.value implies valueAlternatives.empty() |
![]() |
Warning | ElementDefinition.type | profiles SHOULD be unique | profile.isDistinct() |
![]() |
Warning | ElementDefinition.type | targetProfiles SHOULD be unique | targetProfile.isDistinct() |
![]() |
Guideline | ElementDefinition.binding.additional | additionalBindings should have a key | key.exists() This is (only) a best practice guideline because:
|
![]() |
Rule | ElementDefinition.binding | If the strength is 'descriptive' no value set can ve provided | strength = 'descriptive' implies valueSet.empty() |
![]() |
Warning | (base) | If there's more than one bindable type, it's usually an error for there to be a binding | type.where(code in 'code' | 'Coding' | 'CodeableConcept' | 'CodeableReference' | 'uri' | 'string' | 'Quantity').count() > 1 implies binding.empty() |
![]() |
Guideline | ElementDefinition.binding | if there's a required binding with no usage, it should be the base binding | strength != 'required' implies additional.where(purpose = 'required' and usage.empty()).empty() This is (only) a best practice guideline because:
|
The path
element is the most important property of the element definition.
It both names the element, and locates the element within a hierarchy defined within a
particular context. Within the FHIR specification, there is only one original definition
for each path. This is the master definition to which all the other definitions with the
same path must conform.
All elements defined within the FHIR specification itself are defined within a StructureDefinition that defines a resource, or a datatype. This defines the identity of the element and provides the context in which the meaning of the element is understood. When Elements are defined, the following rules apply:
If the element is polymorphic (has more than one datatype), then the end of the path for the element SHALL be "[x]" to designate that the name of the element may vary when serialized. The "[x]" is not considered to be part of the official element name, though it may frequently appear in documentation that way.
Elements may be defined in:
resource
, complex-type
or primitive-type
, where derivation = specialization
. These are either Resources or Datatypes defined in the specificationlogical
StructureDefinitions with derivation = constraint
(i.e. Resource and Datatype profiles) are not allowed to define or include ElementDefinitions
with a path not defined within the base type definition from which they derive (e.g. in the FHIR specification).
In addition to the path, every ElementDefinition SHALL have a populated id, and the id
SHALL have a unique value populated by following this algorithm:
pathpart:slicename/reslicename
Note that in a profile with no slices, this id will match the path exactly and entirely.
id
values constructed in this fashion are unique, and persistent, and may be used as the target of external references into the definition, where necessary.
The datatype ElementDefinition
is used in StructureDefinition. The way its elements are to be used and interpreted depends on the context:
ElementDefinition field | Type definition, root element | Type definition, following elements | Constraint Definition, root element | Constraint Definition, following elements |
sliceName | prohibited | prohibited | prohibited | required for slices, else prohibited |
label | optional | optional | recommended | recommended |
code | optional | optional | optional | optional |
slicing | prohibited | optional | prohibited | optional |
short/definition | required | required | required‡ | required‡ |
requirements | prohibited | optional | prohibited‡ | optional‡ |
comment | optional | optional | optional | optional |
alias | optional | optional | optional | optional |
base | snapshot: expected differential: optional |
snapshot: expected differential: optional |
expected | expected |
type | Not expected | required | optional | optional |
nameReference | prohibited | optional | prohibited | optional |
min/max | optional§ | required | optional | optional† |
defaultValue[x] | prohibited | optional | prohibited | optional† |
meaningWhenMissing | prohibited | optional | prohibited | optional† |
fixed[x] | prohibited | prohibited | prohibited | optional |
pattern[x] | prohibited | prohibited | prohibited | optional |
example[x] | prohibited | optional | prohibited | optional |
minValue[x] | prohibited | prohibited | prohibited | optional |
maxValue[x] | prohibited | prohibited | prohibited | optional |
maxLength | prohibited | prohibited | prohibited | optional |
mustSupport | optional♉︎ | optional♉︎ | optional | optional |
isModifier | optional | optional | optional | optional† |
isSummary | Not expected | optional | Not expected | optional† |
binding | prohibited | optional | optional | optional |
constraint | optional | optional | optional∆ | optional∆ |
condition | Not expected | optional | Not expected | optional∆ |
mapping | optional | optional | optional∆ | optional∆ |
Notes:♉
.
separators in the path. It is not always present in differentialsbaseDefinition
element, or where the derivation type is 'specialization'baseDefinition
element and a derivation of 'constraint' - e.g. a definition of a structure that constrains another base structure, referring to the differential portionThe use of Path and type depends more deeply on the context where the ElementDefinition is used:
Context | path (1st element) | path (following elements) | type (1st element) |
Base definition of a datatype (example: Quantity - XML, JSON) |
Name of the type | Path inside the datatype | Element |
A constrained datatype (example: Money - XML, JSON) |
Name of the base type | Path inside the datatype | Name of the base type |
Base definition of a resource (example: Patient - XML, JSON) |
The name of the resource | Path inside the resource | DomainResource or sometimes Resource |
Constraint on a resource (example: DAF Patient - XML, JSON) |
The name of the resource | Path inside the resource (including into the datatypes) |
The name of the resource |
Base Extension (which is a standard datatype) (example: Extension - XML, JSON) |
Extension |
Extension.value[x] or Extension.extension |
Extension |
A defined Extension (example: Extension - XML, JSON) |
Extension |
Extension.value[x] or Extension.extension (for complex extensions) |
Extension |
There are additional notes about the use of ElementDefinition
when defining Extensions on the Defining Extensions page.
For a description of slicing, see Slicing
slicing
can only be used on the first repetition of an element. This first element that declares slicing
is considered to be the slicing entrysliceName
@default
applies to all entries that are not in any other sliceslicing
information) is understood to be the set of constraints that apply to all slices and entries, whether they have a defined slice or not
It's use follows the "normal case", except:
slicing
must be presentmin
governs the number of total occurrences of the sliced element including the number of occurrences in the open portion of the slice (individual slices may have a different min
value). Elements that allow a choice of multiple types can be constrained. In principle, there are two different types of constraints to apply:
When constraining elements with multiple types, the following rules apply:
StructureDefinition.baseDefinition
: min and max are always requiredStructureDefinition.differential
: min and max are always optional; if they are not present, they default to the min and max from the base definitionStructureDefinition.snapshot
: min and max are always required
This section and the elements mustHaveValue
and valueAlternatives
are considered Trial Use for FHIR Release 5.
All primitive data types have a value and also extensions. Even if the element is present, the value might not be present; instead, an extension may be present the either provides information about why the value is not present, or provides an expression that might be used to generate a value in a particular context. Some common extensions that might appear in place of a primitive value:
In many cases, profiles want to make a primitive element required (min = 1), and also want to say
that when a primitive element is present, the value must be present, since the value is what is
processed by applications. The flag mustHaveValue
can be set to true to indicate that
the primitive data type must have value if present (so it has impact whatever the value of min
).
Note that this flag is a short cut, equivalent to the
profile walking into the primitive data type and setting min = 1 for the value. The short cut is
preferable because it's simpler and more concise for implementers.
Alternatively, profiles may wish to allow the primitive value to be replaced by some extensions
but not others. In this case, the profiles can list the allowable extensions using the
valueAlternatives
element, which contains a list of the extensions that can appear
if the primitive value is not present. Note that this list is a short cut for actually profiling
the extensions on the primitive data type and making a co-occurence constraint,
but has no effect when the value is present.
For further discussion regarding populating primitive values, see Exchanging Data using FHIR.
Most elements have a minimum cardinality of 0, which means that they may be missing from a resource when it is exchanged between systems. Generally, when an element is missing, all that an application processing the resource can say about the element is that the value is unknown - it may have a correct value, but it has not been provided for security or workflow reasons. On the other hand, it might not have a value at all. All the application can say is that the value is unknown.
This also applies when the element is present, but has no value or child elements, and only has extensions instead.
However, for some elements, this specification makes specific rules about what it means if the element is missing. Constraints on other structures cannot change the missing meaning of an element. Here is a list of all elements with a default value or a missing meaning:
This specification does not define any default values for resources or datatypes because:
Note that default values can be defined in Logical Models.
For further information about bindings, see Terminology bindings.
The primary focus of the FHIR specification is on correct application behavior around what is exchanged and how: valid APIs and resource instances. However many FHIR implementation guides are interested in specifying additional obligations about how the applications involved handle the data that is being exchanged.
Element Definitions use the property mustSupport
to indicate that there
are rules that apply to how the data is handled. In addition, the
Obligation Extension extension can be used
to make more detailed statements about application behavior.
See Implementation Obligations for the proper use of these features.