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

# Clinical Order Sets & Standing Orders (Admin Guide)

> Audience: Clinical administrators, compliance leads Status: Draft (WS5 pending — content subject to refinement) Last Updated: 2026-05-08

**Audience:** Clinical administrators, compliance leads
**Status:** Draft (WS5 pending — content subject to refinement)
**Last Updated:** 2026-05-08

***

## Feature Flag

CL-44 is gated by `cl_module_settings.order_sets_enabled` (boolean, default **true**). Disable it to hide order set navigation, the chart quick action, and the management pages. The standing order protocol UI remains independent of this flag.

## Module Settings

| Setting                              | Default | Purpose                                           |
| ------------------------------------ | ------- | ------------------------------------------------- |
| `order_sets_enabled`                 | `true`  | Master feature flag                               |
| `order_set_max_items`                | `50`    | Soft cap enforced in the template editor          |
| `standing_order_default_expiry_days` | `365`   | Default protocol expiration when none is supplied |

## Permissions Mapping

Seeded by migration `20260508131517_*`:

| Role             | Permissions granted                                                                                     |
| ---------------- | ------------------------------------------------------------------------------------------------------- |
| `platform_admin` | All seven CL-44 permissions                                                                             |
| `staff`          | `cl.order_sets.view`, `cl.order_sets.activate`, `cl.standing_orders.view`, `cl.standing_orders.execute` |
| `readonly`       | `cl.order_sets.view`, `cl.standing_orders.view`                                                         |

Adjust per-role mappings via the platform permission management UI as needed.

## Database Surface (Phase 1)

* `cl_order_set_templates` — versioned templates (`status`: draft, approved, retired)
* `cl_order_set_activations` — per-patient activation log; references `cl_charts` and `pm_patients`
* `cl_clinical_standing_orders` — protocol definitions with parameter ranges and effective/expiration dates
* `cl_standing_order_executions` — append-only execution log (no UPDATE/DELETE policy by design)

All tables are tenant-scoped via `cl_has_org_access(organization_id, auth.uid())` with `FORCE ROW LEVEL SECURITY` enabled.

## Operational Notes

* **Append-only executions:** corrections must be issued as compensating executions; do not attempt UPDATE/DELETE — RLS will reject them.
* **Frequency enforcement** is implemented client-side in `useStandingOrderExecutions` (`frequencyLimit: { count, windowHours }`) before insertion. A future migration will add a server-side trigger if abuse is observed.
* **CL-09 EN-30 coexistence:** the legacy lab-only `cl_standing_order_protocols` and `StandingOrderProtocolsPage` remain unchanged at `/cl/settings/standing-orders`. CL-44's cross-category protocols live at `/cl/standing-orders`.

## Related

* Spec: `specs/cl/specs/CL-44-clinical-order-sets-standing-orders.md`
* User guide: [`order-sets-user-guide.md`](./order-sets-user-guide.md)
* Tasks: `specs/cl/tasks/CL-44-TASKS.md`
