diff --git a/app/Models/OrthancHost.php b/app/Models/OrthancHost.php index fa76b66..6266b30 100644 --- a/app/Models/OrthancHost.php +++ b/app/Models/OrthancHost.php @@ -20,11 +20,6 @@ public function facility(): BelongsTo return $this->belongsTo(Facility::class); } - private function restEndpoint(string $path): Uri - { - return Uri::of($this->rest_api_endpoint)->withPath($path); - } - public function stoneViewerUrl(): Uri { return $this->restEndpoint($this->stone_viewer_path); @@ -34,4 +29,9 @@ public function ohifViewerUrl(): Uri { return $this->restEndpoint($this->ohif_viewer_path); } + + private function restEndpoint(string $path): Uri + { + return Uri::of($this->rest_api_endpoint)->withPath($path); + } } diff --git a/app/Models/Study.php b/app/Models/Study.php index b66ed58..b31847e 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -9,6 +9,7 @@ use App\Models\Traits\HashableId; use App\Services\Pacs\PacsUrlGen; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Concerns\HasTimestamps; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -47,19 +48,19 @@ public function shares(): HasMany return $this->hasMany(SharedStudy::class); } - public function scopeActive($query) + public function scopeActive(Builder $query): Builder { - return $query->where('is_archived', false); + return $query->whereNull('archived_at'); } - public function scopeArchived($query) + public function scopeArchived(Builder $query): Builder { - return $query->where('is_archived', true); + return $query->whereNotNull('archived_at'); } - public function scopeUnlocked($query) + public function scopeUnlocked(Builder $query): Builder { - return $query->where('is_locked', false); + return $query->whereNotNull('locked_at'); } public function getHistoryLink(): string @@ -129,7 +130,12 @@ public function isAssigned(int $rad_id): bool public function isActive(): bool { - return $this->is_archived === false; + return $this->archived_at === null; + } + + public function isArchived(): bool + { + return $this->archived_at !== null; } public function getReportStatusLedAttribute(): string diff --git a/app/Services/Pacs/Sync/Pipes/FilterStudies.php b/app/Services/Pacs/Sync/Pipes/FilterStudies.php index f631b93..33f3330 100644 --- a/app/Services/Pacs/Sync/Pipes/FilterStudies.php +++ b/app/Services/Pacs/Sync/Pipes/FilterStudies.php @@ -15,7 +15,7 @@ public function __invoke(StudiesSync $sync, Closure $next): StudiesSync $sync->resetQueues(); $studies = DB::table('studies') - ->where('is_archived', false) + ->whereNull('archived_at') ->get(['orthanc_uuid', 'study_status']) ->pluck('study_status', 'orthanc_uuid'); diff --git a/database/migrations/2024_12_27_060234_create_studies_table.php b/database/migrations/2024_12_27_060234_create_studies_table.php index 320ca58..712fbf4 100644 --- a/database/migrations/2024_12_27_060234_create_studies_table.php +++ b/database/migrations/2024_12_27_060234_create_studies_table.php @@ -16,7 +16,6 @@ public function up(): void $table->id(); $table->foreignIdFor(OrthancHost::class)->index(); $table->string('orthanc_uuid')->index(); - $table->boolean('is_archived')->default(false); $table->unsignedTinyInteger('priority')->default(Priority::Routine); $table->string('patient_uuid')->nullable()->index();