# OCR an identity document

Operation ID: `patient.analyzeIdentityDocument`

Extract identity-document fields via AWS Textract AnalyzeID for the authenticated patient. When `verify_against_demographics` is true, the extracted name/DOB are compared against the caller's own FHIR patient record. The submitted image is also mirrored best-effort to the linked Athena driver's-license image; Athena receives no extracted licence fields. Requires a patient Bearer JWT.

## Public method

`scanIdentityDocument`

Signature: `patient.scanIdentityDocument(request)`

Return type: `Promise<IdentityDocumentResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /patients/identity-document`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`AnalyzeIdentityDocumentRequest`](../models/AnalyzeIdentityDocumentRequest.md) | No |  |  |  | No |  |

Request model: [`AnalyzeIdentityDocumentRequest`](../models/AnalyzeIdentityDocumentRequest.md)

## Request example

```json
{
  "document_data": "c3ludGhldGljLWRvY3VtZW50",
  "verify_against_demographics": false
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`AnalyzeIdentityDocumentResponse`](../models/AnalyzeIdentityDocumentResponse.md) | application/json | Extracted identity-document fields |

## Success response examples

### 200

```json
{
  "date_of_birth": "1990-05-15",
  "demographics_match": {
    "date_of_birth": true,
    "name": true
  },
  "document_number": "ID-EXAMPLE-001",
  "document_type": "DRIVER LICENSE FRONT",
  "expiry_date": "2030-05-15",
  "first_name": "Test",
  "issuing_country": "US",
  "last_name": "User",
  "raw_fields": {},
  "verified": true
}
```

## Common errors

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

## Error examples

### 400 — document_data is required

```json
{
  "error": "document_data (base64) is required"
}
```

### 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";
import type { IdentityDocumentRequest } from "@healthcloudai/hc-sdk";
```

```ts
const request = {
  "document_data": "c3ludGhldGljLWRvY3VtZW50",
  "verify_against_demographics": false
};

const result = await patient.scanIdentityDocument(request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"document_data":"c3ludGhldGljLWRvY3VtZW50","verify_against_demographics":false}' \
  'https://dev-api-patient.health.cloud/patients/identity-document'
```

## 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.
