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);
$this->decodeKeys();
$study = Study::findOrFail($this->key);
$reportStatus = ReportStatus::from($request->integer('report_status'));
$report = StudyReport::make([
'study_id' => $study->id,
'institute_id' => $study->institute_id,
'facility_id' => $study->facility_id,
'report_status' => ReportStatus::Preliminary->value,
'report_status' => $reportStatus->value,
'read_by_id' => me()->id,
]);
$report->saveContent(request('content'));
$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()
@ -56,8 +64,9 @@ public function create()
->where('report_status', ReportStatus::Preliminary->value)
->latest()
->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)
@ -66,8 +75,9 @@ public function edit(string $uuid)
$report = StudyReport::with(['study', 'radiologist'])->where('accession_number', $uuid)->firstOrFail();
$study = $report->study;
$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)

View File

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

View File

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

View File

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

View File

@ -16,30 +16,24 @@
<div class="container">
<div class="mt-8">
<div class="row ">
<div class="container-split">
<div class="col-7">
<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">
<div class="container__left">
<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">
</iframe>
</div>
<div class="resizer"></div>
<div class="container__right">
<div
class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container"
id="editor-container">
<div class="editor-container__editor">
<div id="editor"></div>
</div>
<div class="editor_container__word-count" id="editor-word-count"></div>
</iframe>
</div>
<div class="col-5">
<div
class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container"
id="editor-container">
<div class="editor-container__editor">
<div id="editor"></div>
</div>
<div class="editor_container__word-count" id="editor-word-count"></div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"

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 name="viewport" content="width=device-width, initial-scale=1">
<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-premium-features/44.1.0/ckeditor5-premium-features.css" crossorigin>
<link rel="stylesheet" href="./ck.css">
<link rel="stylesheet" href="{{ asset('ck.css') }}">
</head>
<body>
<div class="container">
<div class="mt-8">
<div class="row ">
<iframe class="fixed-container" src="{{ $study->getOhifLink() }}">
<body @if ($close) onload="window.close()" @endif>
<div class="py-4">
<p class="text-center">HEADER</p>
</div>
<div class="container-fluid px-4 mb-4">
<div class="row">
<div class="col-7">
<iframe class="fixed-container" src="{{ $study->getStoneLink() }}">
</iframe>
</div>
<div class="col-5">
<form action="{{ route('staff.report.save') }}" method="POST">
@csrf
<input type="hidden" value="{{ $study->hash }}" name="hashid">
<div
class="ck-editor editor-container editor-container_classic-editor editor-container_include-word-count fixed-container"
id="editor-container">
@ -28,12 +35,42 @@ class="ck-editor editor-container editor-container_classic-editor editor-contain
</div>
<div class="editor_container__word-count" id="editor-word-count"></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>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"

View File

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