This commit is contained in:
Dr Masroor Ehsan 2025-01-04 11:07:27 +06:00
parent 336d18181b
commit 8cb1b317d3
6 changed files with 94 additions and 11 deletions

View File

@ -25,4 +25,8 @@ public function setArchived(bool $archived): self;
public function setLocked(bool $locked): self; public function setLocked(bool $locked): self;
public function get(?int $user_id = null): LengthAwarePaginator; public function get(?int $user_id = null): LengthAwarePaginator;
public function setStudyDate(string $from, ?string $to = null): self;
public function setReceiveDate(string $from, ?string $to = null): self;
} }

View File

@ -5,6 +5,7 @@
use App\Models\Enums\ReportStatus; use App\Models\Enums\ReportStatus;
use App\Models\Enums\StudyLevelStatus; use App\Models\Enums\StudyLevelStatus;
use App\Models\Study; use App\Models\Study;
use Carbon\Carbon;
use Illuminate\Contracts\Database\Eloquent\Builder; use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Illuminate\Contracts\Pagination\LengthAwarePaginator;
@ -14,8 +15,6 @@ abstract class WorklistBase implements IUserStudyLister
private array $sortColumns = []; private array $sortColumns = [];
private ?string $sortDir = null;
private ?string $searchTerm = null; private ?string $searchTerm = null;
private ?int $radiologist_id = null; private ?int $radiologist_id = null;
@ -28,6 +27,14 @@ abstract class WorklistBase implements IUserStudyLister
private ?bool $archived = null; private ?bool $archived = null;
private ?string $studyDateFrom = null;
private ?string $studyDateTo = null;
private ?string $receiveDateFrom = null;
private ?string $receiveDateTo = null;
public function setRadiologist(int $radiologist_id): self public function setRadiologist(int $radiologist_id): self
{ {
$this->radiologist_id = $radiologist_id; $this->radiologist_id = $radiologist_id;
@ -115,6 +122,7 @@ public function get(?int $user_id = null): LengthAwarePaginator
$query = $this->applyReportStatus($query); $query = $this->applyReportStatus($query);
$query = $this->applyArchived($query); $query = $this->applyArchived($query);
$query = $this->applyLocked($query); $query = $this->applyLocked($query);
$query = $this->applyDateFilters($query);
return $query->paginate($this->getPageSize($user_id)); return $query->paginate($this->getPageSize($user_id));
} }
@ -200,4 +208,47 @@ private function applyLocked(Builder $query): Builder
return $query; return $query;
} }
private function applyDateFilter(Builder $query, string $column, string $from, ?string $to): Builder
{
$start = Carbon::parse($from);
if (filled($to)) {
$end = Carbon::parse($to);
$query = $query->whereBetween($column, [$start->toDateString(), $end->toDateString()]);
} else {
$query = $query->where($column, '>=', $start->toDateString());
}
return $query;
}
private function applyDateFilters(Builder $query): Builder
{
if (filled($this->studyDateFrom)) {
$query = $this->applyDateFilter($query, 'study_date', $this->studyDateFrom, $this->studyDateTo);
}
if (filled($this->receiveDateFrom)) {
$query = $this->applyDateFilter($query, 'receive_date', $this->receiveDateFrom, $this->receiveDateTo);
}
return $query;
}
public function setStudyDate(string $from, ?string $to = null): self
{
$this->studyDateFrom = $from;
$this->studyDateTo = $to;
return $this;
}
public function setReceiveDate(string $from, ?string $to = null): self
{
$this->receiveDateFrom = $from;
$this->receiveDateTo = $to;
return $this;
}
} }

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Api;
use App\DAL\Studies\WorklistFactory;
use App\Http\Controllers\Controller;
use App\Presenters\StudyPresenter;
use Illuminate\Http\Request;
class WorklistController extends Controller
{
public function studies(Request $request)
{
if (! $request->ajax()) {
abort(404);
}
$studies = StudyPresenter::pagination(WorklistFactory::getLister()->get());
// ->toArray();dd($studies);
return response()->json($studies);
}
}

View File

@ -174,4 +174,14 @@ public function allowed(): array
'ohif.seg' => filled($this->getOhifSegmentationLink()), 'ohif.seg' => filled($this->getOhifSegmentationLink()),
]; ];
} }
public function toArray(): array
{
return array_merge(parent::toArray(), [
'sex_age' => $this->sexAge(),
'num_instances' => $this->numInstances(),
'links' => $this->links(),
'allowed' => $this->allowed(),
]);
}
} }

View File

@ -2,7 +2,6 @@
namespace App\Presenters; namespace App\Presenters;
use Carbon\Carbon;
use CultureGr\Presenter\Presenter; use CultureGr\Presenter\Presenter;
class StudyPresenter extends Presenter class StudyPresenter extends Presenter
@ -11,12 +10,4 @@ public function toArray(): array
{ {
return $this->model->toArray(); return $this->model->toArray();
} }
public function sexAge(): array
{
$dob = $this->model->patient_birthdate;
$age = $dob ? Carbon::make($dob)->diffInYears() : null;
return "$age / {$this->model->patient_sex}";
}
} }

View File

@ -1,5 +1,6 @@
<?php <?php
use App\Http\Controllers\Api\WorklistController as ApiWorklistController;
use App\Http\Controllers\Guest\ViewSharedStudyController; use App\Http\Controllers\Guest\ViewSharedStudyController;
use App\Http\Controllers\Radiologist\ReportWriteController; use App\Http\Controllers\Radiologist\ReportWriteController;
use App\Http\Controllers\SocialLoginController; use App\Http\Controllers\SocialLoginController;
@ -29,6 +30,10 @@
return view('dashboard'); return view('dashboard');
})->name('dashboard'); })->name('dashboard');
Route::group(['prefix' => 'api', 'as' => 'api.'], function () {
Route::get('studies', [ApiWorklistController::class, 'studies'])->name('studies');
});
Route::group(['prefix' => 'radiologist', 'as' => 'radiologist.'], function () { Route::group(['prefix' => 'radiologist', 'as' => 'radiologist.'], function () {
Route::get('/report-write/{id}', ReportWriteController::class)->name('report-write'); Route::get('/report-write/{id}', ReportWriteController::class)->name('report-write');
}); });