# Get a field agent's dashboard

Operation ID: `fieldagent.getAgentDashboard`

Return same-day activity counts (patients, encounters, diagnostic reports) for one field agent, based on FHIR `_lastUpdated` — a resource counts on the day it was last modified, not necessarily created. Counts are tenant-wide (not filtered to resources this agent created); assigned_patients/recent_encounters/pending_tasks/alerts are reserved for future use and are always empty today. Only the agent themselves may view their own dashboard.

## Public method

`getDashboard`

Signature: `fieldAgent.getDashboard(fhirPersonId, query)`

Return type: `Promise<FieldAgentDashboardResponse>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`GET /agents/{agent_id}/dashboard`

## Path parameters

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

## Query parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `date` | `string` | No | date |  |  | No | Dashboard date; defaults to today |

## Body parameters

None.

Request model: None.

## Request example

None declared in canonical OpenAPI.

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`AgentDashboardResponse`](../models/AgentDashboardResponse.md) | application/json | Dashboard counts for the requested (or today's) date |

## Success response examples

### 200

```json
{
  "agent_id": "agent-example-001",
  "alerts": [],
  "assigned_patients": [],
  "counts": {
    "patients": 3,
    "test_results": 0,
    "tests": 2
  },
  "date": "2026-01-01",
  "pending_tasks": [],
  "recent_encounters": [],
  "summary": {
    "patients": 3,
    "test_results": 0,
    "tests": 2
  }
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | ?date= is not a valid ISO 8601 date |
| `401` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `403` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | The authenticated caller does not own this agent profile |
| `404` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | No agent profile exists for the given agent_id |
| `500` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | Internal server error |

## Error examples

### 400 — The date query parameter could not be parsed

```json
{
  "error": "Invalid date format — expected YYYY-MM-DD"
}
```

### 401 — Missing or invalid access token

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

### 403 — The JWT caller's cognito_sub does not match the agent's

```json
{
  "error": "You may only access your own agent profile"
}
```

### 404 — No FHIR Person exists for agent_id

```json
{
  "error": "Agent not found"
}
```

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

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

## NodeJS / TypeScript implementation

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

```ts
const fhirPersonId = "<FHIR_PERSON_ID>";

const query = {
  "date": "<DATE>"
};

const result = await fieldAgent.getDashboard(fhirPersonId, query);
```

## cURL

```bash
curl -X GET \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  'https://dev-api-fieldagent.health.cloud/agents/%3CAGENT_ID%3E/dashboard?date=%3CDATE%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.
