import type { ClinicalImpression } from "fhir/r4"; // A patient reads a note inside its visit, as the deck's "A visit, opened" draws it, never as the // generic resource sheet that shows them a raw Encounter reference. export const patientNoteVisitPath = (note: ClinicalImpression): string | undefined => { const id = note.encounter?.reference?.match(/^Encounter\/([^/]+)$/)?.[1]; return id ? `/dashboard/patient/visit/${id}` : undefined; }; // The row names who wrote it, in the visit's own words; with no named author the existing title stands. export const patientNoteTitle = (note: ClinicalImpression, fallback: string): string => { const author = note.assessor?.display?.trim(); return author ? `What ${author} wrote` : fallback; };