wip assignment
This commit is contained in:
parent
3161b143bb
commit
1a2c67d852
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Http\Controllers\HashidControllerBase;
|
||||
use App\Models\Enums\Permission;
|
||||
use App\Models\Enums\UserRole;
|
||||
use App\Models\Study;
|
||||
use App\Services\AuditTrail\Activity;
|
||||
|
||||
@ -64,13 +63,4 @@ public function attachments()
|
||||
|
||||
return view('staff.history.partials._uploaded-studies-list', compact('study', 'allow_delete'));
|
||||
}
|
||||
|
||||
public function assignmentShow()
|
||||
{
|
||||
$this->decodeKeys();
|
||||
$study = Study::findOrFail($this->key);
|
||||
$rads = User::active()->role(UserRole::Radiologist)->get();
|
||||
|
||||
return view('staff.studies.assign-form', compact('study', 'rads'));
|
||||
}
|
||||
}
|
||||
|
49
app/Http/Controllers/Staff/StudyAssignmentController.php
Normal file
49
app/Http/Controllers/Staff/StudyAssignmentController.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Http\Controllers\HashidControllerBase;
|
||||
use App\Http\Requests\AssignPhysicianRequest;
|
||||
use App\Models\Enums\UserRole;
|
||||
use App\Models\Study;
|
||||
use App\Models\User;
|
||||
use App\Services\AuditTrail\Activity;
|
||||
|
||||
class StudyAssignmentController extends HashidControllerBase
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
$this->decodeKeys();
|
||||
$study = Study::with('assignedPhysician')->findOrFail($this->key);
|
||||
$rads = User::active()->role(UserRole::Radiologist)->get();
|
||||
|
||||
return view('staff.studies.assign-form', compact('study', 'rads'));
|
||||
}
|
||||
|
||||
public function remove()
|
||||
{
|
||||
$this->decodeKeys();
|
||||
$study = Study::with('assignedPhysician')->findOrFail($this->key);
|
||||
if ($study->assigned_physician_id !== null) {
|
||||
$study->update(['assigned_physician_id' => null]);
|
||||
audit()
|
||||
->did(Activity::Unassign_Physician)
|
||||
->notes("Previous assignment: {$study->assignedPhysician?->display_name}")
|
||||
->on($study)
|
||||
->log();
|
||||
}
|
||||
|
||||
return redirect()->route('staff.worklist.index')->with('success', 'Removed assignment');
|
||||
}
|
||||
|
||||
public function save(AssignPhysicianRequest $request)
|
||||
{
|
||||
$this->decodeKeys();
|
||||
$study = Study::findOrFail($this->key);
|
||||
$rad = User::active()->findOrFail($request->input('rad_id'));
|
||||
$study->update(['assigned_physician_id' => $rad->id]);
|
||||
audit()->did(Activity::Assign_Physician)->on($study)->log();
|
||||
|
||||
return redirect()->route('staff.worklist.index')->with('success', "Assigned study to {$rad->display_name}");
|
||||
}
|
||||
}
|
20
app/Http/Requests/AssignPhysicianRequest.php
Normal file
20
app/Http/Requests/AssignPhysicianRequest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AssignPhysicianRequest extends FormRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'rad_id' => ['required', 'exists:users,id'],
|
||||
];
|
||||
}
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -36,4 +36,7 @@ final class Activity
|
||||
public const int User_Failed_Login = 302;
|
||||
|
||||
public const int User_Logout = 303;
|
||||
|
||||
public const int Assign_Physician = 401;
|
||||
public const int Unassign_Physician = 402;
|
||||
}
|
||||
|
@ -1,8 +1,25 @@
|
||||
<div>
|
||||
Currently assigned: {{ $study->assignedPhysician?->display_name ?? 'None' }}
|
||||
@isset($study->assignedPhysician)
|
||||
<form action="{{ route('staff.assign.remove', $study->hash) }}" class="inline" method="post">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger btn-xs" type="submit">Remove</button>
|
||||
</form>
|
||||
@endisset
|
||||
</div>
|
||||
|
||||
<table class="table table-sm">
|
||||
@foreach ($rads as $doc)
|
||||
<tr>
|
||||
<td>{{ $doc->display_name }}</td>
|
||||
<td>X</td>
|
||||
<td>
|
||||
<form action="{{ route('staff.assign.save', $study->hash) }}" class="inline" method="post">
|
||||
@csrf
|
||||
<input type="hidden" name="rad_id" value="{{ $doc->id }}">
|
||||
<button class="btn btn-primary btn-xs" type="submit">Assign</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
@ -59,7 +59,7 @@
|
||||
|
||||
$('body').on('click', '.show-assign', function () {
|
||||
var study_id = $(this).data('id');
|
||||
$.get("{{ route('staff.studies.assign-show') }}", {hashid: study_id}, function (data) {
|
||||
$.get("{{ route('staff.assign.show') }}", {hashid: study_id}, function (data) {
|
||||
$('#assign-details').html(data);
|
||||
$('#assign-modal').modal('show');
|
||||
});
|
||||
|
@ -6,6 +6,7 @@
|
||||
use App\Http\Controllers\SocialLoginController;
|
||||
use App\Http\Controllers\Staff\AttachmentController;
|
||||
use App\Http\Controllers\Staff\StudiesController;
|
||||
use App\Http\Controllers\Staff\StudyAssignmentController;
|
||||
use App\Http\Controllers\Staff\StudyHistoryController;
|
||||
use App\Http\Controllers\Staff\StudyViewerController;
|
||||
use App\Http\Controllers\Staff\WorklistController;
|
||||
@ -57,6 +58,12 @@
|
||||
Route::get('attach', [StudiesController::class, 'attachments'])->name('attach');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'assign', 'as' => 'assign.'], function () {
|
||||
Route::get('', [StudyAssignmentController::class, 'show'])->name('show');
|
||||
Route::post('{hashid}', [StudyAssignmentController::class, 'save'])->name('save');
|
||||
Route::delete('{hashid}', [StudyAssignmentController::class, 'remove'])->name('remove');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'history', 'as' => 'history.'], function () {
|
||||
Route::get('{hashid}', [StudyHistoryController::class, 'view'])->name('view');
|
||||
Route::get('{hashid}/edit', [StudyHistoryController::class, 'edit'])->name('edit');
|
||||
|
Loading…
Reference in New Issue
Block a user