This commit is contained in:
Dr Masroor Ehsan 2025-01-11 17:32:41 +06:00
parent 92545ac719
commit 10c6921209
8 changed files with 95 additions and 47 deletions

View File

@ -30,18 +30,26 @@ public function save(CreateReportRequest $request)
abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove]), 403); abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove]), 403);
$this->decodeKeys(); $this->decodeKeys();
$study = Study::findOrFail($this->key); $study = Study::findOrFail($this->key);
$reportStatus = ReportStatus::from($request->integer('report_status'));
$report = StudyReport::make([ $report = StudyReport::make([
'study_id' => $study->id, 'study_id' => $study->id,
'institute_id' => $study->institute_id, 'institute_id' => $study->institute_id,
'facility_id' => $study->facility_id, 'facility_id' => $study->facility_id,
'report_status' => ReportStatus::Preliminary->value, 'report_status' => $reportStatus->value,
'read_by_id' => me()->id, 'read_by_id' => me()->id,
]); ]);
$report->saveContent(request('content')); $report->saveContent(request('content'));
$report->save(); $report->save();
return redirect()->back()->with('success', 'Report saved successfully.'); if ($reportStatus->value >= ReportStatus::Finalized) {
// todo: log activities
$report->setStatus($reportStatus);
$study->setReportStatus($reportStatus);
$study->unlockStudy();
}
return view('staff.reports.close-window');
} }
public function create() public function create()
@ -56,8 +64,9 @@ public function create()
->where('report_status', ReportStatus::Preliminary->value) ->where('report_status', ReportStatus::Preliminary->value)
->latest() ->latest()
->first(); ->first();
$close = false;
return view('staff.reports.create', compact('study', 'report')); return view('staff.reports.create', compact('study', 'report', 'close'));
} }
public function edit(string $uuid) public function edit(string $uuid)
@ -66,8 +75,9 @@ public function edit(string $uuid)
$report = StudyReport::with(['study', 'radiologist'])->where('accession_number', $uuid)->firstOrFail(); $report = StudyReport::with(['study', 'radiologist'])->where('accession_number', $uuid)->firstOrFail();
$study = $report->study; $study = $report->study;
$title = 'View Report'; $title = 'View Report';
$close = false;
return view('staff.reports.create', compact('study', 'report')); return view('staff.reports.create', compact('study', 'report', 'close'));
} }
public function view(string $uuid) public function view(string $uuid)

View File

@ -2,9 +2,11 @@
namespace App\Http\Requests; namespace App\Http\Requests;
use App\Domain\Report\ReportStatus;
use App\Models\Study; use App\Models\Study;
use App\Rules\ExistsByHash; use App\Rules\ExistsByHash;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CreateReportRequest extends FormRequest class CreateReportRequest extends FormRequest
{ {
@ -18,6 +20,11 @@ public function rules(): array
return [ return [
'hashid' => ['required', new ExistsByHash(Study::class)], 'hashid' => ['required', new ExistsByHash(Study::class)],
'content' => 'required', 'content' => 'required',
'report_status' => ['required',
Rule::enum(ReportStatus::class)
->only([ReportStatus::Preliminary, ReportStatus::Finalized, ReportStatus::Approved]),
],
]; ];
} }
} }

View File

@ -102,12 +102,11 @@ public function canRemove(User|int|null $user = null): bool
public function canEdit(User|int|null $user = null): bool public function canEdit(User|int|null $user = null): bool
{ {
if ($this->study->canEditReport() && if ($this->report_status->value < ReportStatus::Finalized->value &&
$this->report_status->value < ReportStatus::Finalized->value) { $this->study->canEditReport() &&
if ($this->read_by_id === me($user)->id) { $this->read_by_id === me($user)->id) {
return true; return true;
} }
}
return false; return false;
} }

View File

