Deliver portable native Architecture B deployment and final verification

This commit is contained in:
Steffen committed 2026-10-14 16:32:20 +02:00
1 parent f451b55de1
commit 36740d2492
92 files changed
+10939 -926

No files matched your search

+21 -12
View File
@@ -2,24 +2,33 @@ using HealthApp.Contracts;
using HealthApp.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
namespace HealthApp.Analytics;
internal sealed class AnalyticsFacade(ObservationQueries observations,RequestTransaction tx,SummaryPolicy summary,TrendPolicy trend) : AnalyticsQueries
internal sealed class AnalyticsFacade(ObservationQueries observations, RequestTransaction tx, SummaryPolicy summary, TrendPolicy trend) : AnalyticsQueries
{
public async Task<HealthInsight?> InsightAsync(AuthorizedPatientContext scope,DateTime from,DateTime to,ContextSelection selection,CancellationToken ct)
{var series=await observations.SelectedAsync(scope,from,to,selection,ct);await tx.FinishAsync(ct);ct.ThrowIfCancellationRequested();return summary.CalculateSummary(scope.PatientId,MeasurementPeriod.Normalize(from),MeasurementPeriod.Normalize(to),series,selection);}
public async Task<TrendAssessment> TrendAsync(AuthorizedPatientContext scope,DateTime from,DateTime to,ContextSelection selection,CancellationToken ct)
{var series=await observations.SelectedAsync(scope,from,to,selection,ct);await tx.FinishAsync(ct);ct.ThrowIfCancellationRequested();return trend.CalculateTrend(scope.PatientId,MeasurementPeriod.Normalize(from),MeasurementPeriod.Normalize(to),series,selection);}
public async Task<HealthInsight?> InsightAsync(AuthorizedPatientContext scope, DateTime from, DateTime to, ContextSelection selection, CancellationToken ct)
{
var series = await observations.SelectedAsync(scope, from, to, selection, ct); await tx.FinishAsync(ct); ct.ThrowIfCancellationRequested(); var result = summary.CalculateSummary(scope.PatientId, MeasurementPeriod.Normalize(from), MeasurementPeriod.Normalize(to), series, selection);
ct.ThrowIfCancellationRequested();
return result;
}
public async Task<TrendAssessment> TrendAsync(AuthorizedPatientContext scope, DateTime from, DateTime to, ContextSelection selection, CancellationToken ct)
{
var series = await observations.SelectedAsync(scope, from, to, selection, ct); await tx.FinishAsync(ct); ct.ThrowIfCancellationRequested(); var result = trend.CalculateTrend(scope.PatientId, MeasurementPeriod.Normalize(from), MeasurementPeriod.Normalize(to), series, selection);
ct.ThrowIfCancellationRequested();
return result;
}
}
public static class AnalyticsModule
{
public static IServiceCollection AddAnalytics(this IServiceCollection s)
{s.AddSingleton<SummaryPolicy>();s.AddSingleton<ClinicalPolicy>();s.AddSingleton<TrendPolicy>();s.AddScoped<AnalyticsQueries,AnalyticsFacade>();return s;}
public static IServiceCollection AddAnalytics(this IServiceCollection s)
{ s.AddSingleton<SummaryPolicy>(); s.AddSingleton<ClinicalPolicy>(); s.AddSingleton<TrendPolicy>(); s.AddScoped<AnalyticsQueries, AnalyticsFacade>(); return s; }
}
// Test-only-compatible calculation entry, internal to the module; no public repository/SQL access.
internal sealed class InsightCalculator
{
private readonly SummaryPolicy summary=new();
private readonly TrendPolicy trend;
internal InsightCalculator(ReferenceCatalog catalog){trend=new(new ClinicalPolicy(catalog));}
public HealthInsight? CalculateSummary(Guid patientId,DateTime from,DateTime to,IReadOnlyList<ObservationDto> observations,ContextSelection selection)=>summary.CalculateSummary(patientId,from,to,observations,selection);
public TrendAssessment CalculateTrend(Guid patientId,DateTime from,DateTime to,IReadOnlyList<ObservationDto> observations,ContextSelection selection)=>trend.CalculateTrend(patientId,from,to,observations,selection);
private readonly SummaryPolicy summary = new();
private readonly TrendPolicy trend;
internal InsightCalculator(ReferenceCatalog catalog) { trend = new(new ClinicalPolicy(catalog)); }
public HealthInsight? CalculateSummary(Guid patientId, DateTime from, DateTime to, IReadOnlyList<ObservationDto> observations, ContextSelection selection) => summary.CalculateSummary(patientId, from, to, observations, selection);
public TrendAssessment CalculateTrend(Guid patientId, DateTime from, DateTime to, IReadOnlyList<ObservationDto> observations, ContextSelection selection) => trend.CalculateTrend(patientId, from, to, observations, selection);
}
+1 -1
View File
@@ -1,2 +1,2 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("HealthApp.AcceptanceTests")]
[assembly: InternalsVisibleTo("HealthApp.AcceptanceTests")]
+6 -5
View File
@@ -1,14 +1,15 @@
using System.Globalization;
using HealthApp.Contracts;
namespace HealthApp.Analytics;
internal sealed class ClinicalPolicy(ReferenceCatalog catalog)
{
internal const string GeneralLimits = "General reference thresholds are not individual treatment targets. " +
"This is a descriptive assessment, not a diagnosis or medication recommendation. " +
"Symptoms, treatment, training, risk factors and measurement technique are not established by these observations.";
internal (ClinicalReference? Reference,string Comparison,string Interpretation,string Hint) Apply(string metric,string unit,IReadOnlyList<ObservationDto> observations,ComparabilityAssessment comparability,(DateTime Time,decimal Value)[] points,string direction,int reversals,decimal mean,Func<ObservationDto,int> value)
{
internal (ClinicalReference? Reference, string Comparison, string Interpretation, string Hint) Apply(string metric, string unit, IReadOnlyList<ObservationDto> observations, ComparabilityAssessment comparability, (DateTime Time, decimal Value)[] points, string direction, int reversals, decimal mean, Func<ObservationDto, int> value)
{
var reference = SelectReference(metric, observations, comparability);
var comparison = "Unavailable: known, non-conflicting resting conditions" +
(metric == "Pulse" ? "" : " and a single Home or Clinic setting") + " are required; recorded inadequate preparation also limits applicability.";
@@ -64,8 +65,8 @@ internal sealed class ClinicalPolicy(ReferenceCatalog catalog)
"missing or differing conditions limit interpretation of the combined trajectory. ") +
"An outside-reference value is not dismissed because preparation information is incomplete.";
}
return (reference,comparison,interpretation,hint);
}
return (reference, comparison, interpretation, hint);
}
private ClinicalReference? SelectReference(string metric, IReadOnlyList<ObservationDto> observations,
ComparabilityAssessment comparability)
{
@@ -79,7 +80,7 @@ internal sealed class ClinicalPolicy(ReferenceCatalog catalog)
if (observations.Any(o => !string.IsNullOrWhiteSpace(o.MeasurementContext?.BodyPosition) &&
!new[] { "seated", "sitting", "siddende" }.Contains(o.MeasurementContext!.BodyPosition!.Trim(), StringComparer.OrdinalIgnoreCase)))
return null;
return catalog.Pressure(metric,settings[0]!);
return catalog.Pressure(metric, settings[0]!);
}
private static bool IsHigh(decimal value, ClinicalReference reference) =>
+4 -3
View File
@@ -5,7 +5,8 @@ namespace HealthApp.Analytics;
internal sealed class TrendPolicy(ClinicalPolicy clinical)
{
private const string GeneralLimits=ClinicalPolicy.GeneralLimits;
internal const string MethodVersion = "baseline-2026-10-05";
private const string GeneralLimits = ClinicalPolicy.GeneralLimits;
public TrendAssessment CalculateTrend(Guid patientId, DateTime from, DateTime to,
IReadOnlyList<ObservationDto> observations, ContextSelection selection)
@@ -62,8 +63,8 @@ internal sealed class TrendPolicy(ClinicalPolicy clinical)
$"Total successive change is {Format(totalChange!.Value)} {unit}.") +
" Range and successive change describe observed variation; no clinical stability classification is made.";
var result = clinical.Apply(metric,unit,observations,comparability,points,direction,reversals,mean,value);
var reference=result.Reference;var comparison=result.Comparison;var interpretation=result.Interpretation;var hint=result.Hint;
var result = clinical.Apply(metric, unit, observations, comparability, points, direction, reversals, mean, value);
var reference = result.Reference; var comparison = result.Comparison; var interpretation = result.Interpretation; var hint = result.Hint;
return new(metric, unit, Round(mean), minimum, maximum, maximum - minimum, points.Length,
direction, overall, slope is { } s ? Math.Round(s, 6, MidpointRounding.AwayFromZero) : null,
reversals, totalChange is { } change ? Round(change) : null, numerical, reference,