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

> Manage reusable protocol-driven care pathway templates with draft, published, and archived lifecycle states.

The Pathway Templates screen (`/cl/pathway-templates`) lists all reusable care pathway templates for the organization and provides lifecycle controls to create, edit, publish, archive, and delete them.

## Overview

The page queries `cl_pathway_templates` (soft-delete filtered, ordered by `updated_at` descending) via `usePathwayTemplates`. Templates are displayed in a table with columns for Name, Program (`clinical_program`), Status, Milestones count, and Updated date. Templates have three statuses — `draft`, `published`, and `archived` — rendered as badges. Row-level actions (gated on `cl.pathways.manage`) depend on status: draft templates show Edit, Publish, and Delete buttons; published templates show an Archive button; archived templates have no row actions. Deleting a draft opens a `ConfirmationDialog` with a destructive confirmation step. Errors surface as sanitized toast messages via Sonner.

## Who it's for

Requires permission: `cl.pathways.manage`

## Before you start

You must hold the `cl.pathways.manage` permission. Templates are scoped to your organization. At least one template must exist before row-level actions are available.

## Steps

<Steps>
  <Step title="Navigate to /cl/pathway-templates">
    Open the Clinical module and navigate to Pathway Templates. The page loads the template table for your organization.
  </Step>

  <Step title="Create a new template">
    Click "New template" (visible to users with `cl.pathways.manage`) to open the `PathwayTemplateFormDialog`. Fill in name, clinical program, and milestones, then save.
  </Step>

  <Step title="Edit a draft template">
    Click the Edit (pencil) icon on any draft-status row to reopen the form dialog pre-populated with the existing template data.
  </Step>

  <Step title="Publish a draft template">
    Click the Publish (check-circle) icon on a draft row. The template status changes to `published` and a success toast confirms the action.
  </Step>

  <Step title="Archive a published template">
    Click the Archive icon on a published row. The template status changes to `archived` and a success toast confirms the action.
  </Step>

  <Step title="Delete a draft template">
    Click the Delete (trash) icon on a draft row. Confirm the destruction in the dialog that appears. This action cannot be undone from the UI.
  </Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="Template status lifecycle">
    Templates move through three states: `draft` (editable) → `published` (read-only, archivable) → `archived` (no further UI actions). Status badges use `secondary`, `default`, and `outline` variants respectively.
  </Accordion>

  <Accordion title="Empty state">
    When no templates exist for the organization, the page shows: "No pathway templates yet — Create your first protocol-driven care pathway."
  </Accordion>

  <Accordion title="Error state">
    If the data fetch fails, a destructive alert banner renders above the table with a sanitized error message. Mutation errors surface as Sonner toast notifications.
  </Accordion>

  <Accordion title="Milestones count">
    The Milestones column shows the length of `milestones_parsed` — a parsed array derived from the raw `milestones` JSONB column.
  </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/PathwayTemplateListPage.tsx
  * src/cores/cl/hooks/pathways/usePathwayTemplates.ts
  * src/cores/cl/hooks/pathways/index.ts
</Accordion>
