# ValueSet $expand

`GET /ValueSet/$expand`

This resource contains a set of codes from one or more code systems that are intended for use in a particular context.

<u>Value sets</u> define which codes are allowed for a specific field. For example, a value set might list the allowed codes for a document type, an encounter type, or a lab test category. Codes may come from standard code systems (e.g., SNOMED CT or LOINC) or from organization-specific code systems.

Each health system may support a different set of codes for the same field. Instead of asking each health system for its code lists, you can expand a value set to find out which codes your connection’s system supports.

> **Supported fields and schema examples**
>
> We support any valid FHIR field. However, we only display fields we’ve defined in our schema, which are usually based on what’s included in the U.S. Core profile. We recommend relying on U.S. Core requirements. 
>
> Our schema examples show the shape and possibility of each FHIR resource; they aren’t code for real-time API calls. We don’t currently recommend copying and pasting these schema examples for your API calls. [Consider reviewing FHIR API actions](/fhir-api-actions) for realistic examples for particular use cases.

### $expand

Retrieve the codes that your connection’s system supports for a specific element of a FHIR resource.

For example, you might expand the value set for `DocumentReference.type` to find out which document types a health system sends and accepts before you exchange documents with them.

The response lists each supported code with its code system and display name.

## Request parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `context` | query | string | Yes | The resource element to get the codes for, in the format `<ResourceType>.<element path>`, such as `DocumentReference.type` or `Encounter.type`. |
| `contextDirection` | query | string | Yes | Which codes to get: `outgoing` for the codes the system sends in responses and accepts in search parameters, or `incoming` for the codes it accepts in a create or update. |
| `filter` | query | string | No | Narrows the codes that are returned. In FHIR, this is a text filter on the codes. Some systems, such as Epic, use it to select a category instead, such as `category:clinical-note`. |

## Request example

```bash
curl 'https://api.redoxengine.com/fhir/R4/{destinationSlug}/{environmentFlag}/ValueSet/$expand' \
--request GET \
--header 'Authorization: Bearer $API_TOKEN'
```

## Responses

### 200

Operation Response

A ValueSet expansion that lists the codes the connection's system supports.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `resourceType` | string | Yes | Identifies the type of the resource. Value: ValueSet |
| `status` | string | Yes | The status of this value set. Enables tracking the life-cycle of the content. The status of the value set applies to the value set definition (ValueSet.compose) and the associated ValueSet metadata. Expansions do not have a state. Possible values: draft, active, retired, unknown |
| `id` | string | No | The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes. |
| `expansion` | object | No | A value set can also be "expanded", where the value set is turned into a simple collection of enumerated codes. This element holds the expansion, if it has been performed. |
| `expansion.timestamp` | string | Yes | The time at which the expansion was produced by the expanding system. |
| `expansion.total` | number | No | The total number of concepts in the expansion. If the number of concept nodes in this resource is less than the stated number, then the server can return more using the offset parameter. |
| `expansion.parameter` | Array of object | No | A parameter that controlled the expansion process. These parameters may be used by users of expanded value sets to check whether the expansion is suitable for a particular purpose, or to pick the correct expansion. |
| `expansion.parameter[].name` | string | Yes | Name of the input parameter to the $expand operation; may be a server-assigned name for additional default or other server-supplied parameters used to control the expansion process. |
| `expansion.parameter[].valueString` | string | No | The value of the parameter. Only one of `valueString`, `valueUri`, `valueCode` may be present. |
| `expansion.parameter[].valueUri` | string | No | The value of the parameter. Only one of `valueString`, `valueUri`, `valueCode` may be present. |
| `expansion.parameter[].valueCode` | string | No | The value of the parameter. Only one of `valueString`, `valueUri`, `valueCode` may be present. |
| `expansion.contains` | Array of object | No | The codes that are contained in the value set expansion. |
| `expansion.contains[].system` | string | No | An absolute URI which is the code system in which the code for this item in the expansion is defined. |
| `expansion.contains[].code` | string | No | The code for this item in the expansion hierarchy. If this code is missing the entry in the hierarchy is a place holder (abstract) and does not represent a valid code in the value set. |
| `expansion.contains[].display` | string | No | The recommended display for this item in the expansion. |

