Run initial test for Climate Resilience Verification Suite

Add first part of Alert Quality Analytics
This commit is contained in:
voltsrage
2026-06-24 03:01:00 +08:00
parent 032cd1d240
commit 185dc93fa1
50 changed files with 4116 additions and 55 deletions
@@ -0,0 +1,10 @@
public class AlertFeedback
{
public Guid Id { get; set; }
public Guid AlertId { get; set; }
public ClinicalAlert Alert { get; set; } = null!;
public Guid UserId { get; set; }
public AlertFeedbackType FeedbackType { get; set; }
public string? Comment { get; set; }
public DateTimeOffset CreatedAt { get; set; }
}
@@ -0,0 +1,22 @@
public class AlertQualityMetric
{
public Guid Id { get; set; }
public AlertType AlertType { get; set; }
public DateTimeOffset WindowStart { get; set; }
public DateTimeOffset WindowEnd { get; set; }
public int TotalAlerts { get; set; }
public int AcknowledgedCount { get; set; }
public int ResolvedCount { get; set; }
public int EscalatedCount { get; set; }
public int FeedbackUsefulCount { get; set; }
public int FeedbackFalsePositiveCount { get; set; }
public int FeedbackWouldActCount { get; set; }
public int FeedbackCount { get; set; }
public double AcknowledgementRate { get; set; }
public double FalsePositiveRate { get; set; }
public double UsefulRate { get; set; }
public double WouldActRate { get; set; }
public double AvgSecondsToAcknowledge { get; set; }
public double AvgSecondsToResolution { get; set; }
public DateTimeOffset ComputedAt { get; set; }
}
@@ -15,6 +15,8 @@ public class ClinicalAlert
public DateTimeOffset TriggeredAt { get; set; }
public Guid? ClientAlertId { get; set; }
public bool SyncedFromGateway { get; set; }
public bool FeedbackReceived { get; set; }
public Encounter Encounter { get; set; } = null!;
public List<AlertFeedback> Feedbacks { get; set; } = new();
}
@@ -0,0 +1,34 @@
public enum AlertFeedbackType
{
Useful,
TooEarly,
TooLate,
FalsePositive,
MissingContext,
WouldAct
}
public static class AlertFeedbackTypeExtensions
{
public static string ToDbString(this AlertFeedbackType t) => t switch
{
AlertFeedbackType.Useful => "USEFUL",
AlertFeedbackType.TooEarly => "TOO_EARLY",
AlertFeedbackType.TooLate => "TOO_LATE",
AlertFeedbackType.FalsePositive => "FALSE_POSITIVE",
AlertFeedbackType.MissingContext => "MISSING_CONTEXT",
AlertFeedbackType.WouldAct => "WOULD_ACT",
_ => throw new ArgumentOutOfRangeException(nameof(t))
};
public static AlertFeedbackType FromDbString(string v) => v switch
{
"USEFUL" => AlertFeedbackType.Useful,
"TOO_EARLY" => AlertFeedbackType.TooEarly,
"TOO_LATE" => AlertFeedbackType.TooLate,
"FALSE_POSITIVE" => AlertFeedbackType.FalsePositive,
"MISSING_CONTEXT" => AlertFeedbackType.MissingContext,
"WOULD_ACT" => AlertFeedbackType.WouldAct,
_ => throw new ArgumentOutOfRangeException(nameof(v))
};
}
@@ -10,7 +10,8 @@ public enum AuditAction
PatientUpdated,
SuppressionWindowSet,
UserLogin,
AuthorizationDenied
AuthorizationDenied,
AlertFeedbackSubmitted,
}
public static class AuditActionExtensions
@@ -28,6 +29,7 @@ public static class AuditActionExtensions
AuditAction.SuppressionWindowSet => "SUPPRESSION_WINDOW_SET",
AuditAction.UserLogin => "USER_LOGIN",
AuditAction.AuthorizationDenied => "AUTHORIZATION_DENIED",
AuditAction.AlertFeedbackSubmitted => "ALERT_FEEDBACK_SUBMITTED",
_ => throw new ArgumentOutOfRangeException(nameof(a))
};
@@ -44,6 +46,7 @@ public static class AuditActionExtensions
"SUPPRESSION_WINDOW_SET" => AuditAction.SuppressionWindowSet,
"USER_LOGIN" => AuditAction.UserLogin,
"AUTHORIZATION_DENIED" => AuditAction.AuthorizationDenied,
"ALERT_FEEDBACK_SUBMITTED" => AuditAction.AlertFeedbackSubmitted,
_ => throw new ArgumentOutOfRangeException(nameof(v))
};
}