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

# Medicaid State Compliance Configuration — Integration Documentation

> Spec: specs/pf/specs/PF-96-medicaid-state-compliance-configuration.md Owner: PF (Platform Foundation) Created: 2026-03-29

**Spec:** `specs/pf/specs/PF-96-medicaid-state-compliance-configuration.md`
**Owner:** PF (Platform Foundation)
**Created:** 2026-03-29

***

## Integration Overview

PF-96 provides the **jurisdiction profile system** — a multi-tier configuration layer that decouples state-specific Medicaid compliance rules from hardcoded constants. It is consumed by CL, PM, and PF features via a resolution function and frontend hook.

***

## Platform Integration Layer

**Location:** `src/platform/jurisdiction/`

**Public API:**

| Export                            | Type                 | Purpose                                                   |
| --------------------------------- | -------------------- | --------------------------------------------------------- |
| `useJurisdictionProfile(siteId?)` | React hook           | Resolve effective profile for current org + optional site |
| `useClinicalRules(siteId?)`       | React hook           | Convenience accessor for clinical rule pack               |
| `useBillingRules(siteId?)`        | React hook           | Convenience accessor for billing rule pack                |
| `useComplianceRules(siteId?)`     | React hook           | Convenience accessor for compliance rule pack             |
| `JurisdictionProfile`             | TypeScript interface | Resolved profile shape                                    |
| `ClinicalRules`                   | TypeScript interface | Clinical rule pack                                        |
| `BillingRules`                    | TypeScript interface | Billing rule pack                                         |
| `ComplianceRules`                 | TypeScript interface | Compliance rule pack                                      |

**Edge Function Helper:**

| Export                                           | Location                                     | Purpose                        |
| ------------------------------------------------ | -------------------------------------------- | ------------------------------ |
| `getJurisdictionProfile(client, orgId, siteId?)` | `supabase/functions/_shared/jurisdiction.ts` | Server-side profile resolution |

***

## Event Contracts

### Events Published

**`pf_jurisdiction_profile_changed`**

* **Publisher:** PF-96 (on org/site jurisdiction config change)
* **Subscribers:** CL-02, CL-04, CL-40, PM-07, PM-08, PM-41, PF-91
* **Payload Schema:**

  ```typescript theme={null}
  {
    event_id: string; // UUID - unique event identifier for deduplication
    organization_id: string; // UUID
    site_id?: string; // UUID, present if site-level change
    old_profile_code: string; // e.g. "az-ahcccs"
    new_profile_code: string; // e.g. "ca-medi-cal"
    changed_by: string; // UUID of user who made the change
  }
  ```
* **Status:** ✅ Complete

### Events Consumed

| Event                     | Source | Purpose                                                      |
| ------------------------- | ------ | ------------------------------------------------------------ |
| `pf_organization_created` | PF-01  | Set default federal baseline jurisdiction profile on new org |
| `pf_site_created`         | PF-19  | Prompt for jurisdiction profile if org is multi-state        |

***

## API Contracts

### RPC Functions

**`pf_resolve_jurisdiction_profile(p_org_id UUID, p_site_id UUID DEFAULT NULL)`**

* **Type:** PostgreSQL RPC (SECURITY DEFINER)
* **Returns:** `JSONB` — Merged profile with `{ profile_id, state_code, program_code, display_name, clinical, billing, compliance }`
* **Consumers:** All CL/PM features, PF-91 compliance dashboard, edge functions
* **Resolution Order:** Federal baseline → State profile → Org overrides → Site overrides
* **Status:** ✅ Complete

***

## Consumer Integration Points

| Consumer Spec                | What It Reads                                                                   | How It Integrates                                |
| ---------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------ |
| CL-02 (Assessments)          | `clinical.assessment_required_elements`, `clinical.assessment_completion_hours` | `useClinicalRules()` hook                        |
| CL-04 (Progress Notes)       | `clinical.documentation_timeliness_hours`, `clinical.required_note_elements`    | `useClinicalRules()` hook                        |
| CL-11 (Consent)              | `clinical.minor_consent_age`, `clinical.sud_confidentiality_standard`           | `useClinicalRules()` hook                        |
| CL-40 (Intake)               | `clinical.intake_assessment_type`                                               | `useClinicalRules()` hook / edge function helper |
| PM-07 (Charge Capture)       | `billing.min_billable_minutes`, `billing.modifier_conventions`                  | `useBillingRules()` hook                         |
| PM-08 (Claims)               | `billing.filing_deadline_days`                                                  | `useBillingRules()` hook                         |
| PM-10 (Prior Auth)           | `billing.bhrf_urgent_pa_exempt_days`                                            | `useBillingRules()` hook                         |
| PM-18 (Scrub Rules)          | `billing.modifier_conventions`                                                  | `getJurisdictionProfile()` edge fn               |
| PM-41 (Compliance Reports)   | `billing.compliance_window_hours`                                               | `getJurisdictionProfile()` edge fn               |
| PF-91 (Compliance Dashboard) | All rule packs                                                                  | `useJurisdictionProfile()` hook                  |

***

## Security

* **RLS:** All three tables have RLS + FORCE enabled
* **Profile access:** All authenticated users can read active profiles (shared reference data)
* **Config access:** Org-scoped via `pf_has_org_access()`; admin writes via `pf_has_org_role()`
* **Federal baseline enforcement:** `pf_validate_jurisdiction_override()` trigger prevents weakening federal requirements
* **No PHI:** Profiles contain configuration data only; no patient data

***

## References

* [PF-96 Spec](../../../specs/pf/specs/PF-96-medicaid-state-compliance-configuration.md)

* [PF-96 Migration Plan](../../../specs/cross-cutting/PF-96-MIGRATION-PLAN-ahcccs-to-jurisdiction-profiles.md)

* [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md)

* [constitution.md](../../../constitution.md) §5.1, §5.2.2
