Implement US-10 selected-context insights and final rounding
This commit is contained in:
1 parent
d21005b6fe
commit
a0a9e2e9b9
11 files changed
+314
-18
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using InsightsService.Clients;
|
||||
using InsightsService.Domain;
|
||||
|
||||
@@ -6,14 +7,15 @@ namespace InsightsService.Application;
|
||||
public sealed class InsightsApplicationService(ObservationServiceClient observations, InsightCalculator calculator)
|
||||
{
|
||||
public async Task<HealthInsight?> GetSummaryAsync(Guid patientId, DateTime from, DateTime to,
|
||||
CancellationToken cancellationToken)
|
||||
ContextSelection selection, CancellationToken cancellationToken)
|
||||
{
|
||||
from = NormalizeTimestamp(from);
|
||||
to = NormalizeTimestamp(to);
|
||||
if (to < from)
|
||||
throw new ArgumentException("The end time must not be earlier than the start time.", nameof(to));
|
||||
var history = await observations.GetByPeriodAsync(patientId, from, to, cancellationToken);
|
||||
return calculator.CalculateSummary(patientId, from, to, history);
|
||||
Validator.ValidateObject(selection, new ValidationContext(selection), validateAllProperties: true);
|
||||
var history = await observations.GetByPeriodAsync(patientId, from, to, selection, cancellationToken);
|
||||
return calculator.CalculateSummary(patientId, from, to, history, selection);
|
||||
}
|
||||
|
||||
private static DateTime NormalizeTimestamp(DateTime value) =>
|
||||
|
||||
Reference in new issue
Block a user