# CDSHooks patient-view

`POST /cds-hooks/v1/sources/{sourceId}/cds-services/{serviceId}`

These API events help facilitate real-time, immediate clinical decision support (CDS). <u>CDS hooks</u> are events that are triggered during the provider's workflow, typically appearing as a popup modal or separate iFrame. The most common hooks are triggered upon: 

- opening a patient chart
- signing an order
- creating an order
- scheduling

We support these type of hooks that allow you to:

- request a list of supported CDS hooks within the EHR system; 
- return a list of supported CDS hooks within the EHR system;
- view context for a patient upon opening or interacting with their chart;
- view context when creating and selecting an order from a list of order types; and
- view order context and insights when signing an order.

Return patient context when a user opens a patient record. This is typically triggered at the beginning of the clinician’s interaction.

Status: Beta

## Request parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `sourceId` | path | string | Yes | Displays the unique identifier of a source within a given environment. |
| `serviceId` | path | string | Yes | Identifys the destination system for the CDS Hook call |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `Meta` | object | Yes |  |
| `Meta.DataModel` | string | Yes | CDSHooks |
| `Meta.EventType` | string | Yes | patient-view |
| `Meta.EventDateTime` | string or null | No | Displays the UTC date and time that an outgoing request is delivered or an incoming request is received. *[ISO 8601 Format](http://en.wikipedia.org/wiki/ISO_8601)* |
| `Meta.Test` | boolean or null | No | Indicates whether the request is a test or not. |
| `Meta.Source` | object | No | Contains the information for the system initiating the message, including the source ID and name. *Included in messages from Redox* |
| `Meta.Source.ID` | string or null | No | Identifies the system initiating the message. If you have multiple OAuth API keys per environment type, this value is required. If you have only one OAuth API key per environment type, or you're using legacy API keys, this value is optional. *UUID* |
| `Meta.Source.Name` | string or null | No | Displays the name of the system initiating the message. |
| `Meta.Destinations` | Array of object | No | Contains the information for the endpoint(s) receiving the request. A request must contain at least one destination, but asynchronous requests can have more than one destination. Synchronous requests like queries can only support one destination. *Required when sending data to Redox.* |
| `Meta.Destinations[].ID` | string or null | No | Identifies the endpoint that the request is directed to. *UUID* |
| `Meta.Destinations[].Name` | string or null | No | Displays the name of the endpoint that the request is directed to. |
| `Meta.Logs` | Array of object | No | Contains the log identifier(s) for the request. |
| `Meta.Logs[].ID` | string or null | No | Identifies the request log(s) that correspond to this request. You can use this value to locate the relevant log in the Redox dashboard for support and reference. *UUID* |
| `Meta.Logs[].AttemptID` | string or null | No | Identifies the request log attempt value, which is useful when retries are possible. *UUID* |
| `Meta.FacilityCode` | string or null | No | Code for the facility related to the message. *Only use this field if a health system indicates you should. The code is specific to the health system's EHR and might not be unique across health systems. In general, the facility fields within the data models (e.g. OrderingFacility) are more reliable and informative.* |
| `hook` | string | Yes | Specifies the type of event that triggered this CDS service call. |
| `hookInstance` | string | Yes | Contains a universally unique identifier (UUID) for this specific hook instance. |
| `fhirServer` | string | Yes | Contains the base URL of the CDS client's FHIR server. *If `fhirAuthorization` is provided, this field is required.* |
| `context` | object | Yes | Contains contextual data about the hook, or triggered event, that the CDS service will need. |
| `context.patientId` | string | Yes | Contains the unique identifier of the patient that the order is being placed for. |
| `context.userId` | string or null | No | The user ID of the user who triggered the hook. *Must be in the format [ResourceType]/[id]. For this hook, the user is expected to be of type Practitioner, PractitionerRole, Patient, or RelatedPerson. Patient or RelatedPerson are appropriate when a patient or their proxy are viewing the record. For example, Practitioner/abc or Patient/123.* |
| `context.encounterId` | string or null | No | Identifier of the encounter associated with the order. *This is typically a FHIR resource ID such as Encounter/12345.* |
| `user` | string or null | No | Identifies the user who triggered the event. Typically, this is the clinician or healthcare provider viewing the patient record. *If `fhirAuthorization` is present, the `user` field should match the `subject` in the OAuth token.* |
| `fhirAuthorization` | object | No | Defines the OAuth 2.0 bearer access token (including supplemental information) that grants the CDS service access to FHIR resources. |
| `fhirAuthorization.accessToken` | string or null | No | Contains the token that authorizes access to the FHIR server. |
| `fhirAuthorization.tokenType` | string or null | No | Describes the type of access token. |
| `fhirAuthorization.expiresIn` | string or null | No | Specifies the access token's expiration time (in seconds). |
| `fhirAuthorization.scope` | string or null | No | Defines the scope, or access granted, with the token. |
| `prefetch` | object | No | Defines the FHIR data (e.g., `Patient`, `Condition`) that the EHR system should retrieve in advance to include in the CDS service request when the event is triggered. This reduces latency by fetching required data ahead of time and ensures that the CDS service has the necessary context to make informed decisions. |
| `prefetch.{{key}}` | string or null | No | Defines additional fields under the prefetch object, where each key represents a FHIR query defined by the EHR. These queries are used to retrieve data in advance to optimize CDS service performance. |

## Example

```json
{
  "Meta": {
    "Logs": [
      {
        "ID": "d9f5d293-7110-461e-a875-3beb089e79f3",
        "AttemptID": "925d1617-2fe0-468c-a14c-f8c04b572c54"
      }
    ],
    "Test": true,
    "EventDateTime": "2026-11-20T23:35:51.576Z",
    "Source": {
      "ID": "7ce6f387-c33c-417d-8682-81e83628cbd9",
      "Name": "Redox Dev Tools"
    },
    "Destinations": [
      {
        "ID": "af394f14-b34a-464f-8d24-895f370af4c9",
        "Name": "Redox EMR"
      }
    ],
    "DataModel": "CDSHooks",
    "EventType": "patient-view",
    "FacilityCode": null
  },
  "hookInstance": "d1577c69-dfbe-44ad-ba6d-3e05e953b2ea",
  "hook": "patient-view",
  "user": "Practitioner/123",
  "fhirServer": "https://ehr.example.com/fhir",
  "fhirAuthorization": {
    "access_token": "some-opaque-fhir-access-token",
    "token_type": "Bearer",
    "expires_in": 300,
    "scope": "user/Patient.read launch",
    "subject": "Practitioner/123"
  },
  "context": {
    "userId": "Practitioner/123",
    "patientId": "1288992"
  }
}
```
