relations
This commit is contained in:
parent
0697f458ee
commit
ffc583c34d
@ -164,7 +164,15 @@ protected function getStudiesQuery(): Builder
|
||||
$q = Study::query();
|
||||
}
|
||||
|
||||
return $q->with(['readingPhysician', 'dicomServer', 'assignedPhysicians', 'reports', 'lockingPhysician']);
|
||||
return $q->with([
|
||||
'organization',
|
||||
'department',
|
||||
'dicomServer',
|
||||
'readingPhysician',
|
||||
'assignedPhysicians',
|
||||
'lockingPhysician',
|
||||
'reports',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function applySort(Builder $query): Builder
|
||||
|
@ -6,7 +6,9 @@
|
||||
use App\Domain\Report\ReportStatus;
|
||||
use App\Domain\Study\Priority;
|
||||
use App\Domain\Study\StudyLevelStatus;
|
||||
use App\Models\Traits\HasDepartment;
|
||||
use App\Models\Traits\HashableId;
|
||||
use App\Models\Traits\HasOrganization;
|
||||
use App\Services\Pacs\PacsUrlGen;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@ -22,7 +24,9 @@
|
||||
|
||||
class Study extends BaseModel implements HasMedia
|
||||
{
|
||||
use HasDepartment;
|
||||
use HashableId;
|
||||
use HasOrganization;
|
||||
use HasTimestamps;
|
||||
use InteractsWithMedia;
|
||||
|
||||
|
20
app/Models/Traits/HasDepartment.php
Normal file
20
app/Models/Traits/HasDepartment.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use App\Models\Department;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Yajra\DataTables\Html\Editor\Fields\BelongsTo;
|
||||
|
||||
trait HasDepartment
|
||||
{
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function scopeDepartment(Builder $query, int $department_id): Builder
|
||||
{
|
||||
return $query->where('department_id', $department_id);
|
||||
}
|
||||
}
|
20
app/Models/Traits/HasOrganization.php
Normal file
20
app/Models/Traits/HasOrganization.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Yajra\DataTables\Html\Editor\Fields\BelongsTo;
|
||||
|
||||
trait HasOrganization
|
||||
{
|
||||
public function organization(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organization::class);
|
||||
}
|
||||
|
||||
public function scopeOrganization(Builder $query, int $organization_id): Builder
|
||||
{
|
||||
return $query->where('organization_id', $organization_id);
|
||||
}
|
||||
}
|
@ -34,4 +34,6 @@ enum WorklistColumn: string
|
||||
case ActionButtons = 'action_buttons';
|
||||
case ViewerButtons = 'viewer_buttons';
|
||||
case ReportButtons = 'report_buttons';
|
||||
case Organization = 'organization';
|
||||
case Department = 'department';
|
||||
}
|
||||
|
@ -41,6 +41,11 @@ public static function worklistColumns(User|int|null $usr = null): Collection
|
||||
});
|
||||
}
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
$columns->push(WorklistColumn::Organization);
|
||||
$columns->push(WorklistColumn::Department);
|
||||
}
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user