feature: RBAC + Clinical Audit Logging
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user