From 5d56d24ea6a1bf34e6ceac36158adf226e173ffe Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Wed, 1 Jan 2025 14:10:49 +0600 Subject: [PATCH] wip --- .../Controllers/StudyMetadataController.php | 40 +++++++++++++++++++ .../Requests/StudyMetadataUpdateRequest.php | 39 ++++++++++++++++++ app/Models/Study.php | 15 +++++++ resources/views/staff/meta/edit.blade.php | 28 +++++++++++++ resources/views/staff/meta/view.blade.php | 28 +++++++++++++ resources/views/staff/studies/index.blade.php | 6 ++- routes/web.php | 7 ++++ 7 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/StudyMetadataController.php create mode 100644 app/Http/Requests/StudyMetadataUpdateRequest.php create mode 100644 resources/views/staff/meta/edit.blade.php create mode 100644 resources/views/staff/meta/view.blade.php diff --git a/app/Http/Controllers/StudyMetadataController.php b/app/Http/Controllers/StudyMetadataController.php new file mode 100644 index 0000000..0d760f7 --- /dev/null +++ b/app/Http/Controllers/StudyMetadataController.php @@ -0,0 +1,40 @@ +user()->may(Permission::StudyMetadataView), 403); + $this->decodeKeys(); + $study = Study::find($this->key); + + return view('staff.meta.view', compact('study')); + } + + public function edit() + { + abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403); + $this->decodeKeys(); + $study = Study::find($this->key); + + return view('staff.meta.edit', compact('study')); + } + + public function save(StudyMetadataUpdateRequest $request) + { + abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403); + $this->decodeKeys(); + $study = Study::find($this->key); + $payload = array_trim_strings($request->validated()); + $study->update($payload); + + // return redirect()->route('staff.history.view', _h($this->key)); + return redirect()->route('staff.meta.view', $study->hash); + } +} diff --git a/app/Http/Requests/StudyMetadataUpdateRequest.php b/app/Http/Requests/StudyMetadataUpdateRequest.php new file mode 100644 index 0000000..dfdd1e6 --- /dev/null +++ b/app/Http/Requests/StudyMetadataUpdateRequest.php @@ -0,0 +1,39 @@ + ['nullable'], + 'patient_name' => ['required'], + 'patient_sex' => ['nullable'], + 'patient_birthdate' => ['nullable', 'date'], + 'study_id' => ['nullable'], + 'accession_number' => ['nullable'], + 'study_description' => ['nullable'], + 'body_part_examined' => ['nullable'], + 'station_name' => ['nullable'], + 'operators_name' => ['nullable'], + 'manufacturer' => ['nullable'], + 'manufacturer_model_name' => ['nullable'], + 'referring_physician_name' => ['nullable'], + 'study_modality' => ['nullable'], + 'study_date' => ['required', 'date'], + 'receive_date' => ['required', 'date'], + 'assigned_physician_id' => ['nullable', 'exists:users,id'], + 'referring_physician_id' => ['nullable', 'exists:users,id'], + 'access_flags' => ['required', 'integer'], + 'access_password' => ['nullable'], + ]; + } + + public function authorize(): bool + { + return true; + } +} diff --git a/app/Models/Study.php b/app/Models/Study.php index 5b322b8..2b62289 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -75,4 +75,19 @@ public function getHistoryLink(): string return '#'; } + + public function getMetadataLink(): string + { + $user = auth()->user(); + + if ($user->may(Permission::StudyMetadataEdit)) { + return route('staff.meta.edit', $this->hash); + } + + if ($user->may(Permission::StudyMetadataView)) { + return route('staff.meta.view', $this->hash); + } + + return '#'; + } } diff --git a/resources/views/staff/meta/edit.blade.php b/resources/views/staff/meta/edit.blade.php new file mode 100644 index 0000000..3431abe --- /dev/null +++ b/resources/views/staff/meta/edit.blade.php @@ -0,0 +1,28 @@ + + +

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

+
+ +
+
+ +
+

Clinical Information

+ +
patient_name
+
+ {{ $study->patient_name }} +
+ + + @if(may(\App\Models\Enums\Permission::StudyMetadataEdit)) + Edit + @endif + +
+ +
+
+
diff --git a/resources/views/staff/meta/view.blade.php b/resources/views/staff/meta/view.blade.php new file mode 100644 index 0000000..3431abe --- /dev/null +++ b/resources/views/staff/meta/view.blade.php @@ -0,0 +1,28 @@ + + +

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

+
+ +
+
+ +
+

Clinical Information

+ +
patient_name
+
+ {{ $study->patient_name }} +
+ + + @if(may(\App\Models\Enums\Permission::StudyMetadataEdit)) + Edit + @endif + +
+ +
+
+
diff --git a/resources/views/staff/studies/index.blade.php b/resources/views/staff/studies/index.blade.php index 1deef98..527df80 100644 --- a/resources/views/staff/studies/index.blade.php +++ b/resources/views/staff/studies/index.blade.php @@ -62,7 +62,11 @@ class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking- @foreach($studies as $study) {{ $study->accession_number }} - {{ $study->patient_id }} + + + {{ $study->patient_id }} + + {{ $study->patient_name }} diff --git a/routes/web.php b/routes/web.php index b77c091..2cb22bd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,6 +5,7 @@ use App\Http\Controllers\SocialLoginController; use App\Http\Controllers\Staff\StudiesController; use App\Http\Controllers\Staff\StudyHistoryController; +use App\Http\Controllers\StudyMetadataController; use App\Http\Controllers\System\SyncOrthancController; use Illuminate\Support\Facades\Route; @@ -42,6 +43,12 @@ Route::post('{hashid}', [StudyHistoryController::class, 'save'])->name('save'); }); + Route::group(['prefix' => 'meta', 'as' => 'meta.'], function () { + Route::get('{hashid}', [StudyMetadataController::class, 'view'])->name('view'); + Route::get('{hashid}/edit', [StudyMetadataController::class, 'edit'])->name('edit'); + Route::post('{hashid}', [StudyMetadataController::class, 'save'])->name('save'); + }); + }); });