Skip to main content

Expand Value Set

The FHIR $expand operation expands a value set to return the list of codes that are included in the value set at a specific point in time. This operation can be invoked on ValueSet resources.

Endpoint​

POST /w/{tenant}/{project}/api/v1/fhir/ValueSet/$expand

Where {id} is the logical ID of a specific ValueSet resource (optional for type-level operations).

Request Body (POST)​

For POST requests, the request body should contain a Parameters resource with the input parameters:

{
"resourceType": "Parameters",
"parameter": [
{
"name": "url",
"valueUri": "http://hl7.org/fhir/ValueSet/administrative-gender|4.0.1"
}
]
}

Alternatively, you can pass the entire ValueSet to expand:

{
"resourceType": "Parameters",
"parameter": [
{
"name": "valueSet",
"resource": {
"resourceType": "ValueSet",
"compose": {
"include": [
{
"system": "http://hl7.org/fhir/administrative-gender"
}
]
}
}
}
]
}

Response​

If the expansion is successful, the server will respond with a 200 OK status code and a ValueSet resource containing the expanded codes:

HTTP/1.1 200 OK
Content-Type: application/fhir+json
{
"resourceType": "ValueSet",
"url": "http://hl7.org/fhir/ValueSet/administrative-gender",
"version": "4.0.1",
"name": "AdministrativeGender",
"status": "active",
"expansion": {
"identifier": "urn:uuid:12345678-1234-1234-1234-123456789012",
"timestamp": "2025-11-26T10:30:00Z",
"total": 4,
"offset": 0,
"contains": [
{
"system": "http://hl7.org/fhir/administrative-gender",
"code": "male",
"display": "Male"
},
{
"system": "http://hl7.org/fhir/administrative-gender",
"code": "female",
"display": "Female"
},
{
"system": "http://hl7.org/fhir/administrative-gender",
"code": "other",
"display": "Other"
},
{
"system": "http://hl7.org/fhir/administrative-gender",
"code": "unknown",
"display": "Unknown"
}
]
}
}

Limits​

An expansion is answered whole, so it is bounded. One that would hold more than 100,000 concepts, resolve more than 1,000 included value sets (compose.include.valueSet, at any depth) or follow value sets including one another more than 32 levels deep is refused with 422 and a too-costly OperationOutcome. A value set that includes itself, directly or through the value sets it includes, is refused with 422 and an invalid OperationOutcome. $validate-code expands the value set first, so the same applies to it. The limits are the server settings terminology.max_expansion_concepts, terminology.max_included_value_sets and terminology.max_value_set_depth (see Configuration).

Error Handling​

If there are any issues with the request (e.g., missing required parameters, invalid value set), the server will respond with an appropriate error status code and include an OperationOutcome resource in the response body.

HTTP/1.1 400 Bad Request
Content-Type: application/fhir+json
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "not-found",
"diagnostics": "ValueSet 'http://example.org/unknown-valueset' not found"
}
]
}