import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "../../../components/ui/dialog.tsx"; import { Button } from "../../../components/ui/button.tsx"; import { useStaffPermissionServiceContext } from "../../../services"; import type { BenchRow } from "../../../hooks/useBench.ts"; import { dayAndTime } from "./benchTime.ts"; interface Props { row?: BenchRow; onClose: () => void; /** Absent when this caller may not do it; the act is then not offered. */ onEnterResult?: (row: BenchRow) => void; onRecordRefusal?: (row: BenchRow) => void; } // A tube another laboratory is running: where it went, and the two answers that can come back. export const OrderDetailsDialog = ({ row, onClose, onEnterResult, onRecordRefusal }: Props) => { const { canManage, permissionsSettled } = useStaffPermissionServiceContext(); const mayWork = permissionsSettled && canManage("diagnostics"); if (!row) return null; const collected = dayAndTime(row.collectedAt); const detail = [row.accession, collected ? `Collected ${collected}` : undefined].filter(Boolean).join(" · "); return ( { if (!open) onClose(); }}> Order details
{`${row.patientDisplay ?? "Patient not recorded"} · ${row.test ?? "Test not recorded"}`} {detail ? {detail} : null}
Where this order was sent, and what can come back.
Status
Sent to lab
Performing laboratory
{row.sentOut?.laboratory ?? "Not named on the send-out"}
{mayWork && (onEnterResult || onRecordRefusal) ? (
{onEnterResult ? ( ) : null} {onRecordRefusal ? ( ) : null}
) : null}
); };