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

# Payer Audit Export

> Select claims from pm_claims and export a CSV documentation package for payer audit response, limited to the 200 most recent claims.

This page enables authorized users to select claims and download a CSV export for payer audit response, accessible at the route `/pm/payer-audit`.

## Overview

The Payer Audit Export page loads up to 200 of the most recent claims from `pm_claims` for the current organization (ordered by `created_at` descending, soft-deleted records excluded). Users can select individual claims via checkboxes or use **Select All on Page** to select all loaded claims. Clicking **Export Selected** generates a CSV file in the browser and triggers a download named `payer-audit-export-<YYYY-MM-DD>.csv`. The CSV contains five columns: Claim #, Patient ID, Service Date, Status, and Payer ID. If no claims are selected when the export button is clicked, a toast error is shown. Users without the required permission see a "You do not have permission to export payer audit packages." error alert instead of the page content.

## Who it's for

Requires permission `PM_PERMISSIONS.COMPLIANCE_REPORTS` (`pm.compliance.reports`), enforced via `RequirePermission` in `src/routes/pm.tsx`. Within the component, `useHasPermission('pm.compliance.reports')` gates the full page content; unauthorized users see a destructive alert.

## Before you start

* Your account must hold the `pm.compliance.reports` permission.
* Claims must exist for the current organization in `pm_claims`.

## Steps

<Steps>
  <Step title="Navigate to Payer Audit Export">
    Go to **Practice Management → Compliance → Payer Audit Export** (route `/pm/payer-audit`). The page loads up to 200 recent claims in a table.
  </Step>

  <Step title="Select claims for export">
    Check individual claim rows using the checkbox in each row, or click **Select All on Page** to select all 200 loaded claims. Use **Clear Selection** to deselect all.
  </Step>

  <Step title="Export the selection">
    Click **Export Selected (n)** where *n* is the count of selected claims. A CSV file is immediately downloaded to your browser with the filename `payer-audit-export-<YYYY-MM-DD>.csv`.
  </Step>

  <Step title="Confirm export">
    A toast notification confirms "Exported n claim(s) to CSV." If no claims are selected, a toast error prompts you to select at least one.
  </Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="CSV columns">
    The exported CSV includes: **Claim #** (`claim_number`), **Patient ID** (`patient_id`), **Service Date** (`service_date_from`), **Status** (`status`), **Payer ID** (`payer_id`). All fields are quoted. Empty values are exported as empty strings.
  </Accordion>

  <Accordion title="200-claim limit">
    The query fetches at most 200 claims ordered by creation date descending. There is no pagination or additional filtering on this page in the current implementation.
  </Accordion>

  <Accordion title="Empty state">
    When no claims are found, an empty state displays "No claims found — No claims available for export."
  </Accordion>

  <Accordion title="Error state">
    If the Supabase query fails, a destructive alert is shown with the sanitized error message.
  </Accordion>
</AccordionGroup>

## 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/PayerAuditExportPage.tsx
  * src/platform/permissions/constants.ts
  * src/integrations/supabase/client.ts
</Accordion>
