import { OrgSection } from "./OrgSection.tsx";
import { ORG_AGREEMENT_ORDER } from "../../../../components/OrgAgreements/orgAgreements";
import { ProviderRecordingConsent } from "./ProviderRecordingConsent.tsx";
import { ProviderAccessSection } from "./ProviderAccessSection.tsx";
import type { OrgCollabTeam } from "../../../../utils/orgCollabTeams";
import { formatCutoff, useRecordAccessStanding, type RecordAccessStanding } from "../../../../hooks/useRecordAccessStanding";
/**
* WHAT THIS PRACTICE MAY DO WITH YOUR RECORD - one section, three rows.
*
* IT WAS THREE CARDS, ONE PER DOCUMENT, AND THE DECK REJECTS THAT SHAPE. Three shielded cards stacked
* inside an opened practice read as three separate subjects, and on a phone they pushed the care team
* and the appointments off the screen entirely. They are not three subjects: they are three answers to
* the one question a patient opens a practice to ask.
*
* THE SENTENCE ABOVE THE ROWS IS THE ANSWER IN PLAIN WORDS, and the rows are the detail under it. It is
* written in the present tense about what the practice CAN do, because that is what a patient is
* checking - not what they signed.
*
* IT FOLLOWS THE HIPAA AUTHORIZATION'S STANDING, read for this practice: the present-tense sentence only while it is
* current, the record as it was available to them once withdrawn (forward-only, per Spencer's ruling), and no claim
* at all while the standing is still being read or could not be read. The rows beneath keep each document's detail.
*
* THE ORDER IS THE SHARED ONE, so the patient meets the three documents in the same sequence here as in
* the outstanding-agreements notice and at the front desk.
*/
export const ProviderAccessBlock = ({
orgId,
organizationName,
collabTeams,
}: {
orgId: string;
organizationName?: string;
/** This practice's people in the patient's collaboration teams; null while unknown. */
collabTeams?: OrgCollabTeam[] | null;
}) => {
const practice = organizationName || "This practice";
const { standing, retry } = useRecordAccessStanding({ organizationId: orgId });
return (
{text}
; switch (standing.kind) { case "current": return say(`${practice} can see your record and add to it, and can include you in messages and collaboration teams.`); case "withdrawn": return say(standing.at ? `${practice} can still see your record only as it was available to them through ${formatCutoff(standing.at)}. Nothing newer is shared with them.` : `${practice} can still see your record only as it was available to them when you withdrew. Nothing newer is shared with them.`); case "declined": return say(`You declined ${practice}'s access to your record.`); case "not-given": return say(`${practice} has not been given access to your record.`); case "unknown": return (What {practice} can see could not be checked.{" "}
); case "loading": return null; } }; export default ProviderAccessBlock;