diff --git a/app/Http/Controllers/Staff/StudyHistoryController.php b/app/Http/Controllers/Staff/StudyHistoryController.php new file mode 100644 index 0000000..2db439c --- /dev/null +++ b/app/Http/Controllers/Staff/StudyHistoryController.php @@ -0,0 +1,38 @@ +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); + } +} diff --git a/app/Models/Study.php b/app/Models/Study.php index c28b1aa..66bb6c1 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -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 '#'; + } } diff --git a/app/Models/StudyDetails.php b/app/Models/StudyDetails.php index 9c1d8c3..90322de 100644 --- a/app/Models/StudyDetails.php +++ b/app/Models/StudyDetails.php @@ -18,6 +18,7 @@ protected function casts() return [ 'properties' => 'array', 'series' => 'array', + 'assignment_log' => 'array', ]; } } diff --git a/app/Models/User.php b/app/Models/User.php index 97a4dc8..f8808d4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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); + } } diff --git a/resources/views/staff/history/edit.blade.php b/resources/views/staff/history/edit.blade.php new file mode 100644 index 0000000..aa8422d --- /dev/null +++ b/resources/views/staff/history/edit.blade.php @@ -0,0 +1,42 @@ + + +

+ {{ __('History') }} +

+
+ +
+
+ +
+

Clinical Information

+ +
Clinical History
+
+ {{ $details->clinical_history }} +
+ + +
surgical_history
+
+ {{ $details->surgical_history }} +
+ + +
lab_results
+
+ {{ $details->lab_results }} +
+ + +
clinical_diagnosis
+
+ {{ $details->clinical_diagnosis }} +
+ + +
+ +
+
+
diff --git a/resources/views/staff/history/view.blade.php b/resources/views/staff/history/view.blade.php new file mode 100644 index 0000000..9f71eab --- /dev/null +++ b/resources/views/staff/history/view.blade.php @@ -0,0 +1,42 @@ + + +

+ {{ __('History View') }} +

+
+ +
+
+ +
+

Clinical Information

+ +
Clinical History
+
+ {{ $details->clinical_history }} +
+ + +
surgical_history
+
+ {{ $details->surgical_history }} +
+ + +
lab_results
+
+ {{ $details->lab_results }} +
+ + +
clinical_diagnosis
+
+ {{ $details->clinical_diagnosis }} +
+ + +
+ +
+
+
diff --git a/resources/views/staff/studies/index.blade.php b/resources/views/staff/studies/index.blade.php index 35bab85..1deef98 100644 --- a/resources/views/staff/studies/index.blade.php +++ b/resources/views/staff/studies/index.blade.php @@ -63,8 +63,10 @@ class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking- {{ $study->accession_number }} {{ $study->patient_id }} - {{ $study->patient_name }} + + + {{ $study->patient_name }} + {{ $study->patient_sex }} {{ $study->patient_birthdate }} diff --git a/routes/web.php b/routes/web.php index 3b5e577..b77c091 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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 () {