ValueSet — Code selection for a binding
Every FHIR code or CodeableConcept field is tied to a
ValueSet through a binding. ValueSet is therefore the cornerstone of FHIR
clinical terminology.
Purpose
ValueSet selects a subset of codes from one or more CodeSystems, to be used as a binding by FHIR elements (Patient.gender, Observation.code, Condition.severity...). A ValueSet has two faces:
- Definition (compose) — membership rules: "all SNOMED codes descending from 386053000".
- Expansion (expansion) — the actual list of codes at a given moment.
The $expand operation computes the expansion from the definition,
accounting for the version of each CodeSystem (SNOMED 2026-03, LOINC 2.78, etc.).
Key fields
| Field | Type | Cardinality | Role |
|---|---|---|---|
url | uri | 0..1 | Canonical URL of the ValueSet. |
version | string | 0..1 | ValueSet version. |
name | string | 0..1 | Machine name. |
status | code | 1..1 | Publication status. |
immutable | boolean | 0..1 | Is the ValueSet stable forever? If yes, expansion stable. |
compose | BackboneElement | 0..1 | Inclusion / exclusion rules. |
compose.include | BackboneElement[] | 0..* | Source(s) to include. |
compose.include.system | uri | 0..1 | Canonical URL of source CodeSystem. |
compose.include.concept | BackboneElement[] | 0..* | Codes listed explicitly. |
compose.include.filter | BackboneElement[] | 0..* | Property-based filter (e.g. "is-a 386053000"). |
compose.include.valueSet | canonical[] | 0..* | Include another ValueSet. |
compose.exclude | BackboneElement[] | 0..* | Exclusions. |
expansion | BackboneElement | 0..1 | Actual list of codes (computed). |
expansion.timestamp | dateTime | 1..1 | When expansion was computed. |
expansion.contains | BackboneElement[] | 0..* | Actual codes. |
Binding strength
In a StructureDefinition, a ValueSet binding is qualified by a strength (binding strength):
| Strength | Meaning |
|---|---|
required | Code MUST come from the ValueSet. |
extensible | Code SHOULD come from the ValueSet, unless no suitable code exists: then provide text or another system. |
preferred | The ValueSet is recommended but not enforced. |
example | The ValueSet is illustrative, free choice. |
JSON example
The canonical administrative-gender ValueSet used for
Patient.gender:
{
"resourceType": "ValueSet",
"id": "administrative-gender",
"url": "http://hl7.org/fhir/ValueSet/administrative-gender",
"version": "5.0.0",
"name": "AdministrativeGender",
"title": "AdministrativeGender",
"status": "active",
"experimental": false,
"date": "2026-05-14",
"publisher": "HL7 International (FHIR Project)",
"description": "The gender of a person used for administrative purposes.",
"immutable": true,
"compose": {
"include": [{
"system": "http://hl7.org/fhir/administrative-gender",
"concept": [
{ "code": "male", "display": "Male" },
{ "code": "female", "display": "Female" },
{ "code": "other", "display": "Other" },
{ "code": "unknown", "display": "Unknown" }
]
}]
}
} $expand and $validate-code
GET [base]/ValueSet/123/$expand— computes the expansion.GET [base]/ValueSet/$expand?url=http://hl7.org/fhir/ValueSet/administrative-gender— expand by canonical URL.GET [base]/ValueSet/123/$validate-code?code=male&system=http://hl7.org/fhir/administrative-gender— checks a code belongs to the ValueSet.
These operations are declared by OperationDefinition and exposed by terminology servers (TX server) like tx.fhir.org, Ontoserver, HAPI FHIR.
Common pitfalls
- Confusing
urlandidentifier—urlis the unique canonical URL, which is also the binding target. is-afilter on a CodeSystem without hierarchy — checkCodeSystem.hierarchyMeaningbefore using anis-afilter.- Expansion without CodeSystem version — expansion MUST pin the version (
system.version) for reproducibility. - ValueSet too broad (full SNOMED) — a
requiredbinding to a multi-million-code ValueSet slows every validation. - Code listed in
concept[]but outside the source CodeSystem — inconsistency: the code must exist in the cited CodeSystem.
Related resources
- CodeSystem — source of codes used by the ValueSet.
- ConceptMap — mapping between two ValueSets.
- NamingSystem — alternate identifiers of systems.
- StructureDefinition — where bindings are declared.