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

# Cohort Detail

> View and manage a single patient cohort's definition, version history, membership snapshots, and audit trail.

This screen displays the detail of a single patient cohort at route `/cl/cohorts/:cohortId`.

## Overview

The Cohort detail page loads a cohort record by `cohortId` from `useCohortDetail`. The page header shows the cohort name, a status badge (`draft`, `active`, or `archived`), the current version number (`v{current_version}`), an optional description, and the last-updated date. Three tabs organize the content: **Versions** (renders `CohortVersionsTab`), **Membership** (renders `CohortMembershipTab`), and **Audit** (renders `CohortAuditTab`). The active tab is synchronized to the URL via `useTabUrlState`. A toolbar of action buttons adapts to the current status: Export is always available; Snapshot and Edit are visible for active cohorts; Publish is visible for draft cohorts; Return to draft is visible for active cohorts; Archive is available for non-archived cohorts. The Archive action triggers a `ConfirmationDialog` before committing.

## Who it's for

Requires the `cl.cohort.view` permission to access this route. Additional permissions gate specific actions: `cl.cohort.edit_definition` for Snapshot, Edit, Publish, and Return to draft; `cl.cohort.archive` for Archive.

## Before you start

* You must hold the `cl.cohort.view` permission.
* The cohort must exist in the system; an unknown `cohortId` renders "Cohort not found." with a link back to `/cl/cohorts`.
* To edit, snapshot, publish, or archive, you must also hold `cl.cohort.edit_definition` or `cl.cohort.archive` respectively.

## Steps

<Steps>
  <Step title="Open a cohort record">
    Navigate to `/cl/cohorts` and select a cohort, or follow a direct link to `/cl/cohorts/:cohortId`. The page loads the name, status badge, version, and description.
  </Step>

  <Step title="Review versions">
    The **Versions** tab (default) shows the version history via `CohortVersionsTab`.
  </Step>

  <Step title="Inspect membership">
    Select the **Membership** tab to view the current membership snapshot via `CohortMembershipTab`.
  </Step>

  <Step title="Review the audit trail">
    Select the **Audit** tab to view cohort change history via `CohortAuditTab`.
  </Step>

  <Step title="Edit the cohort definition (active or draft only)">
    Click **Edit** (requires `cl.cohort.edit_definition`) to open `CohortFormSheet` with the current definition pre-populated.
  </Step>

  <Step title="Take a snapshot (active only)">
    Click **Snapshot** (requires `cl.cohort.edit_definition`) to open `CohortSnapshotDialog` and record a point-in-time membership snapshot.
  </Step>

  <Step title="Publish, return to draft, or archive">
    Use **Publish** to transition from `draft` to `active`, **Return to draft** to revert an `active` cohort, or **Archive** to archive a non-archived cohort. Archive requires confirmation via dialog. All three require `cl.cohort.edit_definition` (or `cl.cohort.archive` for archive).
  </Step>

  <Step title="Export">
    Click the **Export** button (`CohortExportButton`) to export cohort data.
  </Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="Cohort status lifecycle">
    A cohort starts as `draft`, transitions to `active` on publish, can be returned to `draft`, and is permanently moved to `archived`. Archived cohorts cannot be edited or snapshotted, but existing snapshots remain available for reporting.
  </Accordion>

  <Accordion title="Versioning">
    Each edit to a cohort increments `current_version`. The Versions tab displays the full version history loaded from `useCohortDetail`.
  </Accordion>

  <Accordion title="Not-found state">
    If the cohort is not found or the current user lacks access, the page renders "Cohort not found. This cohort may have been removed or you may not have access." with a back link.
  </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/CohortDetailPage.tsx
  * src/cores/cl/hooks/cohorts/useCohortDetail.ts
  * src/cores/cl/hooks/cohorts/useCohortMutation.ts
  * src/cores/cl/types/cohorts.ts
</Accordion>
