Skip to main content
Feature ID: PM-02
Status: 📝 Planned
Last Verified: 2026-02-18
Spec Reference: PM-02-insurance-eligibility-verification.md
Last Updated: 2026-02-18

Table of Contents


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


Decision Trees

Eligibility execution path

  1. Select active policy by coverage priority.
  2. Choose check type (real_time, batch, or manual).
  3. Send X12 270/271 through PM-15 or direct AHCCCS path.
  4. Persist normalized result in pm_eligibility_checks.
  5. Surface status to PM-08 claims flow gate.

Coverage gap handling

  1. Evaluate policy effective and termination dates.
  2. If gap detected, flag workflow and route to staff for remediation.
  3. Record remediation actions in policy and audit history.

Pattern Library


Integration Points (from Spec)


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_details contents, policy_number, subscriber_dob, subscriber_name
  • Retention: Audit trail in pf_audit_logs; no PHI in application logs or edge function stdout
Error response schema:

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 via pf_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


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.