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

# Automated Charge Reconciliation — Integration Doc

> Spec: PM-36 Automated Charge Reconciliation Status: ✅ Complete Last Updated: 2026-04-04 Integration Type: Platform Layer (PF-29 tasks) / Data (same-core PM tab…

**Spec:** [PM-36 Automated Charge Reconciliation](../../../specs/pm/specs/PM-36-automated-charge-reconciliation.md)\
**Status:** ✅ Complete\
**Last Updated:** 2026-04-04\
**Integration Type:** Platform Layer (PF-29 tasks) / Data (same-core PM tables) / Scheduled Edge Function

***

## Overview

PM-36 adds nightly automated charge reconciliation: an edge function scans all orgs for five gap types (encounter→charge, charge→claim, claim→payment, duplicate charges, zero-amount charges) and creates PF-29 tasks for each gap. Summary rollups feed the PM-11 Revenue Cycle Dashboard.

***

## Integration Points

### PF-29 (Tasks) — Platform Integration Layer

| Field            | Value                                                                      |
| ---------------- | -------------------------------------------------------------------------- |
| Integration type | Platform Layer (`@/platform/tasks`)                                        |
| Direction        | PM-36 → PF-29 (write)                                                      |
| Trigger          | Nightly edge function per org                                              |
| Contract         | TODO(`#1234`): link to API\_CONTRACTS.md entry when tasks API is published |

**Payload created per gap:**

```typescript theme={null}
{
  source_type: 'charge_reconciliation',
  source_id: reconciliation_result.id,   // pm_charge_reconciliation_results.id
  organization_id: org.id,
  title: `<gap_type> — <days_outstanding> days`,
  // assigned_to: null (biller self-assigns from task queue)
  // status: 'open'
}
```

### PM-07 (Charge Capture) — Same-Core Data

* PM-36 reads `pm_charges` to detect `encounter_no_charge` gaps
* No event contract; direct table query within same core

### PM-08 (Claims Management) — Same-Core Data

* PM-36 reads `pm_claims` to detect `charge_no_claim` gaps
* No event contract; direct table query within same core

### PM-09 (Payment Posting) — Same-Core Data

* PM-36 reads `pm_payments` to detect `claim_no_payment` gaps
* No event contract; direct table query within same core

### PM-11 (Revenue Cycle Dashboard) — Shared Table

* PM-36 populates `pm_charge_recon_daily_summary` (1 row per org per night)
* PM-11 queries `pm_charge_recon_daily_summary` for gap count KPIs, charge lag, and 30/60/90-day trends
* Integration: shared table within same core; no event needed

***

## Pending Contracts

| Dependency                               | Spec  | Status                                   | Blocker                                          |
| ---------------------------------------- | ----- | ---------------------------------------- | ------------------------------------------------ |
| PF-29 `createTask()` platform API shape  | PF-29 | TODO: confirm `@/platform/tasks` exports | Needed before Phase 2                            |
| Real-time reconciliation event contracts | PM-07 | Not yet designed                         | Deferred; blocks PM-36 Phase 2 real-time feature |
| FA cross-core reconciliation contracts   | FA    | Not yet designed                         | Deferred; blocks cross-core reconciliation       |

***

## Permissions

| Key                      | Purpose                                                                      |
| ------------------------ | ---------------------------------------------------------------------------- |
| `pm.charge_recon.view`   | View reconciliation results and trends (Results list, PM-11 dashboard cards) |
| `pm.charge_recon.manage` | Resolve gaps, configure thresholds (Resolve action, PM-28 settings)          |

Seed to: Billing Manager, Org Admin roles.

***

## Security

* All `pm_charge_reconciliation_results` and `pm_charge_recon_daily_summary` rows are scoped by `organization_id`
* RLS uses `pm_has_org_access(organization_id, auth.uid())` (SECURITY DEFINER)
* Edge function uses service-role key; PHI (patient\_id) must not appear in logs
* See PM-36 spec Security Considerations for full detail

***

### PF-96 (Jurisdiction Profiles) — Read-Only

* PM-36 uses org-level `pm_module_settings` thresholds for v1
* Phase 2 enhancement: baseline thresholds read from PF-96 jurisdiction profile, with org settings as overrides
* No direct PF-96 table dependency in v1; listed for architecture awareness
* **API Contract:** See [API\_CONTRACTS.md § PF-96](./API_CONTRACTS.md#pf-96-jurisdiction-profile-resolution) and [PF-96 Integration Doc](./medicaid-state-compliance-configuration-integration.md) for resolver function signatures and fallback semantics

***

## Integration Matrix Entry

See `CROSS_CORE_INTEGRATIONS.md` — PM (PM-36) row.
