21 lines
1.3 KiB
C#
21 lines
1.3 KiB
C#
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."); }
|
|
}
|