Implement owner-scoped Observation lifecycle with serialized patches

This commit is contained in:
Steffen committed 2026-10-14 11:46:03 +02:00
1 parent bfe6ebf5af
commit 3a70e3e296
37 files changed
+31249 -9

No files matched your search

@@ -0,0 +1,19 @@
namespace HealthApp.Contracts;
public interface ObservationQueries
{
Task<Guid?> ResolveOwnerAsync(Guid observationId,CancellationToken ct);
Task<ObservationDto?> GetAsync(AuthorizedPatientContext scope,Guid id,CancellationToken ct);
Task<ObservationDto?> LatestAsync(AuthorizedPatientContext scope,CancellationToken ct);
Task<IReadOnlyList<ObservationDto>> SelectedAsync(AuthorizedPatientContext scope,DateTime from,DateTime to,ContextSelection selection,CancellationToken ct);
}
public interface ObservationCommands
{
Task<ObservationDto?> RecordAsync(AuthorizedPatientContext scope,RecordObservationRequest request,CancellationToken ct);
Task<ObservationDto?> PatchAsync(AuthorizedPatientContext scope,Guid id,PatchObservationRequest request,CancellationToken ct);
Task<bool> DeleteAsync(AuthorizedPatientContext scope,Guid id,CancellationToken ct);
}
public static class MeasurementPeriod
{
public static DateTime Normalize(DateTime t)=>DateTime.SpecifyKind(t.Kind==DateTimeKind.Unspecified?t:t.ToUniversalTime(),DateTimeKind.Unspecified);
public static void Validate(DateTime from,DateTime to){if(Normalize(to)<Normalize(from))throw new ArgumentException("The end time must not be earlier than the start time.");}
}