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

# Order Sets

> Manage reusable order set templates for clinical workflows, stored in cl_order_set_templates.

This screen is the Order Set Management page, accessible at `/cl/order-sets`. It administers rows in `cl_order_set_templates` for the current organization.

## Overview

The Order Sets page lists all active (non-retired, non-deleted) `cl_order_set_templates` for the current organization, sorted alphabetically by name. A search bar filters by template name or category. Users with `cl.order_sets.manage` see a **New Order Set** button that opens `OrderSetTemplateDialog`. Each listed template has **Edit** and **Delete** actions; deletion is a soft-delete (sets `deleted_at`) and requires confirmation.

If `cl_module_settings.order_sets_enabled` is false, the list is replaced by an empty state reading "Order sets are disabled — Ask an administrator to enable order sets in CL module settings." No data is fetched in that case.

Templates have a `status` field; `useOrderSetTemplates` by default excludes `retired` templates unless `includeRetired` is passed as `true` (the page passes `true`, so retired templates are visible to administrators).

## Who it's for

Requires permission: `cl.order_sets.view`

Creating, editing, or deleting templates additionally requires: `cl.order_sets.manage`

## Before you start

* You must hold `cl.order_sets.view` to access this route.
* The `cl_module_settings.order_sets_enabled` setting must be `true` (or not explicitly set to `false`). If it is false, no order sets are accessible and an administrator must enable them in CL module settings.
* To create or modify templates, you additionally need `cl.order_sets.manage`.

## Steps

<Steps>
  <Step title="Navigate to Order Sets">
    Go to `/cl/order-sets`. If you see "Order sets are disabled," contact an administrator to enable order sets in CL module settings.
  </Step>

  <Step title="Search for an order set">
    Type in the **Search order sets…** field to filter by name or category.
  </Step>

  <Step title="Create a new order set template">
    Click **New Order Set** (requires `cl.order_sets.manage`). The `OrderSetTemplateDialog` opens. Fill in the name, category, and template details, then save. New templates default to `draft` status.
  </Step>

  <Step title="Edit an existing template">
    Click **Edit** on a listed template. The same dialog opens pre-populated. Save to apply changes.
  </Step>

  <Step title="Delete a template">
    Click **Delete** on a template and confirm the destructive dialog. Deletion is a soft-delete; the template's `deleted_at` is set and it no longer appears in the list.
  </Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="Template status">
    `cl_order_set_templates` has a `status` field. The page loads templates including retired ones (`includeRetired: true`). SME: confirm the lifecycle states and which roles can transition a template between states.
  </Accordion>

  <Accordion title="Soft delete">
    `useDeleteOrderSetTemplate` sets `deleted_at` and `updated_by` on the row rather than removing it. Deleted templates are filtered out by `.is('deleted_at', null)` in queries.
  </Accordion>

  <Accordion title="Module setting gate">
    The component reads `cl_module_settings` via `useClModuleSettings`. If `order_sets_enabled` is explicitly `false`, an empty-state screen replaces the list — no templates are fetched.
  </Accordion>

  <Accordion title="Empty states">
    No templates matching search: "No order sets yet — Create your first order set to streamline ordering." Load error: an Alert with a sanitized error message.
  </Accordion>
</AccordionGroup>

## Related

<Columns cols={2}>
  <Card title="Clinical" icon="stethoscope" href="/cl/overview">
    Overview of the Clinical core.
  </Card>

  <Card title="Governance & parity" icon="scale-balanced" href="/governance/index">
    Documentation coverage and governance.
  </Card>
</Columns>

<Note>
  This page documents shipped product behavior. It is not medical, legal, or
  billing advice. Verify against your organization's policies and applicable
  regulations before using it for clinical, compliance, or billing decisions.
  Protected health information (PHI) shown in the product is governed by your
  tenant's access controls and is never exposed in this documentation.
</Note>

<Accordion title="Documentation sources">
  * src/routes/cl.tsx
  * src/cores/cl/pages/OrderSetManagementPage.tsx
  * src/cores/cl/hooks/useOrderSetTemplates.ts
</Accordion>
