Files
vigilcare-clinical/VigilCareClinicalAPI/Controllers/QsofaController.cs
T
voltsrage 7751d6df06 fix:
No SOFA trend chart or organ-system timeline
No GCS trend chart or component history
No qSOFA history view
2026-06-23 18:00:43 +08:00

52 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
/// <summary>
/// qSOFA scoring: current active criteria count per encounter (Redis-backed).
/// </summary>
[ApiController]
[Route("api/v1/encounters/{encounterId:guid}/qsofa")]
[Produces("application/json")]
[AuthorizePermission(ClinicalPermissions.EncountersRead)]
public class QsofaController : ControllerBase
{
private readonly IQsofaService _qsofa;
public QsofaController(IQsofaService qsofa) => _qsofa = qsofa;
/// <summary>
/// Returns the current qSOFA active criteria count (03) for an encounter.
/// </summary>
[HttpGet("current")]
[ProducesResponseType(typeof(ApiResponse<QsofaCurrentResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> Current(Guid encounterId)
{
var score = await _qsofa.GetCurrentAsync(encounterId);
return Ok(ApiResponse<QsofaCurrentResponse>.Ok(score));
}
/// <summary>
/// Returns cursor-paginated qSOFA alert history for an encounter.
/// </summary>
[HttpGet("history")]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
public async Task<IActionResult> History(
Guid encounterId,
[FromQuery] int limit = 20,
[FromQuery] string? cursor = null)
{
var page = await _qsofa.GetHistoryAsync(encounterId, limit, cursor);
return Ok(ApiResponse<object>.Ok(new
{
items = page.Items.Select(e => new QsofaHistoryResponse(
e.ActiveCriteria,
QsofaCalculator.ParseCriteriaState(e),
e.ScreenAlertFired,
e.EvaluatedAt)),
nextCursor = page.NextCursor,
hasMore = page.HasMore
}));
}
}