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,
        },
        [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,
        },
        [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,
        },
        [ClinicalRole.Integration] = new(StringComparer.Ordinal)
        {
            ClinicalPermissions.PatientsWrite,
            ClinicalPermissions.EncountersWrite,
            ClinicalPermissions.ObservationsIngest,
            ClinicalPermissions.MedicationsWrite,
            ClinicalPermissions.FhirIngest,
            ClinicalPermissions.FhirRead,
        },
    };

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