import { useAuthServiceContext } from "../services/AuthService.tsx"; // Who a patient-side read is answered for: the signed-in person and, when they act for someone, that subject. // A read started under one scope must never land in another, so lists key their reads on this. export const useViewerScope = (): string => { const { currentUser, actingAs } = useAuthServiceContext(); const fhir = currentUser?.fhir; return [ currentUser?.cognito?.sub ?? "", fhir ? `${fhir.resourceType}/${fhir.id ?? ""}` : "", actingAs ? `${actingAs.relatedPersonId}>${actingAs.subjectPatientId}:${actingAs.scope ?? "full"}` : "", ].join("|"); };