public static class ClinicalRolePermissionMap
{
    private static readonly Dictionary<ClinicalRole, HashSet<string>> _map = new()
    {
        [ClinicalRole.Nurse] = new(StringComparer.Ordinal)
        {
            ClinicalPermissions.PatientsRead,
            ClinicalPermissions.PatientsWrite,
            ClinicalPermissions.EncountersRead,
            ClinicalPermissions.EncountersWrite,
            ClinicalPermissions.ObservationsIngest,
            ClinicalPermissions.AlertsRead,
            ClinicalPermissions.AlertsAcknowledge,
            ClinicalPermissions.AlertsResolve,
            ClinicalPermissions.ThresholdsRead,
            ClinicalPermissions.AnalyticsRead,
            ClinicalPermissions.OrdersWrite,
            ClinicalPermissions.MedicationsWrite,
            ClinicalPermissions.AlertsFeedback,
            ClinicalPermissions.SimulationRun,
        },
        [ClinicalRole.Physician] = new(StringComparer.Ordinal)
        {
            ClinicalPermissions.PatientsRead,
            ClinicalPermissions.PatientsWrite,
            ClinicalPermissions.EncountersRead,
            ClinicalPermissions.EncountersWrite,
            ClinicalPermissions.ObservationsIngest,
            ClinicalPermissions.AlertsRead,
            ClinicalPermissions.AlertsAcknowledge,
            ClinicalPermissions.AlertsResolve,
            ClinicalPermissions.ThresholdsRead,
            ClinicalPermissions.AnalyticsRead,
            ClinicalPermissions.OrdersWrite,
            ClinicalPermissions.MedicationsWrite,
            ClinicalPermissions.AlertsFeedback,
            ClinicalPermissions.SimulationRun,
        },
        [ClinicalRole.Admin] = new(StringComparer.Ordinal)
        {
            ClinicalPermissions.PatientsRead,
            ClinicalPermissions.PatientsWrite,
            ClinicalPermissions.EncountersRead,
            ClinicalPermissions.EncountersWrite,
            ClinicalPermissions.ObservationsIngest,
            ClinicalPermissions.AlertsRead,
            ClinicalPermissions.AlertsAcknowledge,
            ClinicalPermissions.AlertsResolve,
            ClinicalPermissions.ThresholdsRead,
            ClinicalPermissions.ThresholdsWrite,
            ClinicalPermissions.AnalyticsRead,
            ClinicalPermissions.OrdersWrite,
            ClinicalPermissions.MedicationsWrite,
            ClinicalPermissions.FhirIngest,
            ClinicalPermissions.FhirRead,
            ClinicalPermissions.AuditRead,
            ClinicalPermissions.UsersAdmin,
            ClinicalPermissions.AlertsFeedback,
            ClinicalPermissions.SimulationRun,
        },
        [ClinicalRole.Integration] = new(StringComparer.Ordinal)
        {
            ClinicalPermissions.PatientsWrite,
            ClinicalPermissions.EncountersWrite,
            ClinicalPermissions.ObservationsIngest,
            ClinicalPermissions.MedicationsWrite,
            // Phase 36 — simulation runner (Integration) must place orders and ack
            // alerts so sepsis-bundle / alert_ack scenario timelines are complete.
            ClinicalPermissions.OrdersWrite,
            ClinicalPermissions.AlertsAcknowledge,
            ClinicalPermissions.FhirIngest,
            ClinicalPermissions.FhirRead,
        },
    };

    public static bool HasPermission(ClinicalRole role, string permission) =>
        _map.TryGetValue(role, out var perms) && perms.Contains(permission);
}