test phase 23 verification script

This commit is contained in:
voltsrage
2026-06-24 01:19:03 +08:00
parent 2e80700bf0
commit 032cd1d240
14 changed files with 240 additions and 86 deletions
@@ -76,6 +76,17 @@ public class TrendDetector
if (!TrendCalculator.ExceedsThreshold(observationCode, rate.Value, threshold))
return new TrendResult(TrendOutcome.Stable, observationCode, rate);
using (var scope = _services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
if (!await db.Encounters.AnyAsync(e => e.Id == encounterId, ct))
{
_logger.LogWarning(
"Skipping trend alert for unknown encounter {EncounterId}", encounterId);
return new TrendResult(TrendOutcome.EncounterNotFound, observationCode, rate);
}
}
var details = TrendCalculator.DescribeTrend(observationCode, rate.Value, value);
var created = await TryCreateAlertAsync(
encounterId, patientId, observationCode, details, rate.Value, ct);