Element
Element is a FHIR Schema component which defines or constrains FHIR data type.
Syntax
All properties are optional.
Shape properties
array
(boolean)scalar
(boolean)
Cardinality properties
min
(integer)max
(integer)
Choice type properties
choiceOf
(string)choices
(array of strings)
Requires and exclusions properties
excluded
(array of strings)required
(array of strings)
Type reference properties
elementReference
(array of strings)type
(string)
Nested elements property
elements
(object)
Constraints property
constraints
(Constraint)
Slicing property
slicing
(Slicing)
Terminology binding property
binding
(Binding): valueset binding\
Pattern matching (constants definition) property
fixed
(any)pattern
(any)
Reference target property
refers
(array of strings)
Informational properties
modifier
(boolean)mustSupport
(boolean)summary
(boolean)
Shape
There are 2 properties controlling element shape:
array
scalar
The array
and scalar
properties control element structure. These 2 properties are mutually exclusive.
I.e. the folowing element is invalid.
array: true
scalar: true
- If
array
is set, only JSON arrays are accepted. - If
scalar
is set, JSON arrays are rejected. - If neither is set, everything is accepted.
Empty arrays are rejected (they are not allowed by FHIR).
Example
Consider this part of FHIR R4 Core Patient schema:
id: Patient
url: http://hl7.org/fhir/StructureDefinition/Patient
package-meta:
name: hl7.fhir.r4.core
version: 4.0.1
path: "/tmp/lw-fhir-schema-repository/hl7.fhir.r4.core#4.0.1"
base: http://hl7.org/fhir/StructureDefinition/DomainResource
kind: resource
type: Patient
derivation: specialization
elements:
deceasedBoolean:
scalar: true
summary: true
modifier: true
type: boolean
choiceOf: deceased
maritalStatus:
binding:
valueSet: http://hl7.org/fhir/ValueSet/marital-status
strength: extensible
scalar: true
type: CodeableConcept
deceasedDateTime:
scalar: true
summary: true
modifier: true
type: dateTime
choiceOf: deceased
managingOrganization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
summary: true
type: Reference
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
type: code
scalar: true
summary: true
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
scalar: true
name:
summary: true
type: HumanName
array: true
address:
summary: true
type: Address
array: true
identifier:
summary: true
type: Identifier
array: true
photo:
type: Attachment
array: true
link:
summary: true
modifier: true
required:
- other
- type
type: BackboneElement
array: true
elements:
other:
refers:
- http://hl7.org/fhir/StructureDefinition/Patient
- http://hl7.org/fhir/StructureDefinition/RelatedPerson
scalar: true
summary: true
type: Reference
type:
binding:
valueSet: http://hl7.org/fhir/ValueSet/link-type
strength: required
codesystems:
- http://hl7.org/fhir/link-type
scalar: true
summary: true
type: code
birthDate:
scalar: true
summary: true
type: date
multipleBirthBoolean:
scalar: true
type: boolean
choiceOf: multipleBirth
communication:
required:
- language
type: BackboneElement
array: true
elements:
language:
binding:
valueSet: http://hl7.org/fhir/ValueSet/languages
strength: preferred
scalar: true
type: CodeableConcept
preferred:
scalar: true
type: boolean
telecom:
summary: true
type: ContactPoint
array: true
active:
scalar: true
summary: true
modifier: true
type: boolean
deceased:
choices:
- deceasedBoolean
- deceasedDateTime
scalar: true
generalPractitioner:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
- http://hl7.org/fhir/StructureDefinition/Practitioner
- http://hl7.org/fhir/StructureDefinition/PractitionerRole
type: Reference
array: true
contact:
constraints:
pat-1:
human: SHALL at least contain a contact's details or a reference to an organization
severity: error
expression: name.exists() or telecom.exists() or address.exists() or organization.exists()
type: BackboneElement
array: true
elements:
relationship:
binding:
valueSet: http://hl7.org/fhir/ValueSet/patient-contactrelationship
strength: extensible
type: CodeableConcept
array: true
name:
scalar: true
type: HumanName
telecom:
type: ContactPoint
array: true
address:
scalar: true
type: Address
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
scalar: true
type: code
organization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
type: Reference
period:
scalar: true
type: Period
multipleBirthInteger:
scalar: true
type: integer
choiceOf: multipleBirth
Resource example that conforms to schema mentioned earlier:
resourceType: Patient
gender: male
resourceType: Patient
name:
- text: John Smith
Resource example that didn't conform to schema mentioned earlier
resourceType: Patient
gender:
- male
resourceType: Patient
name:
text: John Smith
Cardinality
There are 2 properties controlling element cardinality:
min
max
Cardinality defines the minimum and maximum number of elements in an array. These properties are allowed only if the shape is set to 'array'.
Absent cardinality property means this cardinality is not restricted.
The schema may contain only min
or max
properties, or it may omit both.
Example
Schema
url: http://example.org/StructureDefinition/patient-minmax
base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
derivation: constraint
elements:
name:
min: 2
max: 3
Valid resources
resourceType: Patient
name:
- text: James
- text: Mary
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
resourceType: Patient
name:
- text: James
- text: Mary
- text: Robert
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
Invalid resources:
resourceType: Patient
name:
- text: James
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
resourceType: Patient
name:
- text: James
- text: Mary
- text: Robert
- text: Patricia
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
Choice type
In FHIR, polymorphic types are used to allow values of different types for specific fields.
resourceType: Patient
multipleBirthBoolean: true
resourceType: Patient
multipleBirthInteger: 2
In the example provided above, multipleBirth[x]
is a choice type element, the value of which can either be of the boolean type (multipleBirthBoolean
) or the integer type (multipleBirthInteger
).
The concurrent presence of the multipleBirthBoolean
field and the multipleBirthInteger
field in the data is not allowed.
There are 2 properties controlling that polymorphism:
choices
choiceOf
choices
This property is intended for the enumeration of available polymorphic type elements.
Example
url: http://example.org/StructureDefinition/patient-choice-type
base: http://hl7.org/fhir/StructureDefinition/Patient
derivation: constraint
elements:
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
multipleBirthBoolean:
choiceOf: multipleBirth
type: boolean
multipleBirthInteger:
type: integer
choiceOf: multipleBirth
choiceOf
Every concrete polymorphic type element specifies its polymorphic name under the choiceOf
property.
Example
url: http://example.org/StructureDefinition/patient-choice-type
base: http://hl7.org/fhir/StructureDefinition/Patient
derivation: constraint
elements:
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
multipleBirthBoolean:
choiceOf: multipleBirth
type: boolean
multipleBirthInteger:
type: integer
choiceOf: multipleBirth
Valid resources:
resourceType: Patient
meta:
profile:
- http://example.org/StructureDefinition/patient-choice-type
multipleBirthBoolean: true
resourceType: Patient
meta:
profile:
- http://example.org/StructureDefinition/patient-choice-type
multipleBirthInteger: 3
Invalid resources:
resourceType: Patient
meta:
profile:
- http://example.org/StructureDefinition/patient-choice-type
multipleBirthBoolean: true
multipleBirthInteger: 3
resourceType: Patient
meta:
profile:
- http://example.org/StructureDefinition/patient-choice-type
multipleBirthString: "3"
resourceType: Patient
meta:
profile:
- http://example.org/StructureDefinition/patient-choice-type
multipleBirth: true
resourceType: Patient
meta:
profile:
- http://example.org/StructureDefinition/patient-choice-type
multipleBirth: 3
Requires and exclusions
There are 2 elements controlling required and excluded elements:
required
excluded
The required
property lists all subelements which shall be present.
The excluded
property lists all subelements which shall be absent.
Example
Schema
url: http://example.org/StructureDefinition/patient-minmax
base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
derivation: constraint
required:
- birthDate
excluded:
- gender
Valid resources
resourceType: Patient
birthDate: "2000-01-01"
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
resourceType: Patient
birthDate: "2000-01-01"
active: true
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
Invalid resources
resourceType: Patient
active: true
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
resourceType: Patient
gender: other
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
resourceType: Patient
birthDate: "2000-01-01"
gender: other
meta:
profile:
- http://example.org/StructureDefinition/patient-minmax
Type reference
There are 2 properties specifying type references:
type
elementReference
These two properties are mutually exclusive.
Type reference is either a FHIR type name or canonical URL of the FHIR type.
Base type
The type
property specified base type of the element.
Data is accepted if both conditions are met:
- Data is accepted when validated against referred type
- Data is accepted by all other conditions on element
Example
Schema
id: Patient
url: http://hl7.org/fhir/StructureDefinition/Patient
package-meta:
name: hl7.fhir.r4.core
version: 4.0.1
path: "/tmp/lw-fhir-schema-repository/hl7.fhir.r4.core#4.0.1"
base: http://hl7.org/fhir/StructureDefinition/DomainResource
kind: resource
type: Patient
derivation: specialization
elements:
deceasedBoolean:
scalar: true
summary: true
modifier: true
type: boolean
choiceOf: deceased
maritalStatus:
binding:
valueSet: http://hl7.org/fhir/ValueSet/marital-status
strength: extensible
scalar: true
type: CodeableConcept
deceasedDateTime:
scalar: true
summary: true
modifier: true
type: dateTime
choiceOf: deceased
managingOrganization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
summary: true
type: Reference
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
type: code
scalar: true
summary: true
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
scalar: true
name:
summary: true
type: HumanName
array: true
address:
summary: true
type: Address
array: true
identifier:
summary: true
type: Identifier
array: true
photo:
type: Attachment
array: true
link:
summary: true
modifier: true
required:
- other
- type
type: BackboneElement
array: true
elements:
other:
refers:
- http://hl7.org/fhir/StructureDefinition/Patient
- http://hl7.org/fhir/StructureDefinition/RelatedPerson
scalar: true
summary: true
type: Reference
type:
binding:
valueSet: http://hl7.org/fhir/ValueSet/link-type
strength: required
codesystems:
- http://hl7.org/fhir/link-type
scalar: true
summary: true
type: code
birthDate:
scalar: true
summary: true
type: date
multipleBirthBoolean:
scalar: true
type: boolean
choiceOf: multipleBirth
communication:
required:
- language
type: BackboneElement
array: true
elements:
language:
binding:
valueSet: http://hl7.org/fhir/ValueSet/languages
strength: preferred
scalar: true
type: CodeableConcept
preferred:
scalar: true
type: boolean
telecom:
summary: true
type: ContactPoint
array: true
active:
scalar: true
summary: true
modifier: true
type: boolean
deceased:
choices:
- deceasedBoolean
- deceasedDateTime
scalar: true
generalPractitioner:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
- http://hl7.org/fhir/StructureDefinition/Practitioner
- http://hl7.org/fhir/StructureDefinition/PractitionerRole
type: Reference
array: true
contact:
constraints:
pat-1:
human: SHALL at least contain a contact's details or a reference to an organization
severity: error
expression: name.exists() or telecom.exists() or address.exists() or organization.exists()
type: BackboneElement
array: true
elements:
relationship:
binding:
valueSet: http://hl7.org/fhir/ValueSet/patient-contactrelationship
strength: extensible
type: CodeableConcept
array: true
name:
scalar: true
type: HumanName
telecom:
type: ContactPoint
array: true
address:
scalar: true
type: Address
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
scalar: true
type: code
organization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
type: Reference
period:
scalar: true
type: Period
multipleBirthInteger:
scalar: true
type: integer
choiceOf: multipleBirth
elements:
a:
type: string
array: true
max: 1
b:
type: http://hl7.org/fhir/StructureDefinition/string
array: true
max: 1
Valid resources
resourceType: Patient
gender: other
resourceType: Patient
name:
- text: James
Invalid resources
resourceType: Patient
gender: 2
resourceType: Patient
name:
- James
resourceType: Patient
gender:
text: James
resourceType: Patient
name:
- 2
Element reference syntax
Element reference is an array of the following format:
- First element is a type reference
- Other elements are a path in FHIRSchema
Example
Schema
url: http://example.org/abc
elements:
a:
elements:
b:
type: string
Element reference referring the b
element
[http://example.org/abc, elements, a, elements, b]
Element reference
Data is accepted if both conditions are met:
- Data is accepted when validated against schema for referred element
- Data is accepted by all other conditions on element
Element reference is useful for defining recursive structures (e.g. Questionnaire.item
)
Example
Schema
url: http://hl7.org/fhir/StructureDefinition/Questionnaire
constraints:
que-2:
human: The link ids for groups and questions must be unique within the questionnaire
severity: error
expression: descendants().linkId.isDistinct()
que-0:
human: Name should be usable as an identifier for the module by machine processing applications such as code generation
severity: warning
expression: name.matches('[A-Z]([A-Za-z0-9_]){0,254}')
package-meta:
name: hl7.fhir.r4.core
version: 4.0.1
path: /tmp/lw-fhir-schema-repository/hl7.fhir.r4.core#4.0.1
id: Questionnaire
base: http://hl7.org/fhir/StructureDefinition/DomainResource
kind: resource
required:
- status
type: Questionnaire
elements:
url:
scalar: true
summary: true
type: uri
derivedFrom:
refers:
- http://hl7.org/fhir/StructureDefinition/Questionnaire
type: canonical
array: true
experimental:
scalar: true
summary: true
type: boolean
effectivePeriod:
scalar: true
summary: true
type: Period
approvalDate:
scalar: true
type: date
name:
scalar: true
summary: true
type: string
status:
binding:
valueSet: http://hl7.org/fhir/ValueSet/publication-status
strength: required
codesystems:
- http://hl7.org/fhir/publication-status
scalar: true
summary: true
modifier: true
type: code
identifier:
summary: true
type: Identifier
array: true
item:
constraints:
que-6:
human: Required and repeat aren't permitted for display items
severity: error
expression: type!='display' or (required.empty() and repeats.empty())
que-3:
human: Display items cannot have a "code" asserted
severity: error
expression: type!='display' or code.empty()
que-4:
human: A question cannot have both answerOption and answerValueSet
severity: error
expression: answerOption.empty() or answerValueSet.empty()
que-8:
human: Initial values can't be specified for groups or display items
severity: error
expression: (type!='group' and type!='display') or initial.empty()
que-13:
human: Can only have multiple initial values for repeating items
severity: error
expression: repeats=true or initial.count() <= 1
que-12:
human: If there are more than one enableWhen, enableBehavior must be specified
severity: error
expression: enableWhen.count() > 2 implies enableBehavior.exists()
que-11:
human: If one or more answerOption is present, initial[x] must be missing
severity: error
expression: answerOption.empty() or initial.empty()
que-9:
human: Read-only can't be specified for "display" items
severity: error
expression: type!='display' or readOnly.empty()
que-1:
human: Group items must have nested items, display items cannot have nested items
severity: error
expression: (type='group' implies item.empty().not()) and (type.trace('type')='display' implies item.trace('item').empty())
que-10:
human: Maximum length can only be declared for simple question types
severity: error
expression: (type in ('boolean' | 'decimal' | 'integer' | 'string' | 'text' | 'url' | 'open-choice')) or maxLength.empty()
que-5:
human: Only 'choice' and 'open-choice' items can have answerValueSet
severity: error
expression: (type ='choice' or type = 'open-choice' or type = 'decimal' or type = 'integer' or type = 'date' or type = 'dateTime' or type = 'time' or type = 'string' or type = 'quantity') or (answerValueSet.empty() and answerOption.empty())
required:
- linkId
- type
type: BackboneElement
array: true
elements:
answerValueSet:
refers:
- http://hl7.org/fhir/StructureDefinition/ValueSet
scalar: true
type: canonical
repeats:
scalar: true
type: boolean
prefix:
scalar: true
type: string
answerOption:
required:
- value
- value
- value
- value
- value
- value
type: BackboneElement
array: true
elements:
valueInteger:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: integer
choiceOf: value
value:
choices:
- valueInteger
- valueDate
- valueTime
- valueString
- valueCoding
- valueReference
scalar: true
valueDate:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: date
choiceOf: value
valueTime:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: time
choiceOf: value
valueString:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: string
choiceOf: value
valueCoding:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: Coding
choiceOf: value
valueReference:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
refers:
- http://hl7.org/fhir/StructureDefinition/Resource
scalar: true
required-element: true
type: Reference
choiceOf: value
initialSelected:
scalar: true
type: boolean
maxLength:
scalar: true
type: integer
initial:
required:
- value
- value
- value
- value
- value
- value
- value
- value
- value
- value
- value
- value
type: BackboneElement
array: true
elements:
valueCoding:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: Coding
choiceOf: value
valueUri:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: uri
choiceOf: value
valueString:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: string
choiceOf: value
valueReference:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
refers:
- http://hl7.org/fhir/StructureDefinition/Resource
scalar: true
required-element: true
type: Reference
choiceOf: value
valueDecimal:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: decimal
choiceOf: value
valueAttachment:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: Attachment
choiceOf: value
valueDateTime:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: dateTime
choiceOf: value
value:
choices:
- valueBoolean
- valueDecimal
- valueInteger
- valueDate
- valueDateTime
- valueTime
- valueString
- valueUri
- valueAttachment
- valueCoding
- valueQuantity
- valueReference
scalar: true
valueBoolean:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: boolean
choiceOf: value
valueDate:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: date
choiceOf: value
valueTime:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: time
choiceOf: value
valueQuantity:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: Quantity
choiceOf: value
valueInteger:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: integer
choiceOf: value
enableWhen:
constraints:
que-7:
human: If the operator is 'exists', the value must be a boolean
severity: error
expression: operator = 'exists' implies (answer is Boolean)
modifier: true
required:
- question
- operator
- answer
- answer
- answer
- answer
- answer
- answer
- answer
- answer
- answer
- answer
type: BackboneElement
array: true
elements:
answerReference:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
refers:
- http://hl7.org/fhir/StructureDefinition/Resource
scalar: true
required-element: true
type: Reference
choiceOf: answer
operator:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-enable-operator
strength: required
codesystems:
- http://hl7.org/fhir/questionnaire-enable-operator
scalar: true
type: code
answerDate:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: date
choiceOf: answer
answerTime:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: time
choiceOf: answer
answerString:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: string
choiceOf: answer
answerCoding:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: Coding
choiceOf: answer
question:
scalar: true
type: string
answerInteger:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: integer
choiceOf: answer
answerQuantity:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: Quantity
choiceOf: answer
answerDateTime:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: dateTime
choiceOf: answer
answerBoolean:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: boolean
choiceOf: answer
answerDecimal:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-answers
strength: example
scalar: true
required-element: true
type: decimal
choiceOf: answer
answer:
choices:
- answerBoolean
- answerDecimal
- answerInteger
- answerDate
- answerDateTime
- answerTime
- answerString
- answerCoding
- answerQuantity
- answerReference
scalar: true
text:
scalar: true
type: string
item:
elementReference:
- http://hl7.org/fhir/StructureDefinition/Questionnaire
- elements
- item
array: true
enableBehavior:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-enable-behavior
strength: required
codesystems:
- http://hl7.org/fhir/questionnaire-enable-behavior
scalar: true
type: code
definition:
scalar: true
type: uri
readOnly:
scalar: true
type: boolean
required:
scalar: true
type: boolean
type:
binding:
valueSet: http://hl7.org/fhir/ValueSet/item-type
strength: required
codesystems:
- http://hl7.org/fhir/item-type
scalar: true
type: code
linkId:
scalar: true
type: string
code:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-questions
strength: example
type: Coding
array: true
jurisdiction:
binding:
valueSet: http://hl7.org/fhir/ValueSet/jurisdiction
strength: extensible
summary: true
type: CodeableConcept
array: true
title:
scalar: true
summary: true
type: string
copyright:
scalar: true
type: markdown
publisher:
scalar: true
summary: true
type: string
version:
scalar: true
summary: true
type: string
date:
scalar: true
summary: true
type: dateTime
subjectType:
binding:
valueSet: http://hl7.org/fhir/ValueSet/resource-types
strength: required
codesystems:
- http://hl7.org/fhir/resource-types
summary: true
type: code
array: true
useContext:
summary: true
type: UsageContext
array: true
lastReviewDate:
scalar: true
type: date
code:
binding:
valueSet: http://hl7.org/fhir/ValueSet/questionnaire-questions
strength: example
summary: true
type: Coding
array: true
contact:
summary: true
type: ContactDetail
array: true
description:
scalar: true
type: markdown
purpose:
scalar: true
type: markdown
derivation: specialization
Valid resources:
resourceType: Questionnaire
status: draft
item:
- type: display
linkId: q-1
resourceType: Questionnaire
status: draft
item:
- item:
- type: display
linkId: q-2
type: group
linkId: q-1
resourceType: Questionnaire
status: draft
item:
- item:
- item:
- item:
- type: display
linkId: q-4
linkId: q-3
type: group
linkId: q-2
type: group
linkId: q-1
type: group
Invalid resources:
resourceType: Questionnaire
status: draft
item:
- item:
- wrongType
type: group
linkId: q-1
resourceType: Questionnaire
status: draft
item:
- item:
- item:
- nonExistentField: abc
linkId: q-3
type: group
linkId: q-2
type: group
linkId: q-1
type: group
Nested elements
The elements
property define nested element constraints.
Syntactically it is an object, with string keys and Element values.
Semantically it defines behavior of the corresponding fields in data.
Example
Schema
id: Patient
url: http://hl7.org/fhir/StructureDefinition/Patient
package-meta:
name: hl7.fhir.r4.core
version: 4.0.1
path: "/tmp/lw-fhir-schema-repository/hl7.fhir.r4.core#4.0.1"
base: http://hl7.org/fhir/StructureDefinition/DomainResource
kind: resource
type: Patient
derivation: specialization
elements:
deceasedBoolean:
scalar: true
summary: true
modifier: true
type: boolean
choiceOf: deceased
maritalStatus:
binding:
valueSet: http://hl7.org/fhir/ValueSet/marital-status
strength: extensible
scalar: true
type: CodeableConcept
deceasedDateTime:
scalar: true
summary: true
modifier: true
type: dateTime
choiceOf: deceased
managingOrganization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
summary: true
type: Reference
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
type: code
scalar: true
summary: true
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
scalar: true
name:
summary: true
type: HumanName
array: true
address:
summary: true
type: Address
array: true
identifier:
summary: true
type: Identifier
array: true
photo:
type: Attachment
array: true
link:
summary: true
modifier: true
required:
- other
- type
type: BackboneElement
array: true
elements:
other:
refers:
- http://hl7.org/fhir/StructureDefinition/Patient
- http://hl7.org/fhir/StructureDefinition/RelatedPerson
scalar: true
summary: true
type: Reference
type:
binding:
valueSet: http://hl7.org/fhir/ValueSet/link-type
strength: required
codesystems:
- http://hl7.org/fhir/link-type
scalar: true
summary: true
type: code
birthDate:
scalar: true
summary: true
type: date
multipleBirthBoolean:
scalar: true
type: boolean
choiceOf: multipleBirth
communication:
required:
- language
type: BackboneElement
array: true
elements:
language:
binding:
valueSet: http://hl7.org/fhir/ValueSet/languages
strength: preferred
scalar: true
type: CodeableConcept
preferred:
scalar: true
type: boolean
telecom:
summary: true
type: ContactPoint
array: true
active:
scalar: true
summary: true
modifier: true
type: boolean
deceased:
choices:
- deceasedBoolean
- deceasedDateTime
scalar: true
generalPractitioner:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
- http://hl7.org/fhir/StructureDefinition/Practitioner
- http://hl7.org/fhir/StructureDefinition/PractitionerRole
type: Reference
array: true
contact:
constraints:
pat-1:
human: SHALL at least contain a contact's details or a reference to an organization
severity: error
expression: name.exists() or telecom.exists() or address.exists() or organization.exists()
type: BackboneElement
array: true
elements:
relationship:
binding:
valueSet: http://hl7.org/fhir/ValueSet/patient-contactrelationship
strength: extensible
type: CodeableConcept
array: true
name:
scalar: true
type: HumanName
telecom:
type: ContactPoint
array: true
address:
scalar: true
type: Address
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
scalar: true
type: code
organization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
type: Reference
period:
scalar: true
type: Period
multipleBirthInteger:
scalar: true
type: integer
choiceOf: multipleBirth
Valid resource
resourceType: Patient
link:
- other:
reference: http://example.org/patient-path
type: Patient
type: refer
Invalid resource
resourceType: Patient
link:
- unexisting: true
Terminology binding
Syntax
valueSet
(string)strength
(string)
FHIRSchema terminology binding follows FHIR terminology binding.
Both valueSet
and strength
properties shall be specified.
The valueSet
property is a canonical URL referring to the ValueSet
to which the codes in the data element value are bound.
The strength
property specifies FHIR ValueSet binding strength.
Only required
bindings are validated.
Example
Schema
id: Patient
url: http://hl7.org/fhir/StructureDefinition/Patient
package-meta:
name: hl7.fhir.r4.core
version: 4.0.1
path: "/tmp/lw-fhir-schema-repository/hl7.fhir.r4.core#4.0.1"
base: http://hl7.org/fhir/StructureDefinition/DomainResource
kind: resource
type: Patient
derivation: specialization
elements:
deceasedBoolean:
scalar: true
summary: true
modifier: true
type: boolean
choiceOf: deceased
maritalStatus:
binding:
valueSet: http://hl7.org/fhir/ValueSet/marital-status
strength: extensible
scalar: true
type: CodeableConcept
deceasedDateTime:
scalar: true
summary: true
modifier: true
type: dateTime
choiceOf: deceased
managingOrganization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
summary: true
type: Reference
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
type: code
scalar: true
summary: true
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
scalar: true
name:
summary: true
type: HumanName
array: true
address:
summary: true
type: Address
array: true
identifier:
summary: true
type: Identifier
array: true
photo:
type: Attachment
array: true
link:
summary: true
modifier: true
required:
- other
- type
type: BackboneElement
array: true
elements:
other:
refers:
- http://hl7.org/fhir/StructureDefinition/Patient
- http://hl7.org/fhir/StructureDefinition/RelatedPerson
scalar: true
summary: true
type: Reference
type:
binding:
valueSet: http://hl7.org/fhir/ValueSet/link-type
strength: required
codesystems:
- http://hl7.org/fhir/link-type
scalar: true
summary: true
type: code
birthDate:
scalar: true
summary: true
type: date
multipleBirthBoolean:
scalar: true
type: boolean
choiceOf: multipleBirth
communication:
required:
- language
type: BackboneElement
array: true
elements:
language:
binding:
valueSet: http://hl7.org/fhir/ValueSet/languages
strength: preferred
scalar: true
type: CodeableConcept
preferred:
scalar: true
type: boolean
telecom:
summary: true
type: ContactPoint
array: true
active:
scalar: true
summary: true
modifier: true
type: boolean
deceased:
choices:
- deceasedBoolean
- deceasedDateTime
scalar: true
generalPractitioner:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
- http://hl7.org/fhir/StructureDefinition/Practitioner
- http://hl7.org/fhir/StructureDefinition/PractitionerRole
type: Reference
array: true
contact:
constraints:
pat-1:
human: SHALL at least contain a contact's details or a reference to an organization
severity: error
expression: name.exists() or telecom.exists() or address.exists() or organization.exists()
type: BackboneElement
array: true
elements:
relationship:
binding:
valueSet: http://hl7.org/fhir/ValueSet/patient-contactrelationship
strength: extensible
type: CodeableConcept
array: true
name:
scalar: true
type: HumanName
telecom:
type: ContactPoint
array: true
address:
scalar: true
type: Address
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
scalar: true
type: code
organization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
type: Reference
period:
scalar: true
type: Period
multipleBirthInteger:
scalar: true
type: integer
choiceOf: multipleBirth
Note: there is a
codesystems
property in expanded view of the example schema: it is a technical field generated by StructureDefinition to FHIRSchema conversion, this field speeds up schema loading, but is irrelevant to writing new schemas.
Valid resource:
resourceType: Patient
gender: other
Invalid resource:
resourceType: Patient
gender: something-not-in-the-valueset
Reference target
The refers
property lists allows reference targets.
A reference data element is accepted only if it refers to one of the allowed here types.
A target can be either resource type or canonical URL for this resource type.
Example
Schema:
id: Patient
url: http://hl7.org/fhir/StructureDefinition/Patient
package-meta:
name: hl7.fhir.r4.core
version: 4.0.1
path: "/tmp/lw-fhir-schema-repository/hl7.fhir.r4.core#4.0.1"
base: http://hl7.org/fhir/StructureDefinition/DomainResource
kind: resource
type: Patient
derivation: specialization
elements:
deceasedBoolean:
scalar: true
summary: true
modifier: true
type: boolean
choiceOf: deceased
maritalStatus:
binding:
valueSet: http://hl7.org/fhir/ValueSet/marital-status
strength: extensible
scalar: true
type: CodeableConcept
deceasedDateTime:
scalar: true
summary: true
modifier: true
type: dateTime
choiceOf: deceased
managingOrganization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
summary: true
type: Reference
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
type: code
scalar: true
summary: true
multipleBirth:
choices:
- multipleBirthBoolean
- multipleBirthInteger
scalar: true
name:
summary: true
type: HumanName
array: true
address:
summary: true
type: Address
array: true
identifier:
summary: true
type: Identifier
array: true
photo:
type: Attachment
array: true
link:
summary: true
modifier: true
required:
- other
- type
type: BackboneElement
array: true
elements:
other:
refers:
- http://hl7.org/fhir/StructureDefinition/Patient
- http://hl7.org/fhir/StructureDefinition/RelatedPerson
scalar: true
summary: true
type: Reference
type:
binding:
valueSet: http://hl7.org/fhir/ValueSet/link-type
strength: required
codesystems:
- http://hl7.org/fhir/link-type
scalar: true
summary: true
type: code
birthDate:
scalar: true
summary: true
type: date
multipleBirthBoolean:
scalar: true
type: boolean
choiceOf: multipleBirth
communication:
required:
- language
type: BackboneElement
array: true
elements:
language:
binding:
valueSet: http://hl7.org/fhir/ValueSet/languages
strength: preferred
scalar: true
type: CodeableConcept
preferred:
scalar: true
type: boolean
telecom:
summary: true
type: ContactPoint
array: true
active:
scalar: true
summary: true
modifier: true
type: boolean
deceased:
choices:
- deceasedBoolean
- deceasedDateTime
scalar: true
generalPractitioner:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
- http://hl7.org/fhir/StructureDefinition/Practitioner
- http://hl7.org/fhir/StructureDefinition/PractitionerRole
type: Reference
array: true
contact:
constraints:
pat-1:
human: SHALL at least contain a contact's details or a reference to an organization
severity: error
expression: name.exists() or telecom.exists() or address.exists() or organization.exists()
type: BackboneElement
array: true
elements:
relationship:
binding:
valueSet: http://hl7.org/fhir/ValueSet/patient-contactrelationship
strength: extensible
type: CodeableConcept
array: true
name:
scalar: true
type: HumanName
telecom:
type: ContactPoint
array: true
address:
scalar: true
type: Address
gender:
binding:
valueSet: http://hl7.org/fhir/ValueSet/administrative-gender
strength: required
codesystems:
- http://hl7.org/fhir/administrative-gender
scalar: true
type: code
organization:
refers:
- http://hl7.org/fhir/StructureDefinition/Organization
scalar: true
type: Reference
period:
scalar: true
type: Period
multipleBirthInteger:
scalar: true
type: integer
choiceOf: multipleBirth
Valid resources:
resourceType: Patient
generalPractitioner:
- reference: Organization/organization-1
resourceType: Patient
generalPractitioner:
- reference: Practitioner/practitioner-1
- reference: Organization/organization-1
resourceType: Patient
generalPractitioner:
- reference: Practitioner/practitioner-1
Invalid resources:
resourceType: Patient
generalPractitioner:
- reference: Patient/patient-1
resourceType: Patient
generalPractitioner:
- reference: Organization/organization-1
- reference: Patient/patient-1
Pattern matching
There are 2 properties to define elements that match constant values:
fixed
: a value that must match the value of element;pattern
: a value that specifies the entries or items that an element must contain.
Example
Schema with fixed
element
url: http://example.com/Patient/patient
base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
name: Patient-fixed
elements:
gender:
type: code
fixed: male
name:
type: HumanName
fixed:
- family: Smith
Valid resources
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
Invalid resources
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
given: John
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: female
name:
- family: Smith
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
given: John
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
- family: Gray
Schema with pattern
element
url: http://example.com/Patient/patient
base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient
name: Patient-pattern
elements:
gender:
type: code
pattern: male
name:
type: HumanName
pattern:
- family: Smith
Valid resources
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
given: John
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Smith
- family: Gray
Invalid resources
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: female
name:
- family: Smith
meta:
profile:
- http://example.com/Patient/patient|1.0.0
resourceType: Patient
gender: male
name:
- family: Gray
Informational
These properties do not affect validation, but they provide additional information about element.
The modifier
property mirrors the ElementDefinition.isModifier
FHIR property.
The modifier element changes the interpretation of the resource.
The mustSupport
property mirrors the ElementDefinition.mustSupport
FHIR property.
The mustSupport element must be supported by an implementation.
The summary
property mirrors the ElementDefinition.isSummary
FHIR property.
The summary element should be included in FHIR Search in summary mode.