public enum AuditAction
{
    ThresholdCreated,
    ThresholdUpdated,
    ThresholdDeleted,
    AlertAcknowledged,
    AlertResolved,
    EncounterStatusChanged,
    PatientRegistered,
    PatientUpdated,
    SuppressionWindowSet,
    UserLogin,
    AuthorizationDenied,
    AlertFeedbackSubmitted,
    UserLogout,
    TokenRefreshed,
    SimulationRunStarted,
    SimulationRunStopped,
}

public static class AuditActionExtensions
{
    public static string ToDbString(this AuditAction a) => a switch
    {
        AuditAction.ThresholdCreated      => "THRESHOLD_CREATED",
        AuditAction.ThresholdUpdated      => "THRESHOLD_UPDATED",
        AuditAction.ThresholdDeleted      => "THRESHOLD_DELETED",
        AuditAction.AlertAcknowledged     => "ALERT_ACKNOWLEDGED",
        AuditAction.AlertResolved         => "ALERT_RESOLVED",
        AuditAction.EncounterStatusChanged => "ENCOUNTER_STATUS_CHANGED",
        AuditAction.PatientRegistered     => "PATIENT_REGISTERED",
        AuditAction.PatientUpdated        => "PATIENT_UPDATED",
        AuditAction.SuppressionWindowSet  => "SUPPRESSION_WINDOW_SET",
        AuditAction.UserLogin             => "USER_LOGIN",
        AuditAction.AuthorizationDenied   => "AUTHORIZATION_DENIED",
        AuditAction.AlertFeedbackSubmitted => "ALERT_FEEDBACK_SUBMITTED",
        AuditAction.UserLogout            => "USER_LOGOUT",
        AuditAction.TokenRefreshed        => "TOKEN_REFRESHED",
        AuditAction.SimulationRunStarted  => "SIMULATION_RUN_STARTED",
        AuditAction.SimulationRunStopped  => "SIMULATION_RUN_STOPPED",
        _ => throw new ArgumentOutOfRangeException(nameof(a))
    };

    public static AuditAction FromDbString(string v) => v switch
    {
        "THRESHOLD_CREATED"       => AuditAction.ThresholdCreated,
        "THRESHOLD_UPDATED"       => AuditAction.ThresholdUpdated,
        "THRESHOLD_DELETED"       => AuditAction.ThresholdDeleted,
        "ALERT_ACKNOWLEDGED"      => AuditAction.AlertAcknowledged,
        "ALERT_RESOLVED"          => AuditAction.AlertResolved,
        "ENCOUNTER_STATUS_CHANGED" => AuditAction.EncounterStatusChanged,
        "PATIENT_REGISTERED"      => AuditAction.PatientRegistered,
        "PATIENT_UPDATED"         => AuditAction.PatientUpdated,
        "SUPPRESSION_WINDOW_SET"  => AuditAction.SuppressionWindowSet,
        "USER_LOGIN"              => AuditAction.UserLogin,
        "AUTHORIZATION_DENIED"    => AuditAction.AuthorizationDenied,
        "ALERT_FEEDBACK_SUBMITTED" => AuditAction.AlertFeedbackSubmitted,
        "USER_LOGOUT"              => AuditAction.UserLogout,
        "TOKEN_REFRESHED"          => AuditAction.TokenRefreshed,
        "SIMULATION_RUN_STARTED"   => AuditAction.SimulationRunStarted,
        "SIMULATION_RUN_STOPPED"   => AuditAction.SimulationRunStopped,
        _ => throw new ArgumentOutOfRangeException(nameof(v))
    };
}