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

# Med Audits

> Browse, create, and view medication storage audit records for Recovery Housing residences, including compliance status, findings, and corrective actions.

The `/rh/med-audits` route renders `MedStorageAuditsPage`, which lists medication storage audit records from `rh_med_storage_audits` and provides a dialog to create new audits.

## Overview

The route `/rh/med-audits` is wrapped by the outer `RHViewGuard`, which requires `rh.dashboard.view`. The page renders a search input and a compliance-status filter (`All Statuses`, `Compliant`, `Non-Compliant`, `Corrective Action Needed`). Audit records are loaded by `MedStorageAuditsTable` (which consumes `useMedStorageAudits`) and sorted by audit date descending. Clicking **New Audit** opens `MedStorageAuditDialog` for inline creation. Clicking an audit row navigates to `/rh/med-audits/:id` for the detail view.

## Who it's for

Outer guard: `RH_PERMISSIONS.DASHBOARD_VIEW` (`rh.dashboard.view`), applied by `RHViewGuard`. `RH_PERMISSIONS.MED_AUDITS_CREATE` (`rh.med-audits.create`) exists in the permissions constants but is not applied as a gate on the **New Audit** button in the current component.

## Before you start

* Hold `rh.dashboard.view` to access the page.

## Steps

<Steps>
  <Step title="Open Med Audits">
    Navigate to `/rh/med-audits`. The page loads all medication storage audit records for your organization, sorted by audit date descending.
  </Step>

  <Step title="Filter by compliance status">
    Use the **Compliance Status** dropdown to show only `Compliant`, `Non-Compliant`, or `Corrective Action Needed` records.
  </Step>

  <Step title="Open an audit record">
    Click any row in the audit table to open the detail view at `/rh/med-audits/:id`.
  </Step>

  <Step title="Create a new audit">
    Click **New Audit** to open the creation dialog. Complete the form and submit to add a new audit record.
  </Step>
</Steps>

## Key concepts

| Term                      | Code value                                               |
| ------------------------- | -------------------------------------------------------- |
| Compliance status options | `compliant`, `non_compliant`, `corrective_action_needed` |
| Data table                | `rh_med_storage_audits`                                  |

## Viewing a med audit

The `/rh/med-audits/:id` route renders `MedStorageAuditDetailPage`, which loads a single medication storage audit record from `rh_med_storage_audits` via `useMedStorageAuditDetail`.

The route is wrapped by the outer `RHViewGuard` (`rh.dashboard.view`). The page extracts the `:id` URL parameter and passes it to `useMedStorageAuditDetail`, which queries `rh_med_storage_audits` joined to `rh_residences`. The page displays two cards side-by-side: **Audit Information** (residence name, audit date, auditor, follow-up required, follow-up date) and **Compliance Status** (current status badge with icon). If findings text is present, a **Findings** card is shown. If corrective actions exist, an additional **Corrective Actions Required** card renders each action as a bulleted list. A **Back to Medication Audits** button navigates to `/rh/med-audits`.

No additional per-record permission check is present in the component. Navigate from `/rh/med-audits` by clicking an audit row, or use a direct URL with a known audit ID.

<Steps>
  <Step title="Open an audit record">
    Navigate to `/rh/med-audits` and click an audit row, or go directly to `/rh/med-audits/:id` with a known ID. The page loads the audit record.
  </Step>

  <Step title="Review audit information">
    The **Audit Information** card shows the residence, audit date, auditor, and follow-up requirements.
  </Step>

  <Step title="Review compliance status">
    The **Compliance Status** card displays the current status badge: **Compliant**, **Non-Compliant**, or **Corrective Action Needed**.
  </Step>

  <Step title="Review findings and corrective actions">
    If findings text is recorded, it appears in the **Findings** card. If corrective actions are required, each action is listed in the **Corrective Actions Required** card with a warning border.
  </Step>

  <Step title="Return to the audit list">
    Click **Back to Medication Audits** to return to `/rh/med-audits`.
  </Step>
</Steps>

### Key concepts

| Term                             | Code value                                                               |
| -------------------------------- | ------------------------------------------------------------------------ |
| Compliance status: compliant     | `compliant`                                                              |
| Compliance status: non-compliant | `non_compliant`                                                          |
| Compliance status: action needed | `corrective_action_needed`                                               |
| Corrective actions field         | `corrective_actions` (JSONB array of strings on `rh_med_storage_audits`) |

## Related

<Columns cols={2}>
  <Card title="Recovery Housing" icon="house" href="/rh/references">
    Recovery Housing references and overview.
  </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/rh.tsx
  * src/cores/rh/pages/MedStorageAuditsPage.tsx
  * src/cores/rh/pages/MedStorageAuditDetailPage.tsx
  * src/cores/rh/hooks/useMedStorageAudits.ts
  * src/cores/rh/hooks/useMedStorageAuditDetail.ts
</Accordion>
