feature: RBAC + Clinical Audit Logging
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
public class ClinicalAuditLog
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public AuditAction Action { get; set; }
|
||||
public string EntityType { get; set; } = null!;
|
||||
public Guid EntityId { get; set; }
|
||||
public Guid? UserId { get; set; }
|
||||
public string? UserDisplayName { get; set; }
|
||||
public string? PreviousValueJson { get; set; }
|
||||
public string? NewValueJson { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
public string? CorrelationId { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class ClinicalUser
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Username { get; set; } = null!;
|
||||
public string PasswordHash { get; set; } = null!;
|
||||
public string DisplayName { get; set; } = null!;
|
||||
public ClinicalRole Role { get; set; }
|
||||
public bool IsActive { get; set; } = true;
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset? LastLoginAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
public enum AuditAction
|
||||
{
|
||||
ThresholdCreated,
|
||||
ThresholdUpdated,
|
||||
AlertAcknowledged,
|
||||
AlertResolved,
|
||||
EncounterStatusChanged,
|
||||
PatientRegistered,
|
||||
SuppressionWindowSet,
|
||||
UserLogin
|
||||
}
|
||||
|
||||
public static class AuditActionExtensions
|
||||
{
|
||||
public static string ToDbString(this AuditAction a) => a switch
|
||||
{
|
||||
AuditAction.ThresholdCreated => "THRESHOLD_CREATED",
|
||||
AuditAction.ThresholdUpdated => "THRESHOLD_UPDATED",
|
||||
AuditAction.AlertAcknowledged => "ALERT_ACKNOWLEDGED",
|
||||
AuditAction.AlertResolved => "ALERT_RESOLVED",
|
||||
AuditAction.EncounterStatusChanged => "ENCOUNTER_STATUS_CHANGED",
|
||||
AuditAction.PatientRegistered => "PATIENT_REGISTERED",
|
||||
AuditAction.SuppressionWindowSet => "SUPPRESSION_WINDOW_SET",
|
||||
AuditAction.UserLogin => "USER_LOGIN",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(a))
|
||||
};
|
||||
|
||||
public static AuditAction FromDbString(string v) => v switch
|
||||
{
|
||||
"THRESHOLD_CREATED" => AuditAction.ThresholdCreated,
|
||||
"THRESHOLD_UPDATED" => AuditAction.ThresholdUpdated,
|
||||
"ALERT_ACKNOWLEDGED" => AuditAction.AlertAcknowledged,
|
||||
"ALERT_RESOLVED" => AuditAction.AlertResolved,
|
||||
"ENCOUNTER_STATUS_CHANGED" => AuditAction.EncounterStatusChanged,
|
||||
"PATIENT_REGISTERED" => AuditAction.PatientRegistered,
|
||||
"SUPPRESSION_WINDOW_SET" => AuditAction.SuppressionWindowSet,
|
||||
"USER_LOGIN" => AuditAction.UserLogin,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(v))
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
public enum ClinicalRole
|
||||
{
|
||||
Nurse,
|
||||
Physician,
|
||||
Admin,
|
||||
Integration
|
||||
}
|
||||
|
||||
public static class ClinicalRoleExtensions
|
||||
{
|
||||
public static string ToDbString(this ClinicalRole r) => r switch
|
||||
{
|
||||
ClinicalRole.Nurse => "NURSE",
|
||||
ClinicalRole.Physician => "PHYSICIAN",
|
||||
ClinicalRole.Admin => "ADMIN",
|
||||
ClinicalRole.Integration => "INTEGRATION",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(r))
|
||||
};
|
||||
|
||||
public static ClinicalRole FromDbString(string v) => v switch
|
||||
{
|
||||
"NURSE" => ClinicalRole.Nurse,
|
||||
"PHYSICIAN" => ClinicalRole.Physician,
|
||||
"ADMIN" => ClinicalRole.Admin,
|
||||
"INTEGRATION" => ClinicalRole.Integration,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown role: '{v}'")
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user