chore: necessary updates given the changes in the alert controller
This commit is contained in:
@@ -85,7 +85,7 @@ public class AlertService : IAlertService
|
||||
return AlertResponseMapper.ToResponse(alert);
|
||||
}
|
||||
|
||||
public async Task<ClinicalAlert> AcknowledgeAsync(Guid id, AcknowledgeAlertRequest req)
|
||||
public async Task<AlertResponse> AcknowledgeAsync(Guid id, AcknowledgeAlertRequest req)
|
||||
{
|
||||
if (!_currentUser.IsAuthenticated)
|
||||
throw new ValidationException("Authentication required.", "AUTH_REQUIRED");
|
||||
@@ -164,7 +164,7 @@ public class AlertService : IAlertService
|
||||
reason: acknowledgmentNote);
|
||||
}
|
||||
|
||||
return alert;
|
||||
return AlertResponseMapper.ToResponse(alert);
|
||||
}
|
||||
|
||||
public async Task<AlertFeedback> SubmitFeedbackAsync(
|
||||
@@ -234,7 +234,7 @@ public class AlertService : IAlertService
|
||||
return overrideMinutes ?? defaultWindowMinutes;
|
||||
}
|
||||
|
||||
public async Task<ClinicalAlert> ResolveAsync(Guid id)
|
||||
public async Task<AlertResponse> ResolveAsync(Guid id)
|
||||
{
|
||||
var alert = await _db.ClinicalAlerts.FindAsync(id);
|
||||
if (alert is null)
|
||||
@@ -256,7 +256,7 @@ public class AlertService : IAlertService
|
||||
previousValue: new { status = AlertStatus.Acknowledged.ToDbString() },
|
||||
newValue: new { status = alert.Status.ToDbString() });
|
||||
|
||||
return alert;
|
||||
return AlertResponseMapper.ToResponse(alert);
|
||||
}
|
||||
|
||||
public async Task ApplySyncedAcknowledgmentAsync(
|
||||
|
||||
@@ -6,6 +6,11 @@ using VigilCare.ClinicalContracts.Sync;
|
||||
|
||||
public class ClinicalSyncBatchProcessor
|
||||
{
|
||||
private static readonly JsonSerializerOptions ExplanationJsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
private readonly AppDbContext _db;
|
||||
private readonly IObservationService _observations;
|
||||
private readonly IAlertService _alerts;
|
||||
@@ -163,6 +168,7 @@ public class ClinicalSyncBatchProcessor
|
||||
AlertType = AlertTypeExtensions.FromDbString(alert.AlertType),
|
||||
Severity = AlertSeverityExtensions.FromDbString(alert.Severity),
|
||||
Details = alert.Details,
|
||||
Explanation = ParseExplanation(alert.ExplanationJson),
|
||||
Status = AlertStatus.Open,
|
||||
TriggeredAt = alert.GeneratedAt
|
||||
};
|
||||
@@ -172,7 +178,7 @@ public class ClinicalSyncBatchProcessor
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Topic = "alert.generated",
|
||||
Payload = JsonSerializer.Serialize(new
|
||||
Payload = ClinicalAlertFactory.SerializeOutboxPayload(new
|
||||
{
|
||||
alertId = clinicalAlert.Id,
|
||||
encounterId = alert.EncounterId,
|
||||
@@ -180,6 +186,7 @@ public class ClinicalSyncBatchProcessor
|
||||
alertType = alert.AlertType,
|
||||
severity = alert.Severity,
|
||||
details = alert.Details,
|
||||
explanation = clinicalAlert.Explanation,
|
||||
syncedFromGateway = true,
|
||||
triggeredAt = alert.GeneratedAt,
|
||||
partitionKey = alert.EncounterId.ToString()
|
||||
@@ -231,4 +238,9 @@ public class ClinicalSyncBatchProcessor
|
||||
_db.ClinicalSyncConflicts.Add(new ClinicalSyncConflict(batchId, clientRef, itemType, reason));
|
||||
await _db.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
private static AlertExplanation? ParseExplanation(string? explanationJson) =>
|
||||
string.IsNullOrWhiteSpace(explanationJson)
|
||||
? null
|
||||
: JsonSerializer.Deserialize<AlertExplanation>(explanationJson, ExplanationJsonOptions);
|
||||
}
|
||||
@@ -8,9 +8,9 @@ public interface IAlertService
|
||||
|
||||
Task<AlertResponse> GetByIdAsync(Guid id);
|
||||
|
||||
Task<ClinicalAlert> AcknowledgeAsync(Guid id, AcknowledgeAlertRequest req);
|
||||
Task<AlertResponse> AcknowledgeAsync(Guid id, AcknowledgeAlertRequest req);
|
||||
|
||||
Task<ClinicalAlert> ResolveAsync(Guid id);
|
||||
Task<AlertResponse> ResolveAsync(Guid id);
|
||||
Task ApplySyncedAcknowledgmentAsync(Guid alertId, SyncedAlertAcknowledgment ack, CancellationToken ct);
|
||||
Task ApplySyncedResolutionAsync(Guid alertId, SyncedAlertResolution resolve, CancellationToken ct);
|
||||
Task<AlertFeedback> SubmitFeedbackAsync(Guid alertId, AlertFeedbackType type, string? comment);
|
||||
|
||||
Reference in New Issue
Block a user