import { useAuthServiceContext } from '../services'; /** * WHETHER THE PERSON READING THIS SCREEN IS ALSO THE PERSON IT IS ABOUT. * * Several surfaces are mounted for two audiences from one component: the patient's own portal, where the * reader IS the subject, and the staff chart, where they are not. The copy was written for the first and * is correct there - it becomes wrong only when reader and subject stop being the same person, which is * exactly what a staff surface is. * * KEYED ON THE VIEWER'S ROLE RATHER THAN ON THE MOUNT OR A LAYOUT PROP. A layout flag is one route change * away from being wrong, and the mount cannot distinguish a related person reading their own record. * * ASKED AS "is the viewer a patient" rather than "is the viewer staff" DELIBERATELY: a patient and a * related person are a closed pair, and every other role - clinician, receptionist, admin, platform * manager - is somebody reading about a third party. Enumerating STAFF instead means every new staff role * silently defaults to the patient voice, which is how a clinician came to be told about "your care". */ export const useViewerIsPatient = (): boolean => { const { userRole, USER_ROLES } = useAuthServiceContext(); return [USER_ROLES.PATIENT, USER_ROLES.RELATED_PERSON].includes(userRole as string); };