@ -55,9 +55,6 @@ .editor-container_include-word-count.editor-container_classic-editor .editor-con
border-radius: 0; border-radius: 0;
} }
/* Let's give the editor some space and limits using a border. */ /* Let's give the editor some space and limits using a border. */
.ck-editor { .ck-editor {
margin: 0 0 1em; margin: 0 0 1em;

View File

@ -16,16 +16,13 @@
<div class="container"> <div class="container">
<div class="mt-8"> <div class="mt-8">
<div class="row "> <div class="row ">
<div class="container-split"> <div class="col-7">
<div class="container__left">
<iframe class="fixed-container" <iframe class="fixed-container"
src="http://pacs.mylabctg.com:8042/stone-webviewer/index.html?study=1.3.12.2.1107.5.1.4.86027.30000024071105194090600000028"> src="http://pacs.mylabctg.com:8042/stone-webviewer/index.html?study=1.3.12.2.1107.5.1.4.86027.30000024071105194090600000028">
</iframe> </iframe>
</div> </div>
<div class="resizer"></div> <div class="col-5">
<div class="container__right">
<div <div
class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container" class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container"
id="editor-container"> id="editor-container">
@ -39,9 +36,6 @@ class="ck-editor editor-container editor-container_classic-editor editor-contain
</div> </div>
</div> </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>

View File

@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body onload="window.close()">
</body>
</html>

View File

@ -4,22 +4,29 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>SAVE</title> <title>SAVE</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> @vite([
'resources/assets/vendor/scss/core.scss',
'resources/assets/vendor/scss/theme-default.scss',
])
<link rel="stylesheet" href="https://cdn.ckeditor.com/ckeditor5/44.1.0/ckeditor5.css" crossorigin> <link rel="stylesheet" href="https://cdn.ckeditor.com/ckeditor5/44.1.0/ckeditor5.css" crossorigin>
<link rel="stylesheet" <link rel="stylesheet" href="{{ asset('ck.css') }}">
href="https://cdn.ckeditor.com/ckeditor5-premium-features/44.1.0/ckeditor5-premium-features.css" crossorigin>
<link rel="stylesheet" href="./ck.css">
</head> </head>
<body> <body @if ($close) onload="window.close()" @endif>
<div class="container"> <div class="py-4">
<div class="mt-8"> <p class="text-center">HEADER</p>
</div>
<div class="container-fluid px-4 mb-4">
<div class="row"> <div class="row">
<iframe class="fixed-container" src="{{ $study->getOhifLink() }}"> <div class="col-7">
<iframe class="fixed-container" src="{{ $study->getStoneLink() }}">
</iframe> </iframe>
</div>
<div class="col-5">
<form action="{{ route('staff.report.save') }}" method="POST"> <form action="{{ route('staff.report.save') }}" method="POST">
@csrf @csrf
<input type="hidden" value="{{ $study->hash }}" name="hashid"> <input type="hidden" value="{{ $study->hash }}" name="hashid">
<div <div
class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container" class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container"
id="editor-container"> id="editor-container">
@ -28,12 +35,42 @@ class="ck-editor editor-container editor-container_classic-editor editor-contain
</div> </div>
<div class="editor_container__word-count" id="editor-word-count"></div> <div class="editor_container__word-count" id="editor-word-count"></div>
</div> </div>
<div class="row w-75 mb-4">
<div class="col-md mb-md-0 mb-2">
<div class="form-check form-check-success custom-option custom-option-basic">
<label class="form-check-label custom-option-content" for="customRadioVTemp1">
<input name="report_status" class="form-check-input" type="radio" value="20"
id="customRadioVTemp1" checked/>
<span class="custom-option-header">
<span class="h6 mb-0">Draft</span>
</span>
<span class="custom-option-body">
<small>Preliminary report</small>
</span>
</label>
</div>
</div>
<div class="col-md">
<div class="form-check form-check-success custom-option custom-option-basic">
<label class="form-check-label custom-option-content" for="customRadioVTemp2">
<input name="report_status" class="form-check-input" type="radio" value="40"
id="customRadioVTemp2"/>
<span class="custom-option-header">
<span class="h6 mb-0">Finalize</span>
</span>
<span class="custom-option-body">
<small>Publish report</small>
</span>
</label>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Save</button> <button type="submit" class="btn btn-primary">Save</button>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"

View File

@ -39,8 +39,3 @@
</tr> </tr>
@endforeach @endforeach
</table> </table>
<a class="btn btn-primary btn-xs" target="_blank" href="{{ route('staff.report.create', $study->hash) }}">
Create New
</a>