import type { PractitionerRole } from "fhir/r4"; import { ORGANIZATION_ROLE_GROUPS, STAFF_ORGANIZATION_ROLE_SYSTEM } from "./staffRoleCatalog"; // The patient-facing groups are where both workspace gates take their clinical codes from, so a clinician // bound to any of these opens the Practitioner workspace. export const CLINICAL_ROLE_GROUPS = ORGANIZATION_ROLE_GROUPS.filter((group) => group.patientFacing); /** The role template an invitation or a self-made role carries for a chosen clinical code. */ export const clinicalRoleTemplate = (code: string): PractitionerRole | undefined => { const option = CLINICAL_ROLE_GROUPS.flatMap((group) => group.items).find((item) => item.code === code); if (!option) return undefined; return { resourceType: "PractitionerRole", code: [{ coding: [{ system: STAFF_ORGANIZATION_ROLE_SYSTEM, code: option.code, display: option.display }], text: option.display }], }; };