fix: finish all patient related upgrades
This commit is contained in:
@@ -278,6 +278,74 @@ public class GapAnalysisFixTests : IAsyncLifetime
|
||||
b.GetProperty("complianceStatus").GetString() == "IN_PROGRESS");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// P1 — encounter timeline endpoint
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public async Task EncounterTimeline_ReturnsMergedEventTypes()
|
||||
{
|
||||
using var scope = _fixture.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
|
||||
var patient = new Patient
|
||||
{
|
||||
Id = Guid.NewGuid(), Mrn = "MRN-TL-001", FirstName = "TL", LastName = "Test",
|
||||
DateOfBirth = new DateOnly(1980, 1, 1), Gender = "M",
|
||||
CreatedAt = DateTimeOffset.UtcNow
|
||||
};
|
||||
var admittedAt = DateTimeOffset.UtcNow.AddHours(-6);
|
||||
var encounter = new Encounter
|
||||
{
|
||||
Id = Guid.NewGuid(), PatientId = patient.Id, EncounterType = EncounterType.Inpatient,
|
||||
Status = EncounterStatus.Active, Department = Department.Icu,
|
||||
AttendingPhysician = "Dr. TL", AdmittedAt = admittedAt,
|
||||
CreatedAt = DateTimeOffset.UtcNow
|
||||
};
|
||||
db.Patients.Add(patient);
|
||||
db.Encounters.Add(encounter);
|
||||
|
||||
db.Observations.Add(new Observation
|
||||
{
|
||||
Id = Guid.NewGuid(), EncounterId = encounter.Id,
|
||||
ObservationCode = "TEMP_C", Value = 38.8m, Unit = "C",
|
||||
Source = ObservationSource.Manual, RecordedAt = admittedAt.AddHours(1),
|
||||
CreatedAt = DateTimeOffset.UtcNow
|
||||
});
|
||||
db.ClinicalAlerts.Add(new ClinicalAlert
|
||||
{
|
||||
Id = Guid.NewGuid(), EncounterId = encounter.Id, PatientId = patient.Id,
|
||||
AlertType = AlertType.QsofaScreen, Severity = AlertSeverity.Warning,
|
||||
Details = "qSOFA screen", Status = AlertStatus.Open,
|
||||
TriggeredAt = admittedAt.AddHours(2)
|
||||
});
|
||||
db.Orders.Add(new Order
|
||||
{
|
||||
Id = Guid.NewGuid(), EncounterId = encounter.Id,
|
||||
OrderType = OrderType.Lab, Description = "Blood cultures",
|
||||
OrderedBy = "Dr. TL", Status = OrderStatus.Pending,
|
||||
OrderedAt = admittedAt.AddHours(3)
|
||||
});
|
||||
db.MedicationAdministrations.Add(new MedicationAdministration
|
||||
{
|
||||
Id = Guid.NewGuid(), EncounterId = encounter.Id,
|
||||
DrugName = "Ceftriaxone", Dose = 1m, DoseUnit = "g", Route = "IV",
|
||||
AdministeredAt = admittedAt.AddHours(4), AdministeredBy = "RN TL"
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var resp = await _client.GetFromJsonAsync<JsonElement>(
|
||||
$"/api/v1/encounters/{encounter.Id}/timeline");
|
||||
|
||||
var items = resp.GetProperty("data").GetProperty("events");
|
||||
var types = items.EnumerateArray().Select(e => e.GetProperty("type").GetString()).ToList();
|
||||
types.Should().Contain("status");
|
||||
types.Should().Contain("observation");
|
||||
types.Should().Contain("alert");
|
||||
types.Should().Contain("order");
|
||||
types.Should().Contain("medication");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// P4 — qSOFA history endpoint
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user