49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
/// <summary>
|
|
/// NEWS2 composite scoring: current score and paginated history per encounter.
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/v1/encounters/{encounterId:guid}/news2")]
|
|
[Produces("application/json")]
|
|
[AuthorizePermission(ClinicalPermissions.EncountersRead)]
|
|
public class News2Controller : ControllerBase
|
|
{
|
|
private readonly INews2Service _news2;
|
|
|
|
public News2Controller(INews2Service news2) => _news2 = news2;
|
|
|
|
/// <summary>
|
|
/// Returns the latest NEWS2 score for an encounter, or 404 if no score has been computed.
|
|
/// </summary>
|
|
[HttpGet("current")]
|
|
[ProducesResponseType(typeof(ApiResponse<News2Score>), StatusCodes.Status200OK)]
|
|
public async Task<IActionResult> Current(Guid encounterId)
|
|
{
|
|
var score = await _news2.GetCurrentAsync(encounterId);
|
|
if (score is null)
|
|
return Ok(ApiResponse<News2Score?>.Ok(null));
|
|
return Ok(ApiResponse<News2Score>.Ok(score));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns cursor-paginated NEWS2 score 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 _news2.GetHistoryAsync(encounterId, limit, cursor);
|
|
return Ok(ApiResponse<object>.Ok(new
|
|
{
|
|
items = page.Items,
|
|
nextCursor = page.NextCursor,
|
|
hasMore = page.HasMore
|
|
}));
|
|
}
|
|
} |