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

# Configurable Claim Scrubbing & Org Edit Rules — Integration

> Version: 1.1.0 Status: ✅ Implemented Last Updated: 2026-03-27 Spec: PM-18 Configurable Claim Scrubbing & Org Edit Rules Constitution Reference: Section 1.2 (Co…

**Version:** 1.1.0\
**Status:** ✅ Implemented\
**Last Updated:** 2026-03-27\
**Spec:** [PM-18 Configurable Claim Scrubbing & Org Edit Rules](../../../specs/pm/specs/PM-18-configurable-claim-scrubbing.md)\
**Constitution Reference:** Section 1.2 (Core Independence), Section 1.3 (Integration Patterns)

***

## Overview

PM-18 extends PM-08 claim scrubbing with organization-level overrides for system scrub rules (enabled, severity, optional config). The scrubbing engine remains internal; no new public API or event contracts. Overrides are stored in `pm_scrub_rule_overrides`; definitions in `pm_scrub_rule_definitions` (seeded, read-only).

**Key tables:** `pm_scrub_rule_definitions`, `pm_scrub_rule_overrides`, `pm_scrub_custom_edits` (EN-06)\
**RLS:** `pm_scrub_rule_overrides` and `pm_scrub_custom_edits` (SELECT/INSERT/UPDATE with WITH CHECK via `pm_has_org_access`; DELETE via `pf_is_org_admin()`). Definitions are system-wide read-only.

***

## Enhancement: PM-EN-06 — Per-Payer Custom Scrub Rules

**Spec:** [PM-18-EN-06 Per-Payer Custom Scrub Rules](../../../specs/pm/specs/PM-18-EN-06-per-payer-custom-scrub-rules.md)

EN-06 extends PM-18 with:

* **Per-payer/claim-type overrides:** `payer_id` and `claim_type` columns added to `pm_scrub_rule_overrides`; override priority: payer+type → payer-only → org-wide.
* **Custom edits:** New `pm_scrub_custom_edits` table for org-defined rules with condition expressions (single/compound), severity, message templates, and scope (claim/line).
* **Effectiveness reporting:** Per-rule pass/fail/warning rate from `pm_claim_notes` scrub\_error entries, with date range presets and per-payer filter.
* **Permission:** `pm.settings.scrub_rules.payer` gates per-payer override and custom edit management.
* **PF-70 dependency:** Active (not Phase 2) for code-type field validation in custom edit conditions.

***

## Integration Points

| Dependency       | Pattern              | Status        | Purpose                                                                                                                              | Note                                                                                                                                                |
| ---------------- | -------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **PM-08**        | Internal (same core) | ✅ Implemented | Claim scrubbing is part of PM-08; PM-18 adds configurable overrides. Engine loads org overrides and applies them when running scrub. | PM-18 extends PM-08 behavior.                                                                                                                       |
| **PF-70**        | Platform             | ✅ Implemented | Phase 1: PF-70 validates code-type fields (CPT, ICD-10, HCPCS) for custom edit conditions in EN-06.                                  | EN-06 custom edits rely on PF-70 Phase 1 code validation (`@/platform/codes`); scrub UI/engine consumption per PM-18/EN-06 implementation schedule. |
| **PF-01, PF-02** | Platform             | ✅ Implemented | Identity, tenancy.                                                                                                                   | Existing platform dependencies already in use.                                                                                                      |

***

## API Contracts

No new public API. Scrubbing is invoked internally by PM-08 claim detail/generate flows; engine accepts `organizationId` and uses PM-18 overrides when present. Contract remains existing `ScrubResult` shape (isValid, errors\[]). EN-06 adds `rule_key` to custom edit errors for traceability.

***

## Event Contracts

None. PM-18 does not publish or subscribe to events.

***

## Tenant Isolation & Auth

* All override access is scoped by `organization_id` via RLS on `pm_scrub_rule_overrides` and `pm_scrub_custom_edits`.
* UI for managing overrides is gated by `pm.settings.scrub_rules` (org-wide) and `pm.settings.scrub_rules.payer` (per-payer/custom edits).
* No PHI in rule definitions, overrides, or custom edits; rule execution operates on claim/line data already protected by PM-08 RLS.

***