```json
{
  "resourceType": "ValueSet",
  "id": "fN1VgbouNkWgEiH70dyCFug4",
  "status": "active",
  "expansion": {
    "timestamp": "2026-11-03T14:02:51Z",
    "total": 4,
    "parameter": [
      {
        "name": "category",
        "valueString": "clinical-note"
      },
      {
        "name": "context",
        "valueUri": "DocumentReference.type"
      },
      {
        "name": "contextDirection",
        "valueCode": "outgoing"
      }
    ],
    "contains": [
      {
        "system": "urn:oid:1.2.840.114350.1.13.12345.1.7.4.737880.5010",
        "code": "1",
        "display": "Progress Notes"
      },
      {
        "system": "urn:oid:1.2.840.114350.1.13.12345.1.7.4.737880.5010",
        "code": "2",
        "display": "Consults"
      },
      {
        "system": "urn:oid:1.2.840.114350.1.13.12345.1.7.4.737880.5010",
        "code": "5",
        "display": "Discharge Summary"
      },
      {
        "system": "urn:oid:1.2.840.114350.1.13.12345.1.7.4.737880.5010",
        "code": "6",
        "display": "ED Notes"
      }
    ]
  }
}
```

### 400

Request could not be processed or failed validation

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `resourceType` | string | Yes | Identifies the type of the resource. Value: OperationOutcome |
| `issue` | Array of object | Yes | A structured respresentation of the error that occurred |
| `issue[].severity` | string | Yes | Generally `error` or `fatal` Possible values: fatal, error, warning, information |
| `issue[].code` | string | Yes | A FHIR category code that describes the general type of issue. See http://hl7.org/fhir/ValueSet/issue-type for details |
| `issue[].id` | string | No | If the error occurs in the RedoxEngine, this corresponds to an Error record in the organization. |
| `issue[].details` | object | No | Additional details about the error. This may be a text description of the error or a system code that identifies the error. |
| `issue[].details.coding` | Array of object | No | A more granular FHIR code for the specific error. Typically from http://hl7.org/fhir/ValueSet/operation-outcome |
| `issue[].details.coding[].system` | string | No | The identification of the code system that defines the meaning of the symbol in the code. |
| `issue[].details.coding[].code` | string | No | A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination). |
| `issue[].details.text` | string | No | A human-readable interpretation of the issue code |
| `issue[].diagnostics` | string | No | Additional diagnostic information about the issue. |

```json
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "fatal",
      "code": "invalid",
      "details": {
        "coding": [
          {
            "code": "MSG_BAD_SYNTAX",
            "system": "http://terminology.hl7.org/CodeSystem/operation-outcome"
          }
        ],
        "text": "Invalid content found in request body."
      }
    }
  ]
}
```

### 401

Authorization is required

Same fields as 400.

```json
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "fatal",
      "code": "unknown",
      "details": {
        "coding": [
          {
            "code": "MSG_AUTH_REQUIRED",
            "system": "http://terminology.hl7.org/CodeSystem/operation-outcome"
          }
        ],
        "text": "Invalid authorization token"
      }
    }
  ]
}
```

### 500

Internal server error

Same fields as 400.

```json
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "fatal",
      "code": "processing",
      "details": {
        "coding": [
          {
            "code": "MSG_RESOURCE_ID_FAIL",
            "system": "http://terminology.hl7.org/CodeSystem/operation-outcome"
          }
        ],
        "text": "Unable to allocate resource id."
      }
    }
  ]
}
```

### 503

Service unavailable

Same fields as 400.

```json
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "fatal",
      "code": "transient",
      "details": {
        "text": "System is unable to process this message at this time."
      }
    }
  ]
}
```
