feature: RBAC + Clinical Audit Logging

This commit is contained in:
voltsrage
2026-06-21 15:46:55 +08:00
parent a43db52813
commit 5af6ab490e
83 changed files with 4281 additions and 70 deletions
@@ -16,15 +16,18 @@ public class EncounterService : IEncounterService
private readonly AppDbContext _db;
private readonly IQsofaService _qsofa;
private readonly IExternalIdentifierService _identifiers;
private readonly IAuditService _audit;
public EncounterService(
AppDbContext db,
IQsofaService qsofa,
IExternalIdentifierService identifiers)
IExternalIdentifierService identifiers,
IAuditService audit)
{
_db = db;
_qsofa = qsofa;
_identifiers = identifiers;
_audit = audit;
}
public async Task<Encounter> GetByIdAsync(Guid id)
@@ -171,6 +174,14 @@ public class EncounterService : IEncounterService
});
await _db.SaveChangesAsync();
await _audit.WriteAsync(
AuditAction.EncounterStatusChanged,
"Encounter",
encounterId,
previousValue: new { status = previousStatus.ToDbString() },
newValue: new { status = targetStatus.ToDbString(), dischargeDiagnosis });
return new EncounterStatusTransitionResult(encounterId, targetStatus);
}