// src/components/ProxyAttributionBadge/proxyAttribution.ts // F1 plan Task 12: pure logic behind the "on behalf of" proxy-attribution UI indicator - // the client reflection of the on-behalf-of attribution identity rule (RelatedPerson != // Patient). When a RelatedPerson (a proxy acting for a patient - spouse, parent, guardian) // sends a message, it reads as FROM the related person, not the patient. Kept separate from // ProxyAttributionBadge.tsx so it's testable without rendering. /** * Builds the label for the on-behalf-of badge. The related person's own name is already * rendered as the message sender elsewhere (e.g. the chat header name), so it is * deliberately NOT repeated here - the badge only needs to surface the patient they're * acting for. `relatedPersonName` is accepted for API symmetry with callers that have both * names on hand and to keep the helper self-documenting. */ export function buildProxyAttributionLabel( _relatedPersonName?: string, patientName?: string, ): string { return patientName ? `On behalf of ${patientName}` : 'On behalf of the patient'; } /** True when a FHIR reference string points at a RelatedPerson resource. */ export function isRelatedPersonReference(reference?: string): boolean { return !!reference && reference.startsWith('RelatedPerson/'); }