Clinical Sync Batch Engine: first commit
This commit is contained in:
@@ -200,4 +200,48 @@ public class AlertService : IAlertService
|
||||
|
||||
return alert;
|
||||
}
|
||||
|
||||
public async Task ApplySyncedAcknowledgmentAsync(
|
||||
Guid alertId, SyncedAlertAcknowledgment ack, CancellationToken ct)
|
||||
{
|
||||
var alert = await _db.ClinicalAlerts.FindAsync([alertId], ct)
|
||||
?? throw new NotFoundException("Alert not found.", "ALERT_NOT_FOUND");
|
||||
|
||||
alert.Status = AlertStatus.Acknowledged;
|
||||
alert.AcknowledgedAt = ack.AcknowledgedAt;
|
||||
alert.AcknowledgedBy = ack.ClinicianId;
|
||||
|
||||
_db.OutboxEvents.Add(new OutboxEvent
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Topic = "alert.acknowledged",
|
||||
Payload = JsonSerializer.Serialize(new
|
||||
{
|
||||
alertId = alert.Id,
|
||||
encounterId = alert.EncounterId,
|
||||
acknowledgedBy = ack.ClinicianId,
|
||||
acknowledgedAt = ack.AcknowledgedAt,
|
||||
note = ack.Note,
|
||||
syncedFromGateway = true
|
||||
}),
|
||||
PartitionKey = alert.EncounterId.ToString(),
|
||||
CreatedAt = DateTimeOffset.UtcNow
|
||||
});
|
||||
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task ApplySyncedResolutionAsync(
|
||||
Guid alertId, SyncedAlertResolution resolve, CancellationToken ct)
|
||||
{
|
||||
var alert = await _db.ClinicalAlerts.FindAsync([alertId], ct)
|
||||
?? throw new NotFoundException("Alert not found.", "ALERT_NOT_FOUND");
|
||||
|
||||
if (alert.Status != AlertStatus.Acknowledged)
|
||||
alert.Status = AlertStatus.Acknowledged;
|
||||
|
||||
alert.Status = AlertStatus.Resolved;
|
||||
alert.ResolvedAt = resolve.ResolvedAt;
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user