wip
This commit is contained in:
parent
a55224fe73
commit
b493f2742b
@ -4,7 +4,6 @@
|
||||
|
||||
use App\DAL\Studies\WorklistFactory;
|
||||
use App\Models\Study;
|
||||
use App\Models\User;
|
||||
use App\Services\ACL\WorklistButton;
|
||||
use App\Services\ACL\WorklistColumn;
|
||||
use App\Services\ACL\WorklistGuard;
|
||||
@ -121,6 +120,7 @@ public function getColumns(): array
|
||||
->width('18px')
|
||||
->title('');
|
||||
break;
|
||||
|
||||
case WorklistColumn::ReportStatus:
|
||||
$columns[] = Column::make($col->value)
|
||||
->searchable(false)
|
||||
@ -132,14 +132,16 @@ public function getColumns(): array
|
||||
->width('18px')
|
||||
->title('');
|
||||
break;
|
||||
|
||||
case WorklistColumn::History:
|
||||
$columns[] = Column::make($col->value)
|
||||
->searchable(false)
|
||||
->orderable(false)
|
||||
->addClass('text-center')
|
||||
->width('20px')
|
||||
->width('16px')
|
||||
->title('');
|
||||
break;
|
||||
|
||||
case WorklistColumn::PatientSexAge:
|
||||
$columns[] = Column::make($col->value)
|
||||
->searchable(false)
|
||||
@ -147,25 +149,31 @@ public function getColumns(): array
|
||||
->addClass('text-center')
|
||||
->title('Age');
|
||||
break;
|
||||
|
||||
case WorklistColumn::StudyDate:
|
||||
$columns[] = Column::make($col->value)->searchable(false)->title('Scan Dt');
|
||||
$columns[] = Column::make($col->value)->searchable(false)->title('Scanned');
|
||||
break;
|
||||
|
||||
case WorklistColumn::ReceiveDate:
|
||||
$columns[] = Column::make($col->value)->searchable(false)->title('Received');
|
||||
break;
|
||||
|
||||
case WorklistColumn::ReportDate:
|
||||
$columns[] = Column::make($col->value)->searchable(false)->title('Read At');
|
||||
break;
|
||||
|
||||
case WorklistColumn::AssignedPhysician:
|
||||
$columns[] = Column::make($col->value)
|
||||
->searchable(false)
|
||||
->title('Assigned');
|
||||
->title('Rad');
|
||||
break;
|
||||
|
||||
case WorklistColumn::ReadingPhysician:
|
||||
$columns[] = Column::make($col->value)
|
||||
->searchable(false)
|
||||
->title('Read By');
|
||||
break;
|
||||
|
||||
case WorklistColumn::ActionButtons:
|
||||
case WorklistColumn::ViewerButtons:
|
||||
case WorklistColumn::ReportButtons:
|
||||
@ -174,12 +182,26 @@ public function getColumns(): array
|
||||
->orderable(false)
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center p-0 ps-2')
|
||||
// ->width(60)
|
||||
->addClass('p-0 ps-2')
|
||||
->title('');
|
||||
break;
|
||||
|
||||
case WorklistColumn::PatientId:
|
||||
$columns[] = Column::make($col->value)->title('ID');
|
||||
break;
|
||||
|
||||
case WorklistColumn::PatientName:
|
||||
$columns[] = Column::make($col->value)->title('Patient');
|
||||
break;
|
||||
|
||||
case WorklistColumn::StudyDescription:
|
||||
$columns[] = Column::make($col->value)->title('Study');
|
||||
break;
|
||||
|
||||
default:
|
||||
$columns[] = Column::make($col->value)->title(Str::title($col->value));
|
||||
// dd(Str::slug($col->value, '-'));
|
||||
$columns[] = Column::make($col->value)->title($this->columTitle($col->value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -187,6 +209,11 @@ public function getColumns(): array
|
||||
return $columns;
|
||||
}
|
||||
|
||||
private function columTitle(string $str): string
|
||||
{
|
||||
return Str::of($str)->slug()->replace('-', ' ')->title()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
@ -201,12 +228,19 @@ protected function filename(): string
|
||||
return Str::slug(implode(' ', $parts), '_');
|
||||
}
|
||||
|
||||
private function physicianColumn(?User $user, Carbon|CarbonImmutable|null $dt): ?string
|
||||
private function physicianColumn(Study $study): ?string
|
||||
{
|
||||
$user = $study->readingPhysician;
|
||||
if ($user === null) {
|
||||
if ($study->assigned_at !== null) {
|
||||
return '<img src="' . asset('imgs/checklist.png') . '" data-bs-toggle="tooltip" data-bs-placement="right" title="Assigned at ' . $study->assigned_at->format(self::DATE_FORMAT_LONG) . '">';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$dt = $study->read_at;
|
||||
|
||||
return Blade::render('staff.worklist.partials._radiologist-listing',
|
||||
[
|
||||
'avatar_url' => $user->avatar(),
|
||||
@ -227,14 +261,20 @@ private function renderCustomColumns(): array
|
||||
foreach (WorklistGuard::worklistColumns() as $col) {
|
||||
switch ($col) {
|
||||
case WorklistColumn::PatientName:
|
||||
$columns[$col->value] = fn (Study $study) => $study->sanitizedPatientName();
|
||||
$columns[$col->value] = static function (Study $study) {
|
||||
if (me()->isRadiologist()) {
|
||||
return $study->sanitizedPatientName();
|
||||
}
|
||||
|
||||
return '<a target="_blank" href="' . route('staff.history.edit', $study->hash) . '">' . $study->sanitizedPatientName() . '</a>';
|
||||
};
|
||||
break;
|
||||
case WorklistColumn::StudyDescription:
|
||||
$columns[$col->value] = fn (Study $study) => $study->sanitizedStudyDescription();
|
||||
$columns[$col->value] = static fn (Study $study) => $study->sanitizedStudyDescription();
|
||||
break;
|
||||
case WorklistColumn::AssignedPhysician:
|
||||
$columns[$col->value] = function (Study $study) {
|
||||
if ($study->assigned_at != null) {
|
||||
$columns[$col->value] = static function (Study $study) {
|
||||
if ($study->assigned_at !== null) {
|
||||
return '<img src="' . asset('imgs/checklist.png') . '" data-bs-toggle="tooltip" data-bs-placement="right" title="' . $study->assigned_at->format(self::DATE_FORMAT_LONG) . '">';
|
||||
}
|
||||
|
||||
@ -242,7 +282,7 @@ private function renderCustomColumns(): array
|
||||
};
|
||||
break;
|
||||
case WorklistColumn::ReadingPhysician:
|
||||
$columns[$col->value] = fn (Study $study) => $this->physicianColumn($study->readingPhysician, $study->read_at);
|
||||
$columns[$col->value] = fn (Study $study) => $this->physicianColumn($study);
|
||||
break;
|
||||
case WorklistColumn::Series:
|
||||
$columns[$col->value] = fn (Study $study) => Blade::render(
|
||||
@ -309,6 +349,21 @@ private function renderButton(string $data_id, string $fa_icon, string $data_cla
|
||||
);
|
||||
}
|
||||
|
||||
private function renderImageLink(string $data_id, string $img_src, string $data_class, string $text, string $url = '#', bool $blank = false, int $width = 18): string
|
||||
{
|
||||
return Blade::render('staff.worklist.partials._image-link',
|
||||
[
|
||||
'data_id' => $data_id,
|
||||
'url' => $url,
|
||||
'img_src' => asset('imgs/' . $img_src),
|
||||
'data_class' => $data_class,
|
||||
'text' => $text,
|
||||
'blank' => $blank,
|
||||
'width' => $width,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
private function generateViewerButtons(Study $study): string
|
||||
{
|
||||
$btns = [];
|
||||
@ -332,19 +387,16 @@ private function generateViewerButtons(Study $study): string
|
||||
private function generateActionButtons(Study $study): string
|
||||
{
|
||||
$btns = [];
|
||||
foreach (WorklistGuard::worklistButtons() as $button) {
|
||||
foreach (WorklistGuard::worklistButtons($study) as $button) {
|
||||
switch ($button) {
|
||||
case WorklistButton::StudyMetadata:
|
||||
$btns[] = $this->renderButton($study->hash, 'fa-circle-info', 'showStudy btn-outline-facebook', 'Info');
|
||||
$btns[] = $this->renderImageLink($study->hash, 'info.png', 'showStudy', 'Info');
|
||||
break;
|
||||
case WorklistButton::History:
|
||||
$btns[] = $this->renderButton($study->hash, 'fa-pen-to-square', 'btn-outline-primary', 'Edit', route('staff.history.edit', $study->hash), true);
|
||||
case WorklistButton::Assign:
|
||||
$btns[] = $this->renderImageLink($study->hash, 'assign.png', 'show-assign', 'Assign');
|
||||
break;
|
||||
case WorklistButton::Notes:
|
||||
$btns[] = $this->renderButton($study->hash, 'fa-user-doctor', 'btn-outline-youtube show-assign', 'Assign');
|
||||
break;
|
||||
case WorklistButton::Attachment:
|
||||
$btns[] = $this->renderButton($study->hash, 'fa-edit', 'btn-outline-secondary', 'ED', route('staff.meta.edit', $study->hash), true);
|
||||
$btns[] = $this->renderImageLink($study->hash, 'chat.png', 'show-notes', 'Chat');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -442,7 +442,27 @@ public function setReportStatus(ReportStatus $status, User|int|null $user = null
|
||||
public function canEditReport(): bool
|
||||
{
|
||||
// todo: check if the study disallows reporting
|
||||
return $this->report_status->value < ReportStatus::Finalized->value;
|
||||
return $this->isActive() && $this->reportStatusBefore(ReportStatus::Finalized);
|
||||
|
||||
}
|
||||
|
||||
public function reportStatusBefore(ReportStatus $checkpoint): bool
|
||||
{
|
||||
return $this->report_status->value < $checkpoint->value;
|
||||
}
|
||||
|
||||
public function canEditMetadata(): bool
|
||||
{
|
||||
return $this->isActive() && $this->reportStatusBefore(ReportStatus::Finalized);
|
||||
}
|
||||
|
||||
public function canAssignRad(): bool
|
||||
{
|
||||
if ($this->isLocked()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->isActive() && $this->reportStatusBefore(ReportStatus::Preliminary);
|
||||
}
|
||||
|
||||
public function hasReports(): bool
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\ACL;
|
||||
|
||||
use App\Models\Study;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@ -14,16 +15,16 @@ public static function worklistColumns(User|int|null $usr = null): Collection
|
||||
WorklistColumn::Priority,
|
||||
WorklistColumn::ReportStatus,
|
||||
WorklistColumn::ActionButtons,
|
||||
// WorklistColumn::AssignedPhysician,
|
||||
WorklistColumn::PatientId,
|
||||
WorklistColumn::PatientName,
|
||||
WorklistColumn::PatientSexAge,
|
||||
WorklistColumn::StudyDate,
|
||||
WorklistColumn::ReceiveDate,
|
||||
WorklistColumn::StudyDescription,
|
||||
WorklistColumn::AssignedPhysician,
|
||||
WorklistColumn::ReadingPhysician,
|
||||
WorklistColumn::ReportDate,
|
||||
WorklistColumn::History,
|
||||
// WorklistColumn::History,
|
||||
WorklistColumn::Modality,
|
||||
WorklistColumn::Series,
|
||||
WorklistColumn::ReportButtons,
|
||||
@ -47,18 +48,26 @@ public static function worklistColumns(User|int|null $usr = null): Collection
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public static function worklistButtons(?int $user_id = null): Collection
|
||||
public static function worklistButtons(Study $study, User|int|null $usr = null): Collection
|
||||
{
|
||||
$user = $user_id !== null ? User::findOrFail($user_id) : auth()->user();
|
||||
$user = me($usr);
|
||||
if ($user->isRadiologist()) {
|
||||
return collect([
|
||||
WorklistButton::StudyMetadata,
|
||||
WorklistButton::Notes,
|
||||
]);
|
||||
}
|
||||
|
||||
$buttons = collect([
|
||||
WorklistButton::StudyMetadata,
|
||||
WorklistButton::History,
|
||||
WorklistButton::Notes,
|
||||
WorklistButton::Attachment,
|
||||
WorklistButton::Assign,
|
||||
WorklistButton::Report,
|
||||
]);
|
||||
|
||||
if ($study->canAssignRad()) {
|
||||
$buttons->push(WorklistButton::Assign);
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,6 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('modalities', static function (Blueprint $table) {
|
||||
|
@ -8,9 +8,6 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('procedures', static function (Blueprint $table) {
|
||||
|
Loading…
Reference in New Issue
Block a user