Add remain services and fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using StackExchange.Redis;
|
||||
|
||||
[Collection("Integration")]
|
||||
@@ -206,4 +207,40 @@ public class SepsisBundleTests : IAsyncLifetime
|
||||
updated.ComplianceStatus.Should().Be(SepsisBundleComplianceStatus.NonCompliant);
|
||||
updated.CompletedAt.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeadlinePassed_MonitorMarksNonCompliant()
|
||||
{
|
||||
using var scope = _fixture.Services.CreateScope();
|
||||
var detector = scope.ServiceProvider.GetRequiredService<QsofaDetector>();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
|
||||
await detector.ProcessObservationAsync(_encounterId, _patientId, "RESP_RATE", 24m);
|
||||
await detector.ProcessObservationAsync(_encounterId, _patientId, "SYSTOLIC_BP", 95m);
|
||||
|
||||
var bundle = await db.SepsisBundles.SingleAsync();
|
||||
bundle.DeadlineAt = DateTimeOffset.UtcNow.AddHours(-1);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var monitor = new SepsisBundleMonitorService(
|
||||
_fixture.Services,
|
||||
_fixture.Services.GetRequiredService<ClinicalMetrics>(),
|
||||
_fixture.Services.GetRequiredService<ILogger<SepsisBundleMonitorService>>());
|
||||
|
||||
await monitor.ScanOverdueBundlesAsync(CancellationToken.None);
|
||||
|
||||
var updated = await db.SepsisBundles.AsNoTracking().SingleAsync();
|
||||
updated.ComplianceStatus.Should().Be(SepsisBundleComplianceStatus.NonCompliant);
|
||||
updated.CompletedAt.Should().BeNull(
|
||||
"the monitor marks overdue bundles non-compliant without setting CompletedAt — " +
|
||||
"elements are still incomplete");
|
||||
|
||||
var elements = await db.SepsisBundleElements
|
||||
.AsNoTracking()
|
||||
.Where(e => e.BundleId == updated.Id)
|
||||
.ToListAsync();
|
||||
elements.Should().AllSatisfy(e =>
|
||||
e.Status.Should().Be(SepsisBundleElementStatus.Pending,
|
||||
"the monitor does not complete individual elements"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user