This commit is contained in:
Dr Masroor Ehsan 2025-01-03 21:17:12 +06:00
parent 60c272f07c
commit 45b452fb0e
4 changed files with 42 additions and 30 deletions

View File

@ -14,9 +14,9 @@ public function setStudyStatus(StudyLevelStatus $status): void;
public function setReportStatus(ReportStatus $status): void; public function setReportStatus(ReportStatus $status): void;
public function setPageSize(int $size): void; public function setPerPage(int $size): void;
public function setSortColumn(string $column, string $dir): void; public function setSortOrder(string $order): void;
public function setSearchTerm(string $search): void; public function setSearchTerm(string $search): void;

View File

@ -10,9 +10,9 @@
abstract class WorklistBase implements IUserStudyLister abstract class WorklistBase implements IUserStudyLister
{ {
private ?int $pageSize = null; private ?int $perPage = null;
private ?string $sortColumn = null; private array $sortColumns = [];
private ?string $sortDir = null; private ?string $sortDir = null;
@ -43,7 +43,7 @@ private function applyRadiologist(Builder $query): Builder
if ($this->radiologist_id != null) { if ($this->radiologist_id != null) {
$rad = $this->radiologist_id; $rad = $this->radiologist_id;
$query = $query->where(function ($query) use ($rad) { $query = $query->where(function ($query) use ($rad) {
$query->orWhere('assigned_physician_id', '=', $rad); $query->Where('assigned_physician_id', '=', $rad);
$query->orWhere('reading_physician_id', '=', $rad); $query->orWhere('reading_physician_id', '=', $rad);
}); });
} }
@ -85,13 +85,17 @@ public function setReportStatus(ReportStatus $status): void
protected static function reportCompleteQuery(Builder $query): Builder protected static function reportCompleteQuery(Builder $query): Builder
{ {
return $query->where('report_status', '=', ReportStatus::Signed->value); return $query->where('report_status', '=', ReportStatus::Authorized->value);
} }
protected function applySort(Builder $query): Builder protected function applySort(Builder $query): Builder
{ {
if ($this->sortColumn) { if (! empty($this->sortColumns)) {
return $query->orderBy($this->sortColumn, $this->sortDir ?? 'ASC'); foreach ($this->sortColumns as $column => $dir) {
$query = $query->orderBy($column, $dir);
}
return $query;
} }
return $query return $query
@ -126,25 +130,32 @@ public function setLocked(bool $locked): void
$this->locked = $locked; $this->locked = $locked;
} }
public function setPageSize(int $size): void public function setPerPage(int $size): void
{ {
$this->pageSize = $size; $this->perPage = $size;
} }
public function setSortColumn(string $column, string $dir): void public function setSortOrder(string $order): void
{ {
$this->sortColumn = $column; $this->sortColumns = [];
$this->sortDir = $dir; if (filled($order)) {
$orders = explode(',', $order);
foreach ($orders as $order) {
$column = ltrim($order, '-');
$dir = ($order[0] == '-') ? 'desc' : 'asc';
$this->sortColumns[] = [$column => $dir];
}
}
} }
public function setSearchTerm(string $search): void public function setSearchTerm(string $search): void
{ {
$this->searchTerm = $search; $this->searchTerm = trim(strtolower($search));
} }
private function getPageSize(?int $user_id = null): int private function getPageSize(?int $user_id = null): int
{ {
return $this->pageSize ?? $this->getPageSize($user_id); return $this->perPage ?? $this->getPageSize($user_id);
} }
private function applySearch(Builder $query): Builder private function applySearch(Builder $query): Builder
@ -166,7 +177,7 @@ private function applySearch(Builder $query): Builder
private function applyArchived(Builder $query): Builder private function applyArchived(Builder $query): Builder
{ {
if ($this->archived != null) { if ($this->archived != null) {
$query = $query->where('archived', $this->archived); $query = $query->where('is_archived', $this->archived);
} }
return $query; return $query;
@ -175,7 +186,7 @@ private function applyArchived(Builder $query): Builder
private function applyLocked(Builder $query): Builder private function applyLocked(Builder $query): Builder
{ {
if ($this->locked != null) { if ($this->locked != null) {
$query = $query->where('locked', $this->locked); $query = $query->where('is_locked', $this->locked);
} }
return $query; return $query;

View File

@ -5,8 +5,8 @@
enum ReportStatus: int enum ReportStatus: int
{ {
case Pending = 0; case Pending = 0;
case Opened = 1; case Opened = 10;
case Draft = 2; case Draft = 20;
case Finalized = 3; case Finalized = 30;
case Signed = 4; case Authorized = 90;
} }

View File

@ -2,9 +2,6 @@
use App\Models\Enums\ReportStatus; use App\Models\Enums\ReportStatus;
use App\Models\Enums\StudyLevelStatus; use App\Models\Enums\StudyLevelStatus;
use App\Models\Facility;
use App\Models\Institute;
use App\Models\User;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@ -17,8 +14,8 @@ public function up(): void
$table->id(); $table->id();
$table->string('orthanc_uuid')->unique(); $table->string('orthanc_uuid')->unique();
$table->boolean('is_archived')->default(false); $table->boolean('is_archived')->default(false);
$table->boolean('is_locked')->default(false);
$table->unsignedTinyInteger('study_priority')->default(0); $table->unsignedTinyInteger('study_priority')->default(0);
$table->string('patient_id')->nullable(); $table->string('patient_id')->nullable();
$table->string('patient_uuid')->nullable()->index(); $table->string('patient_uuid')->nullable()->index();
$table->string('patient_name'); $table->string('patient_name');
@ -37,12 +34,11 @@ public function up(): void
$table->timestamp('study_date'); $table->timestamp('study_date');
$table->timestamp('received_at'); $table->timestamp('received_at');
$table->timestamp('assigned_at')->nullable(); $table->timestamp('assigned_at')->nullable();
$table->timestamp('locked_at')->nullable();
$table->timestamp('reported_at')->nullable(); $table->timestamp('reported_at')->nullable();
$table->timestamp('authorized_at')->nullable(); $table->timestamp('authorized_at')->nullable();
$table->timestamp('archived_at')->nullable(); $table->timestamp('archived_at')->nullable();
$table->foreignIdFor(Institute::class)->constrained()->cascadeOnDelete();
$table->foreignIdFor(Facility::class)->nullable()->constrained()->cascadeOnDelete();
$table->unsignedTinyInteger('study_status')->default(StudyLevelStatus::Pending->value); $table->unsignedTinyInteger('study_status')->default(StudyLevelStatus::Pending->value);
$table->unsignedTinyInteger('report_status')->default(ReportStatus::Pending->value); $table->unsignedTinyInteger('report_status')->default(ReportStatus::Pending->value);
@ -50,9 +46,14 @@ public function up(): void
$table->unsignedSmallInteger('series_count')->nullable(); $table->unsignedSmallInteger('series_count')->nullable();
$table->unsignedInteger('disk_size')->nullable(); $table->unsignedInteger('disk_size')->nullable();
$table->foreignIdFor(User::class, 'assigned_physician_id')->nullable()->constrained()->nullOnDelete(); $table->unsignedBigInteger('assigned_physician_id')->nullable();
$table->foreignIdFor(User::class, 'reading_physician_id')->nullable()->constrained()->nullOnDelete(); $table->unsignedBigInteger('locking_physician_id')->nullable();
$table->foreignIdFor(User::class, 'referring_provider_id')->nullable()->constrained()->nullOnDelete(); $table->unsignedBigInteger('reporting_physician_id')->nullable();
$table->unsignedBigInteger('authorizing_physician_id')->nullable();
$table->unsignedBigInteger('referring_doctor_id')->nullable();
$table->unsignedBigInteger('institute_id');
$table->unsignedBigInteger('facility_id')->nullable();
$table->timestamps(); $table->timestamps();
}); });