# Get a patient photo

Operation ID: `fieldagent.getPatientPhoto`

Retrieve a patient's photo as a FHIR Binary resource. If ?binary_id= is omitted, it is auto-resolved from the patient's stored photo_binary_id extension, then from a Binary search by security context — either resolution fails with 400 if the patient has no stored photo.

## Public method

`getPatientPhoto`

Signature: `fieldAgent.getPatientPhoto(patientId, query)`

Return type: `Promise<GetPhotoResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /patients/{patient_id}/photo`

## 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 |
|---|---|---:|---|---|---|---:|---|
| `binary_id` | `string` | Yes |  |  |  | No | Optional binary_id returned by upload_patient_photo. If omitted, the stored patient photo is used. |

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`GetPatientPhotoResponse`](../models/GetPatientPhotoResponse.md) | application/json | Patient photo |

## Success response examples

### 200

```json
{
  "binary_id": "photo-example-002",
  "content_type": "image/png",
  "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | No binary_id was supplied and none could be auto-resolved |
| `401` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `404` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | No FHIR Binary exists for the resolved binary_id |

## Error examples

### 400 — The patient has no stored photo and no binary_id was supplied

```json
{
  "error": "binary_id query parameter is required or the patient must already have a stored photo"
}
```

### 401 — Missing or invalid access token

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

### 404 — The FHIR Binary resource does not exist (sanitized example)

```json
{
  "error": "Not Found"
}
```

## NodeJS / TypeScript implementation

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

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

const query = {
  "binary_id": "<BINARY_ID>"
};

const result = await fieldAgent.getPatientPhoto(patientId, query);
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-fieldagent.health.cloud/patients/%3CPATIENT_ID%3E/photo?binary_id=%3CBINARY_ID%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.
