Implement US-07 blood-pressure observation history

This commit is contained in:
Steffen committed 2026-10-02 09:22:49 +02:00
1 parent df47bcbbd7
commit 0ea7866f82
7 files changed
+155 -1

No files matched your search

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using ObservationService.Application;
using ObservationService.Contracts;
using ObservationService.Domain;
@@ -44,6 +45,23 @@ public sealed class ObservationController(ObservationApplicationService service)
return observation is null ? NotFound() : Ok(ToDto(observation));
}
[HttpGet("patients/{patientId:guid}/observations")]
public async Task<ActionResult<List<ObservationDto>>> GetByPeriod(Guid patientId,
[FromQuery, BindRequired] DateTime from, [FromQuery, BindRequired] DateTime to,
CancellationToken cancellationToken)
{
try
{
var observations = await service.GetByPeriodAsync(patientId, from, to, cancellationToken);
return Ok(observations.Select(ToDto).ToList());
}
catch (ArgumentException)
{
ModelState.AddModelError(nameof(to), "The end time must not be earlier than the start time.");
return ValidationProblem(ModelState);
}
}
private static ObservationDto ToDto(BloodPressureObservation observation) =>
new(observation.ObservationId, observation.PatientId, observation.MeasuredAt, observation.Systolic,
observation.Diastolic, observation.Pulse, observation.Context, observation.Note);