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

# Patient Statement Generation & Billing Communications — Integration

> Version: 1.0.0 Last Updated: 2026-02-23 Status: ✅ Implemented Last Verified: 2026-02-23 Spec: PM-16-patient-statement-generation-billing-communications

**Version:** 1.0.0\
**Last Updated:** 2026-02-23\
**Status:** ✅ Implemented\
**Last Verified:** 2026-02-23
**Spec:** [PM-16-patient-statement-generation-billing-communications](../../../specs/pm/specs/PM-16-patient-statement-generation-billing-communications.md)

***

## Overview

PM-16 adds statement cycle orchestration, multichannel delivery (print/email/portal), payment plans, and financial assistance workflow. It depends on PF and same-core PM features only; no cross-core imports.

## Quick Reference

| I need to…                                    | Pattern                                         | Location                                                       |
| --------------------------------------------- | ----------------------------------------------- | -------------------------------------------------------------- |
| Generate/send statement communications safely | PF-10 notifications + PHI-safe payload IDs only | [Security & Tenant Isolation](#security--tenant-isolation)     |
| Persist statement artifacts                   | PF-11 documents integration                     | [Contract: Platform Foundation](#contract-platform-foundation) |
| Align billing state with existing PM records  | PM-09 statement/payment linkage                 | [Contract: Same-Core (PM)](#contract-same-core-pm)             |

***

## Integration Matrix

| Integration                | Spec          | Direction  | Pattern                    | Status     |
| -------------------------- | ------------- | ---------- | -------------------------- | ---------- |
| Organizations & Sites      | PF-01         | PM-16 → PF | Direct                     | 📝 Planned |
| RBAC / Permissions         | PF-02 (PF-30) | PM-16 → PF | Direct                     | 📝 Planned |
| Notifications (email)      | PF-10         | PM-16 → PF | Platform Integration Layer | 📝 Planned |
| Documents (statement PDFs) | PF-11         | PM-16 → PF | Platform Integration Layer | 📝 Planned |
| Payments & statement table | PM-09         | PM-16 → PM | Same core                  | 📝 Planned |
| Patient portal posting     | PM-12         | PM-16 → PM | Same core                  | 📝 Planned |

### Cross-Core Summary (CROSS\_CORE\_INTEGRATIONS.md)

This row matches the central matrix format for alignment with [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md):

| From Core  | To Core                    | Integration Pattern   | Status | Documentation                                                                                                                       |
| ---------- | -------------------------- | --------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| PM (PM-16) | PF-10, PF-11, PM-09, PM-12 | Platform Layer / Data | 📝     | [PM-16 Patient Statement Generation & Billing Communications](./patient-statement-generation-billing-communications-integration.md) |

***

## Contract: Platform Foundation

### PF-01 (Organizations & Sites)

* **Usage:** Tenant context (`organization_id`, optional `site_id`) on all PM-16 tables; RLS and app-level filtering.
* **Contract:** Standard multi-tenant pattern; no custom API.

### PF-02 / PF-30 (Permissions)

* **Usage:** Permission keys `pm.statements.*`, `pm.payment_plans.*`, `pm.financial_assistance.*` for UI and actions.
* **Contract:** Keys defined in spec; seeded in migration; checks via `pf_has_permission()`.

### PF-10 (Notifications)

* **Usage:** Email delivery of statements / billing communications.
* **Contract:** Use `@/platform/notifications` (Platform Integration Layer). Payload and template TBD in implementation.

### PF-11 (Documents)

* **Usage:** Statement PDF generation and storage; portal and print consumption.
* **Contract:** Use `@/platform/documents` (Platform Integration Layer). Document type and metadata TBD in implementation.

***

## Contract: Same-Core (PM)

### PM-09 (Payments & statement table)

* **Usage:** Payment artifacts and existing statement table; payments update balances and statuses used by PM-16.
* **Contract:** Direct table access within PM; align statement run and delivery tables with PM-09 data model.

### PM-12 (Patient portal)

* **Usage:** Portal posting of statements; patient-facing billing view.
* **Contract:** Direct PM hooks/queries; statement visibility and download via portal scope (patient + org).

***

## Event Contracts

No cross-core events required for PM-16. Internal events (e.g., statement\_run\_completed, delivery\_attempt\_recorded) may be added for audit or workflow; document in [EVENT\_CONTRACTS.md](EVENT_CONTRACTS.md) if added.

***

## API Contracts

No public cross-core APIs. Internal PM hooks and edge functions (e.g., statement generation, delivery trigger) to be documented in implementation tasks.

***

## Security & Tenant Isolation

* All PM-16 data scoped by `organization_id`; RLS and app-level filter on every mutation.
* PHI: statement and payment-plan data; no PHI in logs; access via RLS and permission keys only.
* Integration with PF-10/PF-11: no PHI in notification payloads; use **system-generated UUIDs only** (e.g. `patient_id`, `statement_id`, `organization_id`); resolve display names and account details via **authorized API calls in the UI**; document the retrieval pattern in implementation. **Must not** include in payloads: patient names, MRNs, DOBs, account numbers. **Acceptable:** patient UUID, statement ID, organization ID.

***

## Open Items

* [ ] Finalize statement PDF format and storage location (PF-11).
* [ ] Define email template and notification payload for statement delivery (PF-10).
* [ ] Confirm PM-09 table names and columns for statement/balance linkage.
* [ ] Add CROSS\_CORE\_INTEGRATIONS.md row if any cross-core integration is added later.
