user()->may(Permission::StudyMetadataView), 403); $study = $this->getStudy(); return view('staff.meta.view', compact('study')); } public function edit() { abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403); $study = $this->getStudy(); if ($study->isReportReady()) { return $this->lockedNotice(); } return view('staff.meta.edit', compact('study')); } public function save(StudyMetadataUpdateRequest $request) { abort_unless(may(Permission::StudyMetadataEdit), 403); $study = $this->getStudy(); if ($study->isReportReady()) { return $this->lockedNotice(); } $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['workflow_level'] = WorkflowLevel::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'); } }