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:
@@ -14,4 +14,37 @@ public class GcsService : IGcsService
|
||||
.OrderByDescending(s => s.CalculatedAt)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<CursorPage<GcsScore>> GetHistoryAsync(
|
||||
Guid encounterId, int limit, string? cursorToken)
|
||||
{
|
||||
limit = Math.Clamp(limit, 1, 100);
|
||||
var cursor = GcsScoreCursor.Decode(cursorToken);
|
||||
|
||||
var query = _db.GcsScores
|
||||
.AsNoTracking()
|
||||
.Where(s => s.EncounterId == encounterId);
|
||||
|
||||
if (cursor is not null)
|
||||
{
|
||||
query = query.Where(s =>
|
||||
s.CalculatedAt < cursor.CalculatedAt ||
|
||||
(s.CalculatedAt == cursor.CalculatedAt && s.Id.CompareTo(cursor.Id) < 0));
|
||||
}
|
||||
|
||||
var items = await query
|
||||
.OrderByDescending(s => s.CalculatedAt)
|
||||
.ThenByDescending(s => s.Id)
|
||||
.Take(limit + 1)
|
||||
.ToListAsync();
|
||||
|
||||
var hasMore = items.Count > limit;
|
||||
if (hasMore) items.RemoveAt(limit);
|
||||
|
||||
var nextCursor = hasMore
|
||||
? new GcsScoreCursor(items[^1].CalculatedAt, items[^1].Id).Encode()
|
||||
: null;
|
||||
|
||||
return new CursorPage<GcsScore>(items, nextCursor, hasMore);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user