Implement US-11 context-aware health trend assessments
This commit is contained in:
1 parent
a0a9e2e9b9
commit
cc76c9bde4
9 files changed
+802
-7
No files matched your search
@@ -43,4 +43,32 @@ public sealed class InsightsController(InsightsApplicationService service) : Con
|
||||
return Problem(statusCode: StatusCodes.Status504GatewayTimeout, title: "Observation history timed out.");
|
||||
}
|
||||
}
|
||||
[HttpGet("/api/patients/{patientId:guid}/trends")]
|
||||
public async Task<ActionResult<TrendAssessment>> GetTrend(Guid patientId,
|
||||
[FromQuery, BindRequired] DateTime from, [FromQuery, BindRequired] DateTime to,
|
||||
[FromQuery] ContextSelection selection, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok(await service.GetTrendAsync(patientId, from, to, selection, cancellationToken));
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
ModelState.AddModelError(nameof(to), "The end time must not be earlier than the start time.");
|
||||
return ValidationProblem(ModelState);
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
{
|
||||
return Problem(statusCode: StatusCodes.Status502BadGateway, title: "Observation history is unavailable.");
|
||||
}
|
||||
catch (System.Text.Json.JsonException)
|
||||
{
|
||||
return Problem(statusCode: StatusCodes.Status502BadGateway, title: "Observation history response is invalid.");
|
||||
}
|
||||
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return Problem(statusCode: StatusCodes.Status504GatewayTimeout, title: "Observation history timed out.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user