import type { Patient } from "fhir/r4"; import { calculateAge, patientAgeLabel } from "../../../utils/dateUtils"; import { formatPhoneNumber } from "../../../utils/phoneNumber"; import { getFirstContactPointBySystem } from "../../../utils/fhirContactPoint"; /** The right-hand line of a search result: age and how to reach them, or that nobody can. */ export const patientSearchResultLine = (patient: Patient): string => { const age = patient.birthDate ? calculateAge(patient.birthDate) : null; const phone = getFirstContactPointBySystem(patient.telecom, "phone")?.value; const email = getFirstContactPointBySystem(patient.telecom, "email")?.value; const contact = phone ? formatPhoneNumber(phone) : email || "no contact"; return [patientAgeLabel(age), contact].filter(Boolean).join(" ยท "); };