/** * Whether finding no visit proves none is booked. Only a complete answer for this patient does: an * unanswered, failed or cut-off read knows nothing, and a helper's read can have sensitive visits withheld. */ export const visitListProvesNoneBooked = ( read: { answered?: boolean; error?: unknown; incomplete?: boolean; listIsThisPatients?: boolean }, readerIsHelper: boolean ): boolean => !readerIsHelper && Boolean(read.answered) && !read.error && !read.incomplete && Boolean(read.listIsThisPatients); /** * Whether this session reads for someone else: a helper by role, or a signed-in patient acting for the person they * help, whose role stays Patient while the subject changes. */ export const readsForAnother = (auth: { userRole?: string | null; USER_ROLES?: { RELATED_PERSON?: string }; actingAs?: unknown; }): boolean => Boolean(auth.actingAs) || (Boolean(auth.userRole) && auth.userRole === auth.USER_ROLES?.RELATED_PERSON);