Feature ID: PM-02Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Status: ๐ Planned
Last Verified: 2026-02-18
Spec Reference: PM-02-insurance-eligibility-verification.md
Last Updated: 2026-02-18
Table of Contents
- Overview
- Quick Reference
- Decision Trees
- Pattern Library
- Integration Points (from Spec)
- API / Data Contracts
- Labeled Code Examples
- Event Contracts
- Security and RLS
- Common Mistakes
- Pre-Flight Checklist
- Related Docs
Overview
PM-02 provides multiple insurance policies per patient, real-time and batch eligibility verification via X12 270/271 and AHCCCS, benefit detail capture, coordination of benefits, and coverage gap detection. It depends on PM-01 (patient registration); integrates with PM-08 (claims), PM-15 (clearinghouse), and AHCCCS (direct eligibility).Quick Reference
| Item | Value |
|---|---|
| Core tables | pm_insurance_policies, pm_eligibility_checks, pm_payers |
| Key dependencies | PM-01, PM-08, PM-15, AHCCCS |
| Required permissions | pm.insurance.view/manage, pm.eligibility.run, pm.payers.view/manage |
| Traceability | request_trace_id required for external eligibility requests |
Decision Trees
Eligibility execution path
- Select active policy by coverage priority.
- Choose check type (
real_time,batch, ormanual). - Send X12 270/271 through PM-15 or direct AHCCCS path.
- Persist normalized result in
pm_eligibility_checks. - Surface status to PM-08 claims flow gate.
Coverage gap handling
- Evaluate policy effective and termination dates.
- If gap detected, flag workflow and route to staff for remediation.
- Record remediation actions in policy and audit history.
Pattern Library
| Pattern | Usage |
|---|---|
| Data + API dual integration | PM-02 stores policy state and calls PM-15/AHCCCS for verification |
| Request trace contract | External eligibility calls include trace IDs for replay/audit |
| Claims gate pattern | PM-08 checks PM-02 eligibility status before claim submission |
Integration Points (from Spec)
| Dependency | Pattern | Purpose |
|---|---|---|
| PM-01 (Patient Registration) | Data | Patient linked to insurance policies; pm_insurance_policies.patient_id โ pm_patients.id |
| PM-08 (Claims) | Data / Event | Eligibility verified before claim submission; eligibility result informs claim workflow |
| PM-15 (Clearinghouse) | API | 270/271 transactions via clearinghouse; request_trace_id for auditing |
| AHCCCS | API | Direct eligibility verification (member ID, CIS ID, MCO assignment) |
API / Data Contracts
Insurance Policies โ pm_insurance_policies
Invocation pattern: supabase.from('pm_insurance_policies').select(...).eq('organization_id', orgId).eq('patient_id', patientId)Authentication: Supabase JWT; RLS enforces org isolation. Application layer also filters by
organization_id (defense-in-depth).RBAC:
pm.insurance.view (read), pm.insurance.manage (write)Tenant enforcement:
organization_id required on all mutations; RLS USING + WITH CHECK on UPDATE.Idempotency: Policy uniqueness enforced by
UNIQUE(organization_id, patient_id, payer_id, policy_number).
Request schema (Insert):
Eligibility Checks โ pm_eligibility_checks
Invocation pattern: supabase.from('pm_eligibility_checks').insert({ ... }).eq('organization_id', orgId)Authentication: Supabase JWT; RLS enforces org isolation.
RBAC:
pm.eligibility.run (create), pm.insurance.view (read results)Traceability:
request_trace_id REQUIRED for every external 270/271 or AHCCCS call.Caching: Eligibility results cached in
pm_eligibility_checks; use next_check_due to determine when re-verification is needed.Performance SLA: Real-time p95 < 5s; history load p95 < 1s (NFR-1). Request schema (Insert):
Payers โ pm_payers
Invocation pattern: supabase.from('pm_payers').select(...).eq('organization_id', orgId).is('deleted_at', null)RBAC:
pm.payers.view (read), pm.payers.manage (write)Soft delete:
is_active = false for logical disable (hidden from dropdowns); deleted_at for true soft-delete.
PHI Logging Guidelines:
- Allowed log fields:
check_id,patient_id(UUID only),check_type,eligible,organization_id - Prohibited:
benefit_detailscontents,policy_number,subscriber_dob,subscriber_name - Retention: Audit trail in
pf_audit_logs; no PHI in application logs or edge function stdout
Labeled Code Examples
Example: eligibility check request payload
Example: normalized eligibility result with structured benefit_details
Event Contracts
- Outbound: Eligibility check completed may be consumed by PM-08 (claims) or workflow; document in EVENT_CONTRACTS.md if events are added.
- Inbound: None specified in PM-02 spec.
Security and RLS
- RLS on
pm_insurance_policies,pm_eligibility_checks,pm_payers. Use SECURITY DEFINER helpers that resolve organization and profile access viapf_user_role_assignments. All UPDATE policies include WITH CHECK (constitution ยง5.2.4). - Eligibility and benefit data are PHI; no cross-tenant visibility. Permission keys: pm.insurance.view, pm.insurance.manage, pm.eligibility.run, pm.payers.view, pm.payers.manage.
Common Mistakes
| Mistake | Impact | Fix |
|---|---|---|
Missing request_trace_id | Hard-to-debug payer responses | Require trace ID for every external request |
| Ignoring policy priority order | Incorrect COB behavior | Enforce priority_order during checks and claims gating |
| Incomplete RLS WITH CHECK rules | Tenant write leakage | Ensure UPDATE policies include USING + WITH CHECK |
Pre-Flight Checklist
- Validate RLS on all PM-02 tables.
- Validate permission keys and role mappings.
- Validate real-time + batch eligibility test flows.
- Validate PM-08 blocks claims when eligibility is missing/failed.
- Validate AHCCCS and clearinghouse fallback behavior.