import type { PractitionerRole } from "fhir/r4"; // A seat or setup written in one surface changes roles that others read from the shared practitioners // list; they listen here and reload it rather than wait for a page reload. // A role passed along is one just written, so the signed-in session can take it on if it is theirs. const listeners = new Set<(role?: PractitionerRole) => void>(); export const notifyPractitionerRolesChanged = (role?: PractitionerRole) => listeners.forEach((listener) => listener(role)); export const onPractitionerRolesChanged = (listener: (role?: PractitionerRole) => void) => { listeners.add(listener); return () => { listeners.delete(listener); }; };