import type { ReferralFaxField, ReferralFaxLine, ReferralFaxReadField } from "../../../services/ReferralWorkbenchService"; export const FAX_FIELD_LABEL: Record = { patientName: "Patient name", patientBirthDate: "Date of birth", patientPhone: "Patient phone", patientAddress: "Patient address", patientInsurance: "Insurance", referringProvider: "Referring clinician", referringOrganization: "Referring practice", referringPhone: "Sender phone", referringFax: "Sender fax", requestedService: "Service asked for", reason: "Reason", diagnosis: "Diagnosis", urgency: "Urgency", }; /** Patient values that can be searched; a value off a fax is a search term, never a match. */ export const SEARCHABLE: readonly ReferralFaxField[] = ["patientName", "patientBirthDate", "patientPhone"]; /** Shown to read against the fax; the referral does not keep them. */ export const SHOWN_ONLY: readonly ReferralFaxField[] = [ "requestedService", "diagnosis", "urgency", "patientAddress", "patientInsurance", "referringPhone", "referringFax", ]; const quote = (text: string) => String.fromCharCode(8220) + text + String.fromCharCode(8221); export const citedLine = (line: ReferralFaxLine) => "Page " + line.page + ", line " + line.line + ": " + quote(line.text); /** The sender as one line, from the clinician and practice the fax names. */ export const senderFrom = (fields: Partial>) => [fields.referringProvider?.value, fields.referringOrganization?.value].filter(Boolean).join(", "); export const senderRead = (fields: Partial>) => { const parts = [fields.referringProvider, fields.referringOrganization].filter(Boolean) as ReferralFaxReadField[]; return parts.length === 0 ? undefined : { value: senderFrom(fields), lines: parts.flatMap((part) => part.lines), uncertain: parts.some((part) => part.uncertain), }; };