fixes: MRN generation race condition and Sepsis bundle creation race condition (TOCTOU)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user