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

# PDMP Monitoring

> View the prescription drug monitoring program query history for a patient chart, with risk flags and prescriber attestation.

The PDMP Monitoring screen displays PDMP query history for a specific patient chart at the in-app route `/cl/pdmp`.

## Overview

The PDMP Monitoring page loads when a `chartId` query parameter is present in the URL; without it the page renders a "No Chart Selected" empty state prompting the user to navigate to a patient chart first. When a chart is provided, the `PdmpResultsView` component fetches the patient's PDMP query history from `cl_pdmp_queries` via `usePdmpQueryList`. Each query entry shows the datetime, gateway provider badge, attestation status, and a risk-flag badge. Users can expand any entry to view prescription count, risk indicators (daily MME, overlapping prescriptions, multiple prescribers, multiple pharmacies), exception type, and interstate query details. Queries that have not yet been attested show an "Attest" button (guarded by `cl.pdmp.queries.create`) that opens a `PdmpAttestationDialog`.

## Who it's for

Requires permission `cl.pdmp.queries.view`.

## Before you start

* Permission `cl.pdmp.queries.view` must be granted.
* Navigate to this page from a patient chart context that passes a `chartId` query parameter; the standalone route at `/cl/pdmp` without a `chartId` renders an empty prompt.

## Steps

<Steps>
  <Step title="Open a patient chart">
    Navigate to the patient's chart. The PDMP history link passes the `chartId` as a query parameter to `/cl/pdmp`.
  </Step>

  <Step title="Review query entries">
    The page lists PDMP query records in reverse-chronological order. Each entry shows the query datetime, gateway provider, and attestation status.
  </Step>

  <Step title="Check risk flags">
    Each entry displays a "Risk Flags" badge (destructive) if any of the following are present: overlapping prescriptions, multiple prescribers, multiple pharmacies, or daily MME at or above the configured threshold. "No Risk Flags" (outline) indicates none were detected.
  </Step>

  <Step title="Expand details">
    Click "View Details" on any entry to see prescription count, risk indicator breakdown, exception type (if the query failed), and interstate query states.
  </Step>

  <Step title="Attest a query (if permitted)">
    If you hold the `cl.pdmp.queries.create` permission and the query has not been attested, click "Attest" to open the attestation dialog and record your attestation.
  </Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="Risk indicators">
    The component surfaces four boolean/numeric risk indicators from `results_summary.risk_indicators`: `overlapping_prescriptions`, `multiple_prescribers`, `multiple_pharmacies`, and `mme_daily`. A daily MME value is highlighted in destructive styling when it meets or exceeds the threshold constant in code.
  </Accordion>

  <Accordion title="Empty and error states">
    If no queries are recorded for the chart, an empty state is shown. If the fetch fails, a sanitized error message is displayed inside the card. If no `chartId` query parameter is provided, a full-page "No Chart Selected" card is shown.
  </Accordion>

  <Accordion title="Interstate queries">
    When `interstate_query` is true on a record, the detail expansion lists the `states_queried` array.
  </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/PdmpHistoryPage.tsx
  * src/cores/cl/components/PdmpResultsView\.tsx
  * src/cores/cl/types/pdmp.ts
</Accordion>
