diff --git a/app/Http/Controllers/Staff/ReportController.php b/app/Http/Controllers/Staff/ReportController.php index b2eac5c..a73148a 100644 --- a/app/Http/Controllers/Staff/ReportController.php +++ b/app/Http/Controllers/Staff/ReportController.php @@ -15,7 +15,7 @@ public function popup() { abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove, Permission::ReportDownload]), 403); $this->decodeKeys(); - $study = Study::with(['reports.radiologist', 'assignedPhysicians'])->findOrFail($this->key); + $study = Study::with(['reports.radiologist', 'reports.study', 'assignedPhysicians'])->findOrFail($this->key); if (me()->isRadiologist()) { // abort_unless($study->isAssigned(), 403); abort_unless($study->isUserInStudyAssignmentsOrReadingPhysician(), 403); diff --git a/app/Models/StudyReport.php b/app/Models/StudyReport.php index eae98cb..cf7adb6 100644 --- a/app/Models/StudyReport.php +++ b/app/Models/StudyReport.php @@ -79,6 +79,39 @@ public function getContent(): ?string return Storage::disk('public')->get($this->file_path); } + public function eligibleForExport(): bool + { + return $this->report_status->value >= ReportStatus::Finalized->value; + } + + public function canRemove(User|int|null $user = null): bool + { + if ($this->report_status->value < ReportStatus::Finalized->value) { + if ($this->read_by_id === me($user)->id) { + return true; + } + /* + if ($this->approved_by_id === me($user)->id) { + return true; + } + */ + } + + return false; + } + + public function canEdit(User|int|null $user = null): bool + { + if ($this->study->canEditReport() && + $this->report_status->value < ReportStatus::Finalized->value) { + if ($this->read_by_id === me($user)->id) { + return true; + } + } + + return false; + } + /** * @return array */ diff --git a/resources/views/staff/reports/popup.blade.php b/resources/views/staff/reports/popup.blade.php index a5452bc..eb338d8 100644 --- a/resources/views/staff/reports/popup.blade.php +++ b/resources/views/staff/reports/popup.blade.php @@ -10,18 +10,27 @@ {{ $report->radiologist?->name }} - - DOCX downloaddoc - - - PDF downloadpdf - - - HTML downloadhtm - + @if ($report->eligibleForExport()) + + DOCX downloaddoc + + + PDF downloadpdf + + + HTML downloadhtm + + @else + @if ($report->canEdit()) + edit_button + @endif + @if ($report->canRemove()) + remove_button + @endif + @endif @endforeach diff --git a/resources/views/staff/reports/viewer/html-report.blade.php b/resources/views/staff/reports/viewer/html-report.blade.php index ed6f236..31a21e7 100644 --- a/resources/views/staff/reports/viewer/html-report.blade.php +++ b/resources/views/staff/reports/viewer/html-report.blade.php @@ -1,36 +1,52 @@ @extends('staff.reports.viewer.layout') @section('content') - - - - - - - +
+
+
+
+
Patient Name{{ $report->study->patient_name }}Patient ID{{ $report->study->patient_id }}
+ + + + + + - - - - - - + + + + + + - - - - - - -
Patient Name{{ $report->study->patient_name }}Patient ID{{ $report->study->patient_id }}
Accession No{{ $report->study->accession_number }}Age/Gender{{ $report->study->sexAge() }}
Age/Gender{{ $report->study->sexAge() }}Accession No{{ $report->study->accession_number }}
Referred By{{ $report->study->referring_physician_name }}Date{{ $report->created_at->format('d-M-Y') }}
+ + Referred By + {{ $report->study->referring_physician_name }} + Date + {{ $report->created_at->format('d-M-Y') }} + + -
- {{ $report->study->modality }} REPORT -
+
+
+ {{ $report->study->modality }} Report +
+

+ {{ $report->study->study_description }} +

+
-

- {{ $report->study->study_description }} -

+ + + + - {!! $report->getContent() !!} +
+
+
+ {!! $report->getContent() !!} +
+
+
@endsection diff --git a/resources/views/staff/reports/viewer/layout.blade.php b/resources/views/staff/reports/viewer/layout.blade.php index cb54edb..5baff37 100644 --- a/resources/views/staff/reports/viewer/layout.blade.php +++ b/resources/views/staff/reports/viewer/layout.blade.php @@ -7,7 +7,7 @@ - + {{ $title }}