feature: Improve dashboard functionality
This commit is contained in:
@@ -98,10 +98,14 @@ public class AlertService : IAlertService
|
||||
$"Alert cannot be acknowledged from status '{alert.Status}'.",
|
||||
"ALERT_NOT_ACKNOWLEDGEABLE");
|
||||
|
||||
var roleLabel = _currentUser.Role?.ToDbString() ?? "UNKNOWN";
|
||||
var userId = _currentUser.UserId;
|
||||
var acknowledgmentNote = FormatAcknowledgmentNote(roleLabel, displayName, req.Note);
|
||||
|
||||
var previousStatus = alert.Status;
|
||||
alert.Status = AlertStatus.Acknowledged;
|
||||
alert.AcknowledgedAt = DateTimeOffset.UtcNow;
|
||||
alert.AcknowledgedBy = displayName;
|
||||
alert.AcknowledgedBy = $"{displayName} ({roleLabel})";
|
||||
|
||||
// Write an outbox event so the Kafka consumer (Phase 6) can cancel the
|
||||
// pending RabbitMQ escalation timer when it sees this acknowledgment.
|
||||
@@ -113,9 +117,11 @@ public class AlertService : IAlertService
|
||||
{
|
||||
alertId = alert.Id,
|
||||
encounterId = alert.EncounterId,
|
||||
acknowledgedBy = displayName,
|
||||
acknowledgedBy = alert.AcknowledgedBy,
|
||||
userId,
|
||||
role = roleLabel,
|
||||
acknowledgedAt = alert.AcknowledgedAt,
|
||||
note = req.Note
|
||||
note = acknowledgmentNote
|
||||
}),
|
||||
PartitionKey = alert.EncounterId.ToString(),
|
||||
CreatedAt = DateTimeOffset.UtcNow
|
||||
@@ -141,8 +147,8 @@ public class AlertService : IAlertService
|
||||
"ClinicalAlert",
|
||||
alert.Id,
|
||||
previousValue: new { status = previousStatus.ToDbString() },
|
||||
newValue: new { status = alert.Status.ToDbString(), alert.AcknowledgedBy },
|
||||
reason: req.Note);
|
||||
newValue: new { status = alert.Status.ToDbString(), alert.AcknowledgedBy, role = roleLabel, userId },
|
||||
reason: acknowledgmentNote);
|
||||
|
||||
if (alert.AlertType.IsSuppressible())
|
||||
{
|
||||
@@ -151,7 +157,7 @@ public class AlertService : IAlertService
|
||||
"ClinicalAlert",
|
||||
alert.Id,
|
||||
newValue: new { alert.AlertType, alert.EncounterId },
|
||||
reason: req.Note);
|
||||
reason: acknowledgmentNote);
|
||||
}
|
||||
|
||||
return alert;
|
||||
@@ -244,4 +250,10 @@ public class AlertService : IAlertService
|
||||
alert.ResolvedAt = resolve.ResolvedAt;
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
private static string FormatAcknowledgmentNote(string roleLabel, string displayName, string? note)
|
||||
{
|
||||
var prefix = $"[{roleLabel}] Acknowledged by {displayName}.";
|
||||
return string.IsNullOrWhiteSpace(note) ? prefix : $"{prefix} {note.Trim()}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user