> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Statement Runs

> Generate and track patient statement cycles, viewing run history with type, status, statement counts, and per-run detail.

The Statement Runs screen (`/pm/statements`) lists all statement run records for the current organization and allows users with the appropriate permission to trigger new runs.

<Frame caption="Statement Runs — patient statement cycle history with type, status, and counts.">
  <img src="https://mintcdn.com/encoreos/FHgwdEuPbyKq-W7P/images/pm-revenue/statements-overview.png?fit=max&auto=format&n=FHgwdEuPbyKq-W7P&q=85&s=6bbb242a15ef14165bdc7be212f57a33" alt="Statement Runs screen showing the run history table and New Statement Run action" width="1440" height="900" data-path="images/pm-revenue/statements-overview.png" />
</Frame>

## Overview

The screen renders a "Run History" table ordered by `run_started_at` descending. Each row links to the run detail page (`/pm/statements/:runId`) via the started timestamp, and shows the run type (Scheduled or On Demand), a status badge (Running, Completed, Failed, Cancelled), the count of statements generated, and the completion timestamp. The page wraps its content in a `PermissionGate` so it renders only for users with `pm.statements.view`. Users with `pm.statements.generate` see a "New Statement Run" button in the header.

## Who it's for

Requires the `pm.statements.view` permission. Triggering a new statement run additionally requires `pm.statements.generate`.

## Before you start

* The `pm.statements.view` permission must be granted for the user's role.
* An organization must be selected; the hook returns an empty array when no org is active.

## Steps

<Steps>
  <Step title="View run history">
    The Run History table loads automatically. Each row shows the started timestamp (linked to detail), run type, status, statements generated, and completion time.
  </Step>

  <Step title="Open a run detail">
    Click the started timestamp link in any row to navigate to the statement run detail page at `/pm/statements/:runId`.
  </Step>

  <Step title="Trigger a new statement run">
    Users with `pm.statements.generate` can click "New Statement Run" to open `StatementRunTriggerDialog`. After submission, the list invalidates and the new run appears at the top.
  </Step>
</Steps>

## Key concepts

<Tooltip tip="A batch job that generates patient statements for an organization at a point in time.">Statement run</Tooltip>

<AccordionGroup>
  <Accordion title="Empty and error states">
    When no runs exist, an empty state reads "No statement runs yet — Create a new run to generate patient statements." If the fetch fails, an error message reads "Failed to load statement runs" with a Retry button that reloads the page.
  </Accordion>
</AccordionGroup>

## Viewing a statement run

The Statement Run Details page displays summary information for a completed or in-progress statement generation run at route `/pm/statements/:runId` (permission: `pm.statements.view`).

`StatementRunDetailPage` loads a run record via `useStatementRunDetail` keyed by `runId`. It displays:

* Run type (using `STATEMENT_RUN_TYPE_LABELS`)
* Status badge (using `STATEMENT_RUN_STATUS_LABELS` and `STATEMENT_RUN_STATUS_VARIANT`)
* Start timestamp formatted as month/day/year hour:minute AM/PM

Breadcrumbs link back to `/pm/statements`. Content is gated by `pm.statements.view` via `PermissionGate`. A three-column summary grid is rendered.

1. Navigate to **Practice Management → Statements**, select a run from the list, or go to `/pm/statements/:runId`.
2. The summary shows run type, start timestamp, and status badge. Additional columns may display further run metadata.

* **Statement run status** — reflects whether the run is in progress, completed, or errored; rendered from `STATEMENT_RUN_STATUS_LABELS`.
* **Run type** — the category of statement generated (e.g., batch vs. individual); rendered from `STATEMENT_RUN_TYPE_LABELS`.

## Related

<Columns cols={2}>
  <Card title="Practice Management" icon="briefcase" href="/pm/overview">
    Overview of the Practice Management core.
  </Card>

  <Card title="Governance & parity" icon="scale-balanced" href="/governance/index">
    Documentation coverage and governance.
  </Card>
</Columns>

<Note>
  This page documents shipped product behavior. It is not medical, legal, or
  billing advice. Verify against your organization's policies and applicable
  regulations before using it for clinical, compliance, or billing decisions.
  Protected health information (PHI) shown in the product is governed by your
  tenant's access controls and is never exposed in this documentation.
</Note>

<Accordion title="Documentation sources">
  * src/routes/pm.tsx
  * src/cores/pm/pages/StatementRunListPage.tsx
  * src/cores/pm/hooks/useStatementRuns.ts
  * src/cores/pm/types/statement-billing.ts
  * src/cores/pm/pages/StatementRunDetailPage.tsx
</Accordion>
