wip
This commit is contained in:
parent
2800786c94
commit
2a38df9383
@ -7,6 +7,7 @@
|
||||
use App\Http\Controllers\HashidControllerBase;
|
||||
use App\Http\Requests\StudyMetadataUpdateRequest;
|
||||
use App\Models\Study;
|
||||
use App\Services\AuditTrail\Activity;
|
||||
|
||||
class MetadataController extends HashidControllerBase
|
||||
{
|
||||
@ -14,7 +15,7 @@ public function view()
|
||||
{
|
||||
abort_unless(auth()->user()->may(Permission::StudyMetadataView), 403);
|
||||
$this->decodeKeys();
|
||||
$study = Study::find($this->key);
|
||||
$study = Study::findOrFail($this->key);
|
||||
|
||||
return view('staff.meta.view', compact('study'));
|
||||
}
|
||||
@ -23,7 +24,20 @@ public function edit()
|
||||
{
|
||||
abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403);
|
||||
$this->decodeKeys();
|
||||
$study = Study::find($this->key);
|
||||
$study = Study::findOrFail($this->key);
|
||||
|
||||
if (in_array($study->report_status->value, [
|
||||
ReportStatus::Finalized->value,
|
||||
ReportStatus::Approved->value,
|
||||
],
|
||||
true)) {
|
||||
return view('content.pages.notice', [
|
||||
'title' => 'Study Locked',
|
||||
'color' => 'danger',
|
||||
'heading' => 'Study Locked',
|
||||
'message' => 'Study metadata cannot be edited once the report has been finalized.',
|
||||
]);
|
||||
}
|
||||
|
||||
return view('staff.meta.edit', compact('study'));
|
||||
}
|
||||
@ -33,12 +47,21 @@ public function save(StudyMetadataUpdateRequest $request)
|
||||
abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403);
|
||||
$this->decodeKeys();
|
||||
$study = Study::findOrFail($this->key);
|
||||
abort_if($study->report_status->value >= ReportStatus::Finalized->value, 403);
|
||||
$payload = array_trim_strings($request->validated());
|
||||
$payload['body_part_examined'] = strtoupper($payload['body_part_examined']);
|
||||
$payload['patient_sex'] = strtoupper($payload['patient_sex']);
|
||||
if ($request->has('cancel_read')) {
|
||||
// lock the study if report is not needed
|
||||
$payload['report_status'] = ReportStatus::Cancelled->value;
|
||||
$payload['locked_at'] = now();
|
||||
unset($payload['cancel_read']);
|
||||
}
|
||||
$study->update($payload);
|
||||
audit()
|
||||
->on($study)
|
||||
->did(Activity::Study_Metadata_Edit)
|
||||
->log();
|
||||
|
||||
// return redirect()->route('staff.history.view', _h($this->key));
|
||||
return view('content.pages.close-window');
|
||||
|
@ -15,7 +15,7 @@ public function rules(): array
|
||||
'patient_birthdate' => ['nullable', 'date'],
|
||||
'accession_number' => ['nullable'],
|
||||
|
||||
//'study_date' => ['required', 'date'],
|
||||
// 'study_date' => ['required', 'date'],
|
||||
'study_description' => ['required'],
|
||||
'body_part_examined' => ['required'],
|
||||
'referring_physician_name' => ['nullable'],
|
||||
@ -35,4 +35,6 @@ public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function validateResolved() {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user