decodeKeys(); $study = Study::with(['reports.radiologist', 'reports.study', 'assignedPhysicians'])->findOrFail($this->key); if (me()->isRadiologist()) { // abort_unless($study->isAssigned(), 403); abort_unless($study->isUserInStudyAssignmentsOrReadingPhysician(), 403); } $reports = $study->reports->sortByDesc('created_at'); return view('staff.reports.popup', compact('study', 'reports')); } public function save(StoreReportRequest $request) { ReportManager::ensureEditAccess(); $this->decodeKeys(); $manager = ReportManager::make($this->key); $reportStatus = ReportStatus::from($request->integer('report_status')); $report = $manager->createReport(request('content'), $reportStatus); if ($reportStatus->value === ReportStatus::Finalized->value) { $manager->finalizeReport($report); } return view('content.pages.close-window'); } public function create() { ReportManager::ensureEditAccess(); $this->decodeKeys(); $manager = ReportManager::make($this->key); $view = $manager->check(); if ($view) { return $view; } $manager->lockStudyIfRequired(); $study = $manager->getStudy(); $report = $manager->latestReport(); // todo: study_status: Read in Progress return view('staff.reports.create', compact('study', 'report')); } public function edit(string $uuid) { ReportManager::ensureEditAccess(); $manager = ReportManager::fromReport($uuid); $view = $manager->check(); if ($view) { return $view; } $manager->lockStudyIfRequired(); $study = $manager->getStudy(); $report = $manager->getReport(); return view('staff.reports.create', compact('study', 'report')); } public function view(string $uuid) { ReportManager::ensureDownloadAccess(); $manager = ReportManager::fromReport($uuid); $title = 'View Report'; $report = $manager->getReport(); return view('staff.reports.viewer.html-report', compact('report', 'title')); } }