audit log
This commit is contained in:
parent
708496ea7e
commit
2816e7e40c
51
app/Http/Controllers/Staff/AuditLogController.php
Normal file
51
app/Http/Controllers/Staff/AuditLogController.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Http\Controllers\HashedStudyControllerBase;
|
||||
use App\Services\AuditTrail\Activity;
|
||||
use App\Services\AuditTrail\Category;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AuditLogController extends HashedStudyControllerBase
|
||||
{
|
||||
public function popup()
|
||||
{
|
||||
$study = $this->getStudy();
|
||||
$sql = <<<'SQL'
|
||||
SELECT
|
||||
aud.user_id,
|
||||
usr.display_name AS user_name,
|
||||
aud.category,
|
||||
aud.activity,
|
||||
aud.ip_addr,
|
||||
aud.user_agent,
|
||||
aud.orthanc_uuid,
|
||||
aud.url,
|
||||
aud.notes,
|
||||
aud.created_at
|
||||
FROM
|
||||
audit_logs AS aud
|
||||
INNER JOIN users AS usr ON aud.user_id = usr."id"
|
||||
WHERE
|
||||
aud.study_id = :id
|
||||
ORDER BY
|
||||
aud."id" DESC
|
||||
SQL;
|
||||
// $logs = DB::select($sql, ['id' => $study->id]);
|
||||
$logs = DB::table('audit_logs')
|
||||
->leftjoin('users', 'users.id', '=', 'audit_logs.user_id')
|
||||
->selectRaw('users.display_name as user_name, audit_logs.*')
|
||||
->orderBy('audit_logs.id')
|
||||
->where('audit_logs.study_id', $study->id)
|
||||
->get();
|
||||
|
||||
$logs->each(function ($log) {
|
||||
$log->category_name = Category::from($log->category)->name;
|
||||
$log->activity_name = Str::slug(Activity::from($log->activity)->name);
|
||||
});
|
||||
|
||||
return view('staff.audit.popup', compact('study', 'logs'));
|
||||
}
|
||||
}
|
@ -2,47 +2,48 @@
|
||||
|
||||
namespace App\Services\AuditTrail;
|
||||
|
||||
final class Activity
|
||||
enum Activity: int
|
||||
{
|
||||
// studies
|
||||
public const int Study_Open = 101;
|
||||
case Study_Open = 101;
|
||||
|
||||
public const int Study_Metadata_View = 102;
|
||||
case Study_Metadata_View = 102;
|
||||
|
||||
public const int Study_Metadata_Edit = 103;
|
||||
case Study_Metadata_Edit = 103;
|
||||
|
||||
public const int Study_History_View = 104;
|
||||
case Study_History_View = 104;
|
||||
|
||||
public const int Study_History_Update = 105;
|
||||
case Study_History_Update = 105;
|
||||
|
||||
public const int Study_Create = 106;
|
||||
case Study_Create = 106;
|
||||
|
||||
public const int Study_Update = 107;
|
||||
case Study_Update = 107;
|
||||
|
||||
public const int Study_Archive = 108;
|
||||
case Study_Archive = 108;
|
||||
|
||||
public const int Study_Delete = 109;
|
||||
public const int Study_Lock = 110;
|
||||
public const int Study_Unlock = 111;
|
||||
case Study_Delete = 109;
|
||||
case Study_Lock = 110;
|
||||
case Study_Unlock = 111;
|
||||
|
||||
public const int Attachment_Upload = 112;
|
||||
public const int Attachment_Download = 113;
|
||||
public const int Attachment_Delete = 114;
|
||||
case Attachment_Upload = 112;
|
||||
case Attachment_Download = 113;
|
||||
case Attachment_Delete = 114;
|
||||
|
||||
// report
|
||||
|
||||
public const int Report_Save = 201;
|
||||
case Report_Save = 201;
|
||||
|
||||
public const int Report_Delete = 202;
|
||||
case Report_Delete = 202;
|
||||
|
||||
public const int Report_Finalize = 203;
|
||||
case Report_Finalize = 203;
|
||||
|
||||
public const int User_Login = 301;
|
||||
case User_Login = 301;
|
||||
|
||||
public const int User_Failed_Login = 302;
|
||||
case User_Failed_Login = 302;
|
||||
|
||||
public const int User_Logout = 303;
|
||||
case User_Logout = 303;
|
||||
|
||||
case Assign_Physician = 401;
|
||||
case Unassign_Physician = 402;
|
||||
|
||||
public const int Assign_Physician = 401;
|
||||
public const int Unassign_Physician = 402;
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Services\AuditTrail;
|
||||
|
||||
final class Category
|
||||
enum Category: int
|
||||
{
|
||||
public const int GENERAL = 10;
|
||||
case GENERAL = 10;
|
||||
|
||||
public const int SYSTEM = 20;
|
||||
case SYSTEM = 20;
|
||||
|
||||
public const int PACS = 30;
|
||||
case PACS = 30;
|
||||
|
||||
public const int AUTH = 40;
|
||||
case AUTH = 40;
|
||||
}
|
||||
|
14
resources/views/staff/audit/popup.blade.php
Normal file
14
resources/views/staff/audit/popup.blade.php
Normal file
@ -0,0 +1,14 @@
|
||||
<table class="table table-sm">
|
||||
@foreach ($logs as $log)
|
||||
<tr>
|
||||
<td class="bg-gray-100">{{ $log->created_at }}</td>
|
||||
<td>{{ $log->user_name }}</td>
|
||||
<td>{{ $log->category_name }}</td>
|
||||
<td>{{ $log->activity_name }}</td>
|
||||
<td>{{ $log->ip_addr }}</td>
|
||||
<td>{{ Illuminate\Support\Str::limit($log->user_agent, 20) }}</td>
|
||||
<td>{{ $log->notes }}</td>
|
||||
<td>{{ $log->url }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
@ -73,6 +73,7 @@
|
||||
@include('staff.worklist.partials._modal-js', ['selector' => '.show-attach', 'url' => route('staff.studies.attach'), 'type' => 'attach'])
|
||||
@include('staff.worklist.partials._modal-js', ['selector' => '.show-assign', 'url' => route('staff.assign.show'), 'type' => 'assign'])
|
||||
@include('staff.worklist.partials._modal-js', ['selector' => '.show-reports', 'url' => route('staff.report.popup'), 'type' => 'report'])
|
||||
@include('staff.worklist.partials._modal-js', ['selector' => '.show-audit', 'url' => route('staff.audit.popup'), 'type' => 'audit'])
|
||||
|
||||
let _status, _study_from, _study_to, _receive_from, _receive_to, _assign_from, _assign_to, _read_from,
|
||||
_read_to, _modality, _read_by = null;
|
||||
@ -227,5 +228,6 @@ function formatDate(date) {
|
||||
@include('staff.worklist.partials._modal', ['type' => 'attach', 'title' => 'Attached Docs'])
|
||||
@include('staff.worklist.partials._modal', ['type' => 'assign', 'title' => 'Assign Radiologist'])
|
||||
@include('staff.worklist.partials._modal', ['type' => 'report', 'title' => 'Reports'])
|
||||
@include('staff.worklist.partials._modal', ['type' => 'audit', 'title' => 'Audit Log'])
|
||||
|
||||
@endsection
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Http\Controllers\SocialLoginController;
|
||||
use App\Http\Controllers\Staff\AssignmentController;
|
||||
use App\Http\Controllers\Staff\AttachmentController;
|
||||
use App\Http\Controllers\Staff\AuditLogController;
|
||||
use App\Http\Controllers\Staff\DicomViewerController;
|
||||
use App\Http\Controllers\Staff\HistoryController;
|
||||
use App\Http\Controllers\Staff\MetadataController;
|
||||
@ -78,6 +79,10 @@
|
||||
Route::post('save', [ReportController::class, 'save'])->name('save');
|
||||
Route::get('download/{uuid}/{format}', ReportDownloadController::class)->name('download');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'audit', 'as' => 'audit.'], function () {
|
||||
Route::get('popup', [AuditLogController::class, 'popup'])->name('popup');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user