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

> Manage lab order panels and template sets for quick ordering; create, edit, activate, or delete order templates.

The Order Templates screen is the admin page for managing lab order panels and template sets, accessible at `/cl/settings/order-templates`.

## Overview

The page fetches all order templates via `useAllOrderTemplates` and displays them in a searchable table. Each row shows `template_name` (with optional `description`), `template_type` (badged), item count (from `order_items` array length), and an `Active` toggle. The "New Template" button (gated to `cl.order_templates.manage`) opens `OrderTemplateFormDialog`. Row actions include "Edit" (opens the dialog pre-filled) and "Delete" (calls `deleteTemplate` mutation immediately, no confirmation dialog). The active toggle calls `updateTemplate` with `is_active` flipped.

## Who it's for

Requires permission: `cl.order_templates.manage`

## Before you start

* You must hold `cl.order_templates.manage` to access this page (required for both read and write operations per the route guard).
* Deleting a template is immediate and does not prompt for confirmation.

## Steps

<Steps>
  <Step title="Navigate to Order Templates">
    Go to `/cl/settings/order-templates`. All templates for your organization load.
  </Step>

  <Step title="Search templates">
    Use the search input to filter by `template_name`.
  </Step>

  <Step title="Create a new template">
    Click "New Template." The `OrderTemplateFormDialog` opens with empty fields.
  </Step>

  <Step title="Edit a template">
    Click "Edit" on any row. The `OrderTemplateFormDialog` opens pre-filled with that template's data.
  </Step>

  <Step title="Toggle a template active or inactive">
    Use the `Active` switch on any row. The switch is disabled while the `updateTemplate` mutation is pending.
  </Step>

  <Step title="Delete a template">
    Click "Delete" on a row. The template is deleted immediately (no confirmation prompt).
  </Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="Empty state">
    When no templates match the search (or none exist): "No order templates found" / "Create one to streamline lab ordering."
  </Accordion>

  <Accordion title="Item count">
    The "Items" column reflects the length of the `order_items` JSONB array cast to `OrderTemplateItem[]`. The contents of individual items are not displayed in the list view.
  </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/OrderTemplateManagementPage.tsx
  * src/cores/cl/hooks/useAllOrderTemplates.ts
  * src/cores/cl/hooks/useOrderTemplateMutations.ts
</Accordion>
