import { useCallback } from "react"; import type { Attachment } from "fhir/r4"; import { useHttpService } from "../services/HttpService.tsx"; import { environment } from "../environments/environment.ts"; /** * The laboratory's own reports on one order, for the bench that filed them. * * NOT THE DIAGNOSTIC REPORT READ THE CHART USES. A bench technician holds the Staff group, and * `GET /R4/DiagnosticReport/*` does not admit it -- so the one person who files a faxed report could * not open it again. This route hands back the attachments on a single order instead, to somebody the * order's own permission already lets work it. * * ASKED FOR WHEN SOMEBODY ASKS. A queue is not a record: reading a report per row would cost a request * per row, and most rows are never opened. */ export interface LabReportsOnOrder { orderId?: string; reportId?: string; reports?: Attachment[]; /** The files exist but are not shown to this reader yet; `message` says why. Never the same as none attached. */ withheld?: boolean; message?: string; } const ORDER_API = environment.fhirBaseApi; export const useLabReportsOnOrder = () => { const { get } = useHttpService(); return useCallback( (orderId: string) => get(`${ORDER_API}/diagnostic-order/${orderId}/attachment`), [get], ); };