# Get preferred pharmacy

Operation ID: `patient.getPreferredPharmacy`

Return the authenticated patient's preferred-pharmacy FHIR Organization resource, resolved via the patient's `preferred-pharmacy-ref` extension. Requires a patient Bearer JWT.

## Public method

`getPreferredPharmacy`

Signature: `patient.getPreferredPharmacy()`

Return type: `Promise<JsonValue>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /patients/preferred-pharmacy`

## Path parameters

None.

## Query parameters

None.

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`GetPreferredPharmacyResponse`](../models/GetPreferredPharmacyResponse.md) | application/json | The preferred-pharmacy FHIR Organization resource, or null when none is set |

## Success response examples

### 200

```json
{
  "active": true,
  "address": [
    {}
  ],
  "id": "string",
  "identifier": [
    {}
  ],
  "name": "string",
  "resourceType": "Organization",
  "telecom": [
    {}
  ]
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `401` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Authorization required — missing, invalid, expired, or non-patient Bearer JWT |
| `404` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The patient has no preferred pharmacy set, or it could not be resolved |

## Error examples

### 401 — Missing or invalid access token

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

### 404 — No preferred pharmacy is set

```json
{
  "error": "Preferred pharmacy not found"
}
```

## NodeJS / TypeScript implementation

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

```ts
const result = await patient.getPreferredPharmacy();
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-patient.health.cloud/patients/preferred-pharmacy'
```

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