format(self::DATE_FORMAT); } public function dataTable(QueryBuilder $query): EloquentDataTable { return (new EloquentDataTable($query)) ->addColumn('action', 'worklist.action') ->editColumn('patient_name', fn (Study $study) => $study->sanitizedPatientName()) ->editColumn('study_description', fn (Study $study) => $study->sanitizedStudyDescription()) ->editColumn('reader', function (Study $study) { if ($study->readingPhysician == null) { return ''; } return '' . $study->readingPhysician->display_name; }) ->editColumn('images', function (Study $study) { return $study->numInstances() . '' . human_filesize($study->disk_size) . ''; }) ->editColumn('study_date', function (Study $study) { return self::dtFormat($study->study_date); }) ->editColumn('reported_at', function (Study $study) { return self::dtFormat($study->reported_at); }) ->editColumn('received_at', function (Study $study) { return self::dtFormat($study->received_at); }) ->editColumn('show_study', function (Study $study) { $btn = 'Show'; $btn .= ' Edit'; $btn .= ' Delete'; return $btn; }) ->editColumn('history', function (Study $study) { return sprintf(' ', blank($study->body_part_examined) ? 'text-muted' : 'text-primary'); }) ->orderColumn('patient_name', 'patient_name $1') ->rawColumns(['priority_icon', 'report_status_led', 'images', 'reader', 'history', 'show_study']) ->setRowId('id'); } /** * Get the query source of dataTable. */ public function query(Study $model): QueryBuilder { return WorklistFactory::getLister()->query(); // return $model->newQuery(); } /** * Optional method if you want to use the html builder. */ public function html(): HtmlBuilder { return $this->builder() ->setTableId('worklist-table') ->columns($this->getColumns()) ->minifiedAjax() ->searchPanes(SearchPane::make(['show' => true, 'hideCount' => true])) ->parameters( [ // 'dom' => 'Pfrtip', // 'dom' => 'Bfrtip', 'buttons' => [ 'searchPanes', 'excel', // 'csv', // 'pdf', // 'print', // 'reset', // 'reload', ], 'order' => [ [0, 'desc'], [8, 'desc'], ], ]) // ->selectStyleSingle() ->pageLength(15) ->lengthMenu([15, 25, 50, 100, 250]); } /** * Get the dataTable columns definition. */ public function getColumns(): array { return [ Column::make('priority')->hidden(), Column::make('priority_icon') ->searchable(false) ->orderable(false) ->addClass('text-center') ->width('20px') ->title(''), Column::make('report_status_led') ->searchable(false) ->orderable(false) ->addClass('text-center') ->width('20px') ->title(''), Column::make('history') ->searchable(false) ->orderable(false) ->addClass('text-center') ->width('20px') ->title(''), Column::make('modality')->title('Mo'), Column::make('patient_id')->title('MRN'), Column::make('patient_name')->title('Patient'), Column::make('sex_age') ->searchable(false) ->orderable(false) ->addClass('text-center') ->title('Age'), Column::make('study_description') ->title('Study'), Column::make('show_study')->searchable(false) ->orderable(false) ->addClass('text-center') ->width('20px') ->title(''), Column::make('study_date')->searchable(false)->title('Scan Dt'), Column::make('reader') ->searchable(false) ->title('Read by'), Column::make('reported_at')->searchable(false)->title('Read At'), // Column::make('body_part_examined'), Column::make('images') ->searchable(false) ->orderable(false) ->addClass('text-center') ->title('Images'), Column::make('received_at')->searchable(false)->title('Received'), // Column::make('xxx'), Column::computed('action') ->exportable(false) ->printable(false) ->width(60) ->addClass('text-center'), ]; } /** * Get the filename for export. */ protected function filename(): string { $parts = [ config('app.name'), 'worklist', date('YmdHi'), ]; return Str::slug(implode(' ', $parts), '_'); } }