# List a patient's diagnostic/lab observations

Operation ID: `ehr.listDiagnostics`

List lab/diagnostic Observations for a patient, optionally filtered by ?code= (LOINC code).

## Public method

`listDiagnostics`

Signature: `ehr.listDiagnostics(patientId, code)`

Return type: `Promise<ListDiagnosticsResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /patients/{patient_id}/diagnostics`

## Path parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `patient_id` | `string` | Yes |  |  |  | No |  |

## Query parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `code` | `string` | No |  |  |  | No | LOINC code or other observation code to filter by |

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`ehr.ListDiagnosticsResponse`](../models/ehr.ListDiagnosticsResponse.md) | application/json | Patient diagnostic/lab observations |

## Success response examples

### 200

```json
{
  "diagnostics": [
    {
      "display": "Hemoglobin A1c",
      "effective_datetime": "2026-08-10T12:00:00Z",
      "interpretation": "N",
      "loinc_code": "4548-4",
      "notes": "Synthetic laboratory result",
      "observation_id": "observation-example-001",
      "reference_range": {
        "high": 5.7,
        "low": 4,
        "text": "4.0-5.6 percent",
        "unit": "%"
      },
      "status": "final",
      "value_boolean": null,
      "value_coding": {},
      "value_quantity": 5.2,
      "value_string": null,
      "value_unit": "%"
    }
  ],
  "patient_id": "patient-example-001",
  "total": 1
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `401` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `500` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | Internal server error |

## Error examples

### 401 — Missing or invalid access token

```json
{
  "error": "Authorization required"
}
```

### 500 — Unexpected service failure (sanitized example)

```json
{
  "error": "Internal server error"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
```

```ts
const patientId = "<PATIENT_ID>";

const code = "<CODE>";

const result = await ehr.listDiagnostics(patientId, code);
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-ehr.health.cloud/patients/%3CPATIENT_ID%3E/diagnostics?code=%3CCODE%3E'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
