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

# Note Templates

> Manage service-line documentation templates for clinical notes including creating, editing, activating, and deactivating; create templates via slide-over form.

This screen provides admin CRUD operations for session documentation templates and is accessible at `/cl/note-templates`.

## Overview

The Note Templates page lists all active note templates for the current organization, loaded via `useNoteTemplatesList` from the `cl_note_templates` table. Templates are displayed in a card with a divide-separated list showing template name, note type label, service line (if set), active/inactive badge, an Edit button, and a toggle button to activate or deactivate. Users click "New Template" (top-right button) to open a side-sheet form (`TemplateForm` via `Sheet`) for creating a new template. Clicking "Edit" on a row opens the same sheet pre-populated with the template's current values. Note type choices are: Progress Note, Addendum, Outpatient, Residential, IOP/PHP. Service line is an optional free-text field. The `useNoteTemplateMutation` hook provides `createTemplate`, `updateTemplate`, `activateTemplate`, and `deactivateTemplate` actions, each invalidating the `cl_note_templates` query on success and showing a toast notification.

## Who it's for

Requires the `cl.note_templates.manage` permission (enforced by `RequirePermission` in `cl.tsx` and the component itself).

## Before you start

* You must hold `cl.note_templates.manage` to access this page.

## Steps

<Steps>
  <Step title="Navigate to Note Templates">
    Open the Clinical core and go to `/cl/note-templates`. All active note templates for your organization are listed.
  </Step>

  <Step title="Create a new template">
    Click "New Template" (top right). The side-sheet opens. Enter a Template Name (required), select a Note Type (required), and optionally enter a Service Line. Click "Create" to save.
  </Step>

  <Step title="Edit an existing template">
    Click "Edit" next to the template you want to update. The side-sheet opens pre-filled. Modify the fields as needed and click "Update" to save.
  </Step>

  <Step title="Deactivate or activate a template">
    Click the toggle icon button next to the template. Active templates show a ToggleRight icon (clicking deactivates); inactive templates show a ToggleLeft icon (clicking activates). A toast notification confirms the action.
  </Step>
</Steps>

## Key concepts

Note: `/cl/note-templates/new` is **not a registered route** in the Clinical core router. Template creation is handled entirely through the "New Template" sheet on this page. Navigating to `/cl/note-templates/new` renders the `NotFound` component.

<AccordionGroup>
  <Accordion title="Note type values">
    The `note_type` field accepts: `progress` (Progress Note), `addendum` (Addendum), `outpatient` (Outpatient), `residential` (Residential), `iop_php` (IOP/PHP). These labels are from `NOTE_TYPE_LABEL` in the component. Clinical or billing significance of each type requires SME confirmation.
  </Accordion>

  <Accordion title="Active vs. inactive templates">
    `useNoteTemplatesList` queries only rows where `is_active = true`. Deactivated templates are hidden from the list. The `activateTemplate` mutation sets `is_active: true` and re-queries.
  </Accordion>

  <Accordion title="Empty and error states">
    When no active templates exist, an empty state shows a FileText icon with "No templates yet" and "Create templates to standardize session documentation." If the query errors, the sanitized error message is shown in destructive text within the card.
  </Accordion>
</AccordionGroup>

| Term                      | Meaning                                                                                                        |
| ------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `note_type`               | Enum classifying the documentation template: `progress`, `addendum`, `outpatient`, `residential`, or `iop_php` |
| `service_line`            | Optional free-text identifier (e.g., `SUD`, `MH`) further scoping the template                                 |
| `is_active`               | When `false`, the template is inactive; it remains in the list but is not available for new notes              |
| `useNoteTemplateMutation` | Hook providing `createTemplate`, `updateTemplate`, `activateTemplate`, and `deactivateTemplate`                |

## 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/NoteTemplatesPage.tsx
  * src/cores/cl/hooks/useNoteTemplatesList.ts
  * src/cores/cl/hooks/useNoteTemplateMutation.ts
  * src/cores/cl/types/progress-notes.ts
</Accordion>
