wip history

This commit is contained in:
Dr Masroor Ehsan 2025-01-01 12:00:39 +06:00
parent dce7af78b9
commit 19865fc178
8 changed files with 165 additions and 2 deletions

View File

@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\HashidControllerBase;
use App\Http\Requests\StudyHistoryRequest;
use App\Models\Enums\Permission;
use App\Models\StudyDetails;
class StudyHistoryController extends HashidControllerBase
{
public function view()
{
abort_unless(auth()->user()->can(Permission::StudyHistoryView) || auth()->user()->isAdmin(), 403);
$this->decodeKeys();
$details = StudyDetails::where('study_id', $this->key)->first();
return view('staff.history.view', compact('details'));
}
public function edit()
{
abort_unless(auth()->user()->can(Permission::StudyHistoryEdit) || auth()->user()->isAdmin(), 403);
$this->decodeKeys();
$details = StudyDetails::where('study_id', $this->key)->first();
return view('staff.history.edit', compact('details'));
}
public function save(StudyHistoryRequest $request)
{
abort_unless(auth()->user()->can(Permission::StudyHistoryEdit) || auth()->user()->isAdmin(), 403);
$this->decodeKeys();
$details = StudyDetails::where('study_id', $this->key)->first();
return redirect()->route('staff.history.show', $this->key);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\Enums\Permission;
use App\Models\Enums\ReportStatus;
use App\Models\Enums\StudyLevelStatus;
use Illuminate\Database\Eloquent\Relations\HasMany;
@ -57,4 +58,18 @@ public function scopeUnlocked($query)
{
return $query->where('is_locked', false);
}
public function getHistoryLink(): string
{
$user = auth()->user();
if ($user->may(Permission::StudyHistoryEdit)) {
return route('staff.history.edit', _h($this->id));
}
if ($user->may(Permission::StudyHistoryView)) {
return route('staff.history.view', _h($this->id));
}
return '#';
}
}

View File

@ -18,6 +18,7 @@ protected function casts()
return [
'properties' => 'array',
'series' => 'array',
'assignment_log' => 'array',
];
}
}

View File

@ -3,6 +3,8 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Enums\Permission;
use App\Models\Enums\UserRole;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
@ -85,4 +87,14 @@ public function scopeActive($query)
{
return $query->where('is_active', true);
}
public function isAdmin(): bool
{
return $this->hasRole(UserRole::Admin);
}
public function may(Permission $perm): bool
{
return $this->hasRole(UserRole::Admin) || $this->can($perm);
}
}

View File

@ -0,0 +1,42 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('History') }}
</h2>
</x-slot>
<div>
<div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
<div class="mt-10 sm:mt-0">
<h4>Clinical Information</h4>
<h5>Clinical History</h5>
<div class="p-4 border-gray-100">
{{ $details->clinical_history }}
</div>
<x-section-border />
<h5>surgical_history</h5>
<div class="p-4 border-gray-100">
{{ $details->surgical_history }}
</div>
<x-section-border />
<h5>lab_results</h5>
<div class="p-4 border-gray-100">
{{ $details->lab_results }}
</div>
<x-section-border />
<h5>clinical_diagnosis</h5>
<div class="p-4 border-gray-100">
{{ $details->clinical_diagnosis }}
</div>
<x-section-border />
</div>
</div>
</div>
</x-app-layout>

View File

@ -0,0 +1,42 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('History View') }}
</h2>
</x-slot>
<div>
<div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
<div class="mt-10 sm:mt-0">
<h4>Clinical Information</h4>
<h5>Clinical History</h5>
<div class="p-4 border-gray-100">
{{ $details->clinical_history }}
</div>
<x-section-border/>
<h5>surgical_history</h5>
<div class="p-4 border-gray-100">
{{ $details->surgical_history }}
</div>
<x-section-border/>
<h5>lab_results</h5>
<div class="p-4 border-gray-100">
{{ $details->lab_results }}
</div>
<x-section-border/>
<h5>clinical_diagnosis</h5>
<div class="p-4 border-gray-100">
{{ $details->clinical_diagnosis }}
</div>
<x-section-border/>
</div>
</div>
</div>
</x-app-layout>

View File

@ -63,8 +63,10 @@ class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $study->accession_number }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $study->patient_id }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900"><a
href="{{ route('studies.details', _h($study->id)) }}">{{ $study->patient_name }}</a>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<a href="{{ $study->getHistoryLink() }}">
{{ $study->patient_name }}
</a>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $study->patient_sex }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ $study->patient_birthdate }}</td>

View File

@ -4,6 +4,7 @@
use App\Http\Controllers\Radiologist\ReportWriteController;
use App\Http\Controllers\SocialLoginController;
use App\Http\Controllers\Staff\StudiesController;
use App\Http\Controllers\Staff\StudyHistoryController;
use App\Http\Controllers\System\SyncOrthancController;
use Illuminate\Support\Facades\Route;
@ -33,6 +34,16 @@
Route::get('{hashid}/details', [StudiesController::class, 'details'])->name('details');
});
Route::group(['as' => 'staff.'], function () {
Route::group(['prefix' => 'history', 'as' => 'history.'], function () {
Route::get('{hashid}', [StudyHistoryController::class, 'view'])->name('view');
Route::get('{hashid}/edit', [StudyHistoryController::class, 'edit'])->name('edit');
Route::post('{hashid}', [StudyHistoryController::class, 'save'])->name('save');
});
});
});
Route::group(['prefix' => 'shares', 'as' => 'shares.'], function () {