# List encounters

Operation ID: `fieldagent.listEncounters`

List FHIR encounters visible to the field agent, scoped to the caller's tenant (resolved from the Bearer JWT) — not to the calling agent's own encounters, unless ?created_by= is also supplied. When ?created_by= is set, results are over-fetched up to 10x limit (capped at 200) and filtered client-side, since FHIR has no native search parameter for the custom created-by extension. An invalid ?status= value is not distinguished from any other failure — it surfaces as a 500, not a 400.

## Public method

`listEncounters`

Signature: `fieldAgent.listEncounters(query)`

Return type: `Promise<ListAgentEncountersResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /encounters`

## Path parameters

None.

## Query parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `created_by` | `string` | No |  |  |  | No | Person FHIR ID — only encounters created by this agent |
| `limit` | `integer` | No |  |  | `20` | No |  |
| `patient_id` | `string` | No |  |  |  | No | Filter by FHIR Patient ID |
| `status` | `string` | No |  | planned, in-progress, finished, cancelled |  | No |  |

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`fieldagent.ListEncountersResponse`](../models/fieldagent.ListEncountersResponse.md) | application/json | Tenant-scoped encounter list |

## Success response examples

### 200

```json
{
  "created_by": "string",
  "encounters": [
    {
      "appointment_id": "string",
      "athena_appointment_id": "string",
      "athena_encounter_id": "string",
      "created_by": "self",
      "created_date": "2026-01-01T09:00:00Z",
      "diagnoses": [
        {
          "condition_display": "string",
          "condition_id": "string",
          "rank": 1,
          "use_code": "CC"
        }
      ],
      "encounter_class": "AMB",
      "encounter_id": "00000000-0000-0000-0000-000000000000",
      "fhir_id": "string",
      "hospitalization": {
        "admit_source_code": "string",
        "destination_id": "string",
        "discharge_disposition": "home",
        "origin_id": "string",
        "pre_admission_id": "string",
        "re_admission_code": "string"
      },
      "length_minutes": 0,
      "locations": [
        {
          "location_display": "string",
          "location_id": "string",
          "period_end": "2026-01-01T09:00:00Z",
          "period_start": "2026-01-01T09:00:00Z",
          "status": "active"
        }
      ],
      "notes": "string",
      "openloop_appointment_id": "string",
      "openloop_encounter_id": "string",
      "participants": [
        {
          "participant_type": "PPRF",
          "period_end": "2026-01-01T09:00:00Z",
          "period_start": "2026-01-01T09:00:00Z",
          "practitioner_display": "string",
          "practitioner_id": "string"
        }
      ],
      "patient_id": "string",
      "period_end": "2026-01-01T09:00:00Z",
      "period_start": "2026-01-01T09:00:00Z",
      "priority_code": "string",
      "priority_display": "string",
      "reason_code": "string",
      "reason_display": "string",
      "service_provider_display": "string",
      "service_provider_id": "string",
      "service_type_code": "string",
      "service_type_display": "string",
      "status": "planned",
      "steadymd_consult_guid": "string",
      "steadymd_episode_guid": "string",
      "type_code": "string",
      "type_display": "string"
    }
  ],
  "patient_id": "string",
  "total": 0
}
```

## Common errors

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

## Error examples

### 401 — Missing or invalid access token

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

### 500 — ?status= is not a recognized EncounterStatus value (sanitized example)

```json
{
  "error": "'not-a-real-status' is not a valid EncounterStatus"
}
```

## NodeJS / TypeScript implementation

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

```ts
const query = {
  "created_by": "<CREATED_BY>",
  "limit": 20,
  "patient_id": "<PATIENT_ID>",
  "status": "planned"
};

const result = await fieldAgent.listEncounters(query);
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-fieldagent.health.cloud/encounters?created_by=%3CCREATED_BY%3E&limit=20&patient_id=%3CPATIENT_ID%3E&status=planned'
```

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