fixes: MRN generation race condition and Sepsis bundle creation race condition (TOCTOU)

This commit is contained in:
voltsrage
2026-06-21 16:37:22 +08:00
parent 4583bd7f44
commit 076e8364b2
8 changed files with 2635 additions and 7 deletions
@@ -82,7 +82,18 @@ public class SepsisBundleService : ISepsisBundleService
CreatedAt = DateTimeOffset.UtcNow
});
await _db.SaveChangesAsync(ct);
try
{
await _db.SaveChangesAsync(ct);
}
catch (DbUpdateException ex)
when (ex.InnerException is Npgsql.PostgresException { SqlState: "23505" } pg
&& pg.ConstraintName == "ix_sepsis_bundles_encounter_in_progress")
{
_db.ChangeTracker.Clear();
return null;
}
return bundle;
}