import type { PractitionerWithRoles } from '../../services'; import { WITHHELD_COLLEAGUE_REASON } from './withheldColleague'; /** * The line under a colleague's name. The withheld reason is only for a colleague whose record this * caller could not read; a readable colleague whose role carries no label gets no line rather than a * refusal that did not happen. */ export const colleagueRoleLine = (entry: PractitionerWithRoles | undefined): string => { if (!entry) return WITHHELD_COLLEAGUE_REASON; const code = entry.roles?.find((role) => role.active !== false)?.code?.[0]; return code?.text || code?.coding?.find((coding) => coding.display)?.display || ''; };