// Why a laboratory result is waiting for a person, and what the laboratory called it, in words for the bench. const REASONS: Record = { unsolicited: "It names no order the laboratory confirmed for this practice.", ambiguous: "It names more than one of this practice's orders.", "wrong-subject": "It is about another patient at the laboratory than the order it names.", "unknown-order": "The order it was matched to has no confirmed laboratory receipt.", "wrong-connection": "It came through another laboratory connection than its order went to.", "missing-dependency": "Part of it had not arrived from the laboratory when it was read.", uninterpretable: "Part of it could not be read as a laboratory result.", "results-unread": "Its results could not be read from the laboratory.", "scope-conflict": "An earlier copy came under another laboratory address or account. It is kept apart and is not matched.", }; // Why an order's results could not be searched for at the laboratory. const ORDER_READ_REASONS: Record = { refused: "The laboratory refused the search for this order's results.", unreadable: "The laboratory's answer to the search could not be read.", "transient-exhausted": "The laboratory could not be reached after several tries.", }; export const orderReadWords = (reason: string | undefined): string => (reason && ORDER_READ_REASONS[reason]) ?? "This order's results could not be searched for at the laboratory."; export const heldReasonWords = (reason: string | undefined): string => (reason && REASONS[reason]) ?? "It could not be matched to an order on its own."; const STATUSES: Record = { registered: "Registered at the laboratory", partial: "Partial", preliminary: "Preliminary", final: "Final", amended: "Amended", corrected: "Corrected", appended: "Appended", cancelled: "Cancelled", "entered-in-error": "Entered in error", }; /** The laboratory's own status, which is never a release here. */ export const labStatusWords = (status: string | undefined): string | undefined => (status ? `${STATUSES[status] ?? status} (the laboratory's status)` : undefined);