import { useTheme } from "../useTheme"; import Badge from "./Badge"; import { getDeviceDisplay } from "../lib/coverage"; function daysLabel(days) { if (days < 0) return Expired {Math.abs(days)}d ago; if (days <= 7) return {days} days; if (days <= 30) return {days} days; return {days} days; } function scoreClass(priority) { if (priority >= 500) return "text-[var(--accent-text)]"; if (priority >= 200) return "text-[var(--text-secondary)]"; return "text-[var(--text-muted)]"; } function isHighPriority(flag) { return flag === "OUT_OF_COVERAGE" || flag === "VISIT_DUE"; } const FILTERS = [ { key: "all", label: "All" }, { key: "OUT_OF_COVERAGE", label: "Supply Lapsed" }, { key: "VISIT_DUE", label: "Renewal Due" }, { key: "REFILL_WINDOW", label: "Resupply Ready" }, { key: "OK", label: "Active" }, ]; export default function WorklistTable({ records, activeFilter, onFilterChange }) { const { dark } = useTheme(); const filtered = activeFilter === "all" ? records : records.filter((r) => r.flag === activeFilter); const todayStr = new Date().toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", }); return (
{/* Header */}
Outreach Worklist
{records.length} patients · sorted by priority score · {todayStr}
{FILTERS.map((f) => ( ))}
{/* Table */} {filtered.map((r, i) => { const hp = isHighPriority(r.flag); return ( ); })} {filtered.length === 0 && ( )}
Patient ID Device Payer Days Left Status Priority Action
{r.patient_id}
{i === 0 && (
★ TOP PRIORITY
)}
{getDeviceDisplay(r.device_type)} {r.payer} {daysLabel(r.daysUntilEnd)} {r.reason && (
{r.reason}
)}
{r.priority}
No patients match this filter.
{/* Footer */}
🔒 PHI-safe — patient names and DOBs never stored. Crosswalk: patient_id only. {activeFilter === "all" ? `${records.length} patients · all results shown` : `${filtered.length} of ${records.length} · filtered`}
); } function ActionButton({ flag }) { const base = "bg-transparent border border-[var(--border-color)] text-[var(--text-secondary)] px-[13px] py-[5px] rounded-md text-xs cursor-pointer font-body whitespace-nowrap transition-all hover:border-[var(--brand)] hover:text-[var(--brand)]"; if (flag === "OUT_OF_COVERAGE" || flag === "VISIT_DUE") { const label = flag === "OUT_OF_COVERAGE" ? "Contact Prescriber" : "Request Renewal →"; return ; } if (flag === "REFILL_WINDOW") { return ; } return ; }