fix:
No SOFA trend chart or organ-system timeline No GCS trend chart or component history No qSOFA history view
This commit is contained in:
@@ -26,28 +26,37 @@ public class QsofaService : IQsofaService
|
||||
return QsofaCalculator.CountActiveCriteria(values);
|
||||
}
|
||||
|
||||
public async Task<CursorPage<ClinicalAlert>> GetHistoryAsync(
|
||||
Guid encounterId, int limit, string? cursor)
|
||||
public async Task<CursorPage<QsofaEvaluation>> GetHistoryAsync(
|
||||
Guid encounterId, int limit, string? cursorToken)
|
||||
{
|
||||
limit = Math.Clamp(limit, 1, 100);
|
||||
var cursor = QsofaEvaluationCursor.Decode(cursorToken);
|
||||
|
||||
var query = _db.ClinicalAlerts
|
||||
var query = _db.QsofaEvaluations
|
||||
.AsNoTracking()
|
||||
.Where(a => a.EncounterId == encounterId
|
||||
#pragma warning disable CS0618 // Include legacy QSOFA_WARNING rows in history
|
||||
&& (a.AlertType == AlertType.QsofaScreen || a.AlertType == AlertType.QsofaWarning));
|
||||
#pragma warning restore CS0618
|
||||
.Where(e => e.EncounterId == encounterId);
|
||||
|
||||
if (cursor is not null)
|
||||
{
|
||||
query = query.Where(e =>
|
||||
e.EvaluatedAt < cursor.EvaluatedAt ||
|
||||
(e.EvaluatedAt == cursor.EvaluatedAt && e.Id.CompareTo(cursor.Id) < 0));
|
||||
}
|
||||
|
||||
var items = await query
|
||||
.OrderByDescending(a => a.TriggeredAt)
|
||||
.ThenByDescending(a => a.Id)
|
||||
.OrderByDescending(e => e.EvaluatedAt)
|
||||
.ThenByDescending(e => e.Id)
|
||||
.Take(limit + 1)
|
||||
.ToListAsync();
|
||||
|
||||
var hasMore = items.Count > limit;
|
||||
if (hasMore) items.RemoveAt(limit);
|
||||
|
||||
return new CursorPage<ClinicalAlert>(items, null, hasMore);
|
||||
var nextCursor = hasMore
|
||||
? new QsofaEvaluationCursor(items[^1].EvaluatedAt, items[^1].Id).Encode()
|
||||
: null;
|
||||
|
||||
return new CursorPage<QsofaEvaluation>(items, nextCursor, hasMore);
|
||||
}
|
||||
|
||||
private async Task EnsureEncounterExistsAsync(Guid encounterId)
|
||||
@@ -67,12 +76,6 @@ public class QsofaService : IQsofaService
|
||||
{
|
||||
return new QsofaCurrentResponse(
|
||||
QsofaCalculator.CountActiveCriteria(values),
|
||||
new QsofaCriteriaState(
|
||||
ParseOptionalDecimal(values[0]),
|
||||
ParseOptionalDecimal(values[1]),
|
||||
ParseOptionalDecimal(values[2])));
|
||||
QsofaCalculator.ParseCriteriaState(values));
|
||||
}
|
||||
|
||||
private static decimal? ParseOptionalDecimal(RedisValue value) =>
|
||||
value.HasValue ? decimal.Parse(value.ToString()) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user