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

# Batch Operations & Bulk Processing — Integration Document

> Feature ID: PM-24 Version: 1.0 Status: ✅ Complete Created: 2026-03-01

**Feature ID:** PM-24\
**Version:** 1.0\
**Status:** ✅ Complete\
**Created:** 2026-03-01

***

## Integration Summary

PM-24 is **PM-internal only** — it does not introduce cross-core dependencies. All batch operations consume existing PM entities (charges, claims, eligibility checks) and write to the new `pm_batch_jobs` audit table.

## Integration Points

| From  | To                    | Pattern          | Description                                                                                |
| ----- | --------------------- | ---------------- | ------------------------------------------------------------------------------------------ |
| PM-24 | PM-07 (Charges)       | Data (same core) | Batch claim generation reads approved charges; batch charge approval updates charge status |
| PM-24 | PM-08 (Claims)        | Data (same core) | Batch claim generation creates claims/lines; batch submission transitions claim status     |
| PM-24 | PM-02 (Eligibility)   | Data (same core) | Batch eligibility creates pm\_eligibility\_checks records                                  |
| PM-24 | PM-15 (Clearinghouse) | Data (same core) | Batch submission uses clearinghouse adapter pattern                                        |
| PM-24 | PF-30 (Permissions)   | Platform Layer   | 4 permission keys: pm.batch.claim\_generate/submit/eligibility/charge\_approve             |

## Data Flow

```
User selects items (charges/claims/appointments)
  → BatchSelectionToolbar validates count ≤ batch_size_max
    → Batch hook creates pm_batch_jobs row (status: pending)
      → Sequential processing with progress tracking
        → pm_batch_jobs updated (processed_count, error_count, errors, status)
          → BatchProgressDialog shows results
```

## Database Entities

* `pm_batch_jobs` — Audit/progress tracking (no DELETE policy)
* `pm_module_settings.batch_size_max` — Max items per batch (default 200)
* `pm_module_settings.batch_async_threshold` — Async threshold (default 50)

## Security

* RLS via `pm_has_org_access()` (SELECT, INSERT, UPDATE with WITH CHECK)
* `organization_id` immutability trigger
* FORCE ROW LEVEL SECURITY enabled
* Error messages sanitized before persisting to `pm_batch_jobs.errors`

## Deferred

* Edge function async execution for large batches
* Real-time progress via Supabase Realtime subscriptions
* Scheduled/cron batch operations
