FIX
This commit is contained in:
parent
a5626014c3
commit
72def5d9dd
@ -8,6 +8,7 @@
|
||||
use App\Http\Requests\StoreReportRequest;
|
||||
use App\Models\Study;
|
||||
use App\Models\StudyReport;
|
||||
use App\Services\AuditTrail\Activity;
|
||||
|
||||
class ReportController extends HashidControllerBase
|
||||
{
|
||||
@ -42,10 +43,23 @@ public function save(StoreReportRequest $request)
|
||||
$report->saveContent(request('content'));
|
||||
$report->save();
|
||||
|
||||
if ($reportStatus->value >= ReportStatus::Finalized) {
|
||||
// todo: log activities
|
||||
audit()
|
||||
->on($study)
|
||||
->did($reportStatus->value >= ReportStatus::Finalized->value ? Activity::Report_Finalize : Activity::Report_Save)
|
||||
->notes($report->accession_number)
|
||||
->log();
|
||||
|
||||
if ($reportStatus->value === ReportStatus::Finalized->value) {
|
||||
$report->setStatus($reportStatus);
|
||||
$study->setReportStatus($reportStatus);
|
||||
audit()
|
||||
->on($study)
|
||||
->did(Activity::Report_Finalize)
|
||||
->log();
|
||||
audit()
|
||||
->on($study)
|
||||
->did(Activity::Study_Unlock)
|
||||
->log();
|
||||
$study->unlockStudy();
|
||||
}
|
||||
|
||||
@ -56,7 +70,7 @@ public function create()
|
||||
{
|
||||
abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove]), 403);
|
||||
$this->decodeKeys();
|
||||
$study = Study::select(['id', 'patient_name', 'patient_id', 'patient_sex', 'patient_birthdate', 'study_description'])->findOrFail($this->key);
|
||||
$study = Study::select(['id', 'patient_name', 'patient_id', 'patient_sex', 'patient_birthdate', 'study_description', 'report_status', 'study_status'])->findOrFail($this->key);
|
||||
if (! $study->canEditReport()) {
|
||||
return redirect()->back()->with('error', 'Report is already approved.');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user