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

# Admin Guide — Revenue Matrix & Dashboard Settings

> The Program–Insurance Revenue Matrix (pm_program_insurance_revenue_matrix) stores estimated per-lead revenue by program type and insurance type.

## Revenue Matrix Configuration

The **Program–Insurance Revenue Matrix** (`pm_program_insurance_revenue_matrix`) stores estimated per-lead revenue by program type and insurance type.

### Columns

| Column                       | Type                                                                                | Description                                               |
| ---------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `program_type`               | TEXT                                                                                | Program category (e.g. IOP, PHP, Outpatient, Residential) |
| `insurance_type`             | TEXT (CHECK constraint: `medicaid`, `commercial`, `uninsured`, `medicare`, `other`) | Insurance category                                        |
| `estimated_per_lead_revenue` | NUMERIC                                                                             | Dollar value estimated per converted lead                 |
| `effective_from`             | DATE                                                                                | Start of effective period (NULL = always active)          |
| `effective_to`               | DATE                                                                                | End of effective period (NULL = no end)                   |

### How Revenue Estimates Flow

1. **Screening trigger** → looks up matrix by `(program_type, insurance_type)` → writes `lead_value_estimated` to `pm_analytics_revenue_impact`
2. **Appointment confirmation** → actualizes revenue: `confirmed` → `revenue_realized = estimated`; `no_show` → `revenue_lost = estimated`
3. **Revenue Impact Widget** → aggregates realized vs. lost revenue in the dashboard

### Editing the Matrix

Currently configured via SQL or Supabase dashboard:

```sql theme={null}
INSERT INTO pm_program_insurance_revenue_matrix
  (organization_id, program_type, insurance_type, estimated_per_lead_revenue)
VALUES
  ('your-org-id', 'IOP', 'medicaid', 450),
  ('your-org-id', 'PHP', 'commercial', 800);
```

## Dashboard Settings

These settings are stored in `pm_module_settings` and affect dashboard behavior:

| Setting                                 | Default | Effect                                                                                 |
| --------------------------------------- | ------- | -------------------------------------------------------------------------------------- |
| `ahcccs_compliance_window_hours`        | 72      | Hours within which appointment must be scheduled after screening for AHCCCS compliance |
| `no_show_risk_alert_threshold`          | 50      | Minimum risk score to show in High-Risk Appointments widget                            |
| `waitlist_abandon_risk_alert_threshold` | 50      | Minimum risk score for waitlist abandon alerts                                         |

### Changing Settings

Update via Supabase dashboard or SQL:

```sql theme={null}
UPDATE pm_module_settings
SET ahcccs_compliance_window_hours = 48
WHERE organization_id = 'your-org-id';
```

## Permissions

| Permission              | Grants                                                                                     |
| ----------------------- | ------------------------------------------------------------------------------------------ |
| `pm.intake_funnel.view` | Access to the Intake Funnel Analytics dashboard, compliance report, and benchmarking views |
