49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|
namespace App\Services;
|
|
|
|
use App\Models\AuditLog;
|
|
|
|
/**
|
|
* Class AuditLogger
|
|
* High-Level Audit Logging Helper
|
|
*
|
|
* @package App\Services
|
|
*/
|
|
class AuditLogger
|
|
{
|
|
public static function logLogin(int $userId, string $role): void
|
|
{
|
|
AuditLog::record('LOGIN_SUCCESS', 'users', $userId, null, ['role' => $role, 'timestamp' => date('Y-m-d H:i:s')], $userId);
|
|
}
|
|
|
|
public static function logLoginFailed(string $nationalId, string $reason): void
|
|
{
|
|
AuditLog::record('LOGIN_FAILED', 'users', null, null, ['national_id' => $nationalId, 'reason' => $reason]);
|
|
}
|
|
|
|
public static function logQueueCreate(int $queueId, string $queueNo, string $status): void
|
|
{
|
|
AuditLog::record('QUEUE_CREATE', 'queues', $queueId, null, ['queue_no' => $queueNo, 'status' => $status]);
|
|
}
|
|
|
|
public static function logQueueUpdate(int $queueId, string $queueNo, string $oldStatus, string $newStatus): void
|
|
{
|
|
AuditLog::record('QUEUE_UPDATE', 'queues', $queueId, ['status' => $oldStatus], ['queue_no' => $queueNo, 'status' => $newStatus]);
|
|
}
|
|
|
|
public static function logSoapNote(int $noteId, int $queueId, int $patientId): void
|
|
{
|
|
AuditLog::record('SOAP_CREATE_SIGN', 'soap_notes', $noteId, null, ['queue_id' => $queueId, 'patient_id' => $patientId]);
|
|
}
|
|
|
|
public static function logPayment(int $paymentId, string $receiptNo, float $netAmount): void
|
|
{
|
|
AuditLog::record('PAYMENT_CHECKOUT', 'payments', $paymentId, null, ['receipt_no' => $receiptNo, 'net_amount' => $netAmount]);
|
|
}
|
|
|
|
public static function logSecurityAlert(string $alertType, array $details): void
|
|
{
|
|
AuditLog::record('SECURITY_ALERT', 'system', null, null, ['type' => $alertType, 'details' => $details]);
|
|
}
|
|
}
|