public enum AuditAction
{
    ThresholdCreated,
    ThresholdUpdated,
    ThresholdDeleted,
    AlertAcknowledged,
    AlertResolved,
    EncounterStatusChanged,
    PatientRegistered,
    PatientUpdated,
    SuppressionWindowSet,
    UserLogin,
    AuthorizationDenied
}

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",
        _ => 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,
        _ => throw new ArgumentOutOfRangeException(nameof(v))
    };
}