/** * The muted line under a patient's name in the list: age, gender, and how to reach them. * * - extracted because it was WRONG and could not be tested where it lived. On the deployed * build two rows read **"15 years old No contact info"** and **"8 years old No contact info"** with no * separator, while every populated row used " - ". * * THE CAUSE, which is the part worth keeping: the separator was conditional on `(phone || email)` - * **the very value it existed to separate** - so on rows where those are absent and the "No contact info" * fallback takes their place, the separator was skipped along with them. The old expression could only * ever be right for patients who HAVE contact details. * * Both rows it was wrong for were MINORS, and that is not a coincidence: a child's record legitimately * carries an age and no phone of their own. **The defect lived exactly where the data is least like the * happy path**, which is why a walk found it and the list's own use never did. * * Joining parts rather than interleaving separators closes the class: a separator can no longer * disagree with what it separates. */ import { patientAgeLabel } from "../../../utils/dateUtils"; import { formatPhoneNumber } from "../../../utils/phoneNumber"; export const patientRowSummary = ( age: number | null, gender: string, phone?: string, email?: string, ): string => [ patientAgeLabel(age), gender || null, // A PART, never a fallback for the whole line. The front desk needs to see that there is no way to // reach somebody; treating this as a whole-line fallback would render just "15 years old" for a child // with no contact details and hide precisely the fact that matters. (phone && formatPhoneNumber(phone)) || email || 'No contact info', ] .filter(Boolean) .join(' • ');