import type { Encounter } from 'fhir/r4'; import { formatDateTime } from './dateUtils'; // Include the time to distinguish visits on the same day. export const describeEncounterForPicker = (encounter: Encounter): string => { const why = encounter.reasonCode?.[0]?.text?.trim() || encounter.type?.[0]?.text?.trim() || encounter.class?.display?.trim() || 'Visit'; const start = encounter.period?.start; const when = start ? formatDateTime(start) : undefined; return when ? `${why} - ${when}` : `${why} - date not recorded`; };