massive reorganization Institute, Facility => Organization, Department
This commit is contained in:
parent
a75833f77a
commit
03bd94eb37
@ -9,12 +9,12 @@ final class TechnicianWorklist extends WorklistBase
|
||||
protected function buildQuery(?int $user_id = null): Builder
|
||||
{
|
||||
$query = $this->getStudiesQuery();
|
||||
$facility_id = auth()->user()->facility_id;
|
||||
if ($facility_id) {
|
||||
$query = $query->where('facility_id', $facility_id);
|
||||
$department_id = auth()->user()->department_id;
|
||||
if ($department_id) {
|
||||
$query = $query->where('department_id', $department_id);
|
||||
} else {
|
||||
$institute_id = auth()->user()->institute_id;
|
||||
$query = $query->where('institute_id', $institute_id);
|
||||
$organization_id = auth()->user()->organization_id;
|
||||
$query = $query->where('organization_id', $organization_id);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\FacilityResource\Pages;
|
||||
use App\Models\Facility;
|
||||
use App\Models\Department;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
class FacilityResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Facility::class;
|
||||
protected static ?string $model = Department::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\InstituteResource\Pages;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Organization;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
class InstituteResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Institute::class;
|
||||
protected static ?string $model = Organization::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Institute;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/** @mixin Institute */
|
||||
/** @mixin Organization */
|
||||
class InstituteResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
|
@ -6,13 +6,13 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Facility extends Model
|
||||
class Department extends Model
|
||||
{
|
||||
use Active;
|
||||
|
||||
public function institute(): BelongsTo
|
||||
public function organization(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Institute::class);
|
||||
return $this->belongsTo(Organization::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
@ -17,14 +17,14 @@ public function conditions(): HasMany
|
||||
return $this->hasMany(DicomRuleCondition::class);
|
||||
}
|
||||
|
||||
public function institute(): BelongsTo
|
||||
public function organization(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Institute::class);
|
||||
return $this->belongsTo(Organization::class);
|
||||
}
|
||||
|
||||
public function facility(): BelongsTo
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Facility::class);
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function panel(): HasOne
|
||||
@ -34,7 +34,7 @@ public function panel(): HasOne
|
||||
|
||||
public function radiologist(): HasOne
|
||||
{
|
||||
return $this->hasOne(User::class, 'radiologist_id');
|
||||
return $this->hasOne(User::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
|
@ -12,12 +12,12 @@ class DicomServer extends BaseModel
|
||||
|
||||
public function institute(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Institute::class);
|
||||
return $this->belongsTo(Organization::class);
|
||||
}
|
||||
|
||||
public function facility(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Facility::class);
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function stoneViewerUrl(): Uri
|
||||
|
@ -2,9 +2,4 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Modality extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
class Modality extends BaseModel {}
|
||||
|
@ -6,14 +6,14 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Institute extends BaseModel
|
||||
class Organization extends BaseModel
|
||||
{
|
||||
use Active;
|
||||
use HasFactory;
|
||||
|
||||
public function facilities(): HasMany
|
||||
public function departments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Facility::class);
|
||||
return $this->hasMany(Department::class);
|
||||
}
|
||||
|
||||
protected function casts(): array
|
@ -2,10 +2,4 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Procedure extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
}
|
||||
class Procedure extends BaseModel {}
|
||||
|
@ -161,12 +161,12 @@ public function radiologistProfile(): HasOne
|
||||
|
||||
public function institute(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Institute::class);
|
||||
return $this->belongsTo(Organization::class);
|
||||
}
|
||||
|
||||
public function facility(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Facility::class);
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
|
@ -8,7 +8,7 @@
|
||||
use App\Models\AssignmentPanel;
|
||||
use App\Models\DicomRoutingRule;
|
||||
use App\Models\DicomRuleCondition;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
@ -80,7 +80,7 @@ private static function initialize(): void
|
||||
}
|
||||
|
||||
if (self::$catchAll < 0) {
|
||||
self::$catchAll = Institute::where('name', 'CATCH-ALL')
|
||||
self::$catchAll = Organization::where('name', 'CATCH-ALL')
|
||||
->first('id')
|
||||
->id;
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Institute;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class InstituteFactory extends Factory
|
||||
{
|
||||
protected $model = Institute::class;
|
||||
protected $model = Organization::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Facility;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Department;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -24,8 +24,8 @@ public function up(): void
|
||||
$table->string('stone_viewer_path')->nullable();
|
||||
$table->string('ohif_viewer_path')->nullable();
|
||||
$table->string('meddream_viewer_path')->nullable();
|
||||
$table->foreignIdFor(Institute::class)->nullable()->index();
|
||||
$table->foreignIdFor(Facility::class)->nullable()->index();
|
||||
$table->foreignIdFor(Organization::class)->nullable()->index();
|
||||
$table->foreignIdFor(Department::class)->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Facility;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Department;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -13,20 +13,22 @@ public function up(): void
|
||||
Schema::create('users', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('guid', 40)->unique()->index()->default(DB::raw("concat('USR-', gen_random_uuid())"));
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->boolean('is_active')->default(true)->index();
|
||||
$table->string('prefix')->nullable();
|
||||
$table->string('first_name');
|
||||
$table->string('last_name')->nullable();
|
||||
$table->string('display_name');
|
||||
$table->string('username')->unique();
|
||||
$table->string('password');
|
||||
$table->string('phone')->nullable()->index();
|
||||
$table->string('email')->nullable()->index();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->foreignId('current_team_id')->nullable();
|
||||
$table->string('profile_photo_path')->nullable();
|
||||
$table->foreignIdFor(Institute::class)->nullable()->index();
|
||||
$table->foreignIdFor(Facility::class)->nullable()->index();
|
||||
$table->string('signature_image_path')->nullable();
|
||||
$table->text('signature_text')->nullable();
|
||||
$table->foreignIdFor(Organization::class)->nullable()->index();
|
||||
$table->foreignIdFor(Department::class)->nullable()->index();
|
||||
$table->string('timezone')->default('Asia/Dhaka');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
|
@ -3,6 +3,9 @@
|
||||
use App\Domain\Report\ReportStatus;
|
||||
use App\Domain\Study\Priority;
|
||||
use App\Domain\Study\StudyLevelStatus;
|
||||
use App\Models\Department;
|
||||
use App\Models\DicomServer;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -13,11 +16,11 @@ public function up(): void
|
||||
{
|
||||
Schema::create('studies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('dicom_server_id')->index();
|
||||
$table->unsignedBigInteger('institute_id')->index();
|
||||
$table->unsignedBigInteger('facility_id')->nullable();
|
||||
$table->foreignIdFor(DicomServer::class)->index();
|
||||
$table->foreignIdFor(Organization::class)->index();
|
||||
$table->foreignIdFor(Department::class)->nullable()->index();
|
||||
|
||||
$table->unsignedTinyInteger('priority')->default(Priority::Routine);
|
||||
$table->unsignedTinyInteger('priority')->default(Priority::Routine->value);
|
||||
$table->unsignedTinyInteger('study_status')->default(StudyLevelStatus::Pending->value);
|
||||
$table->unsignedTinyInteger('report_status')->default(ReportStatus::Unread->value);
|
||||
|
||||
@ -59,6 +62,16 @@ public function up(): void
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['dicom_server_id', 'orthanc_uuid']);
|
||||
|
||||
$table->index(['organization_id', 'priority', 'study_date']);
|
||||
$table->index(['organization_id', 'received_at']);
|
||||
$table->index(['organization_id', 'assigned_at']);
|
||||
$table->index(['organization_id', 'locked_at']);
|
||||
|
||||
$table->index(['department_id', 'priority', 'study_date']);
|
||||
$table->index(['department_id', 'received_at']);
|
||||
$table->index(['department_id', 'assigned_at']);
|
||||
$table->index(['department_id', 'locked_at']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Report\ReportStatus;
|
||||
use App\Models\Facility;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Department;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Study;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
@ -18,8 +18,8 @@ public function up(): void
|
||||
$table->unsignedTinyInteger('report_status')->default(ReportStatus::Unread->value);
|
||||
$table->string('accession_number', 64)->unique()->index()->default(DB::raw("concat('REP-', gen_random_uuid())"));
|
||||
|
||||
$table->foreignIdFor(Institute::class)->index()->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(Facility::class)->index()->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(Organization::class)->index()->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(Department::class)->index()->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(Study::class)->index()->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(User::class, 'read_by_id')->index()->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(User::class, 'dictated_by_id')->index()->nullable()->constrained()->nullOnDelete();
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
use App\Domain\Rule\MatchCondition;
|
||||
use App\Models\AssignmentPanel;
|
||||
use App\Models\Facility;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Department;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@ -16,9 +16,9 @@ public function up(): void
|
||||
Schema::create('dicom_routing_rules', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->foreignIdFor(Institute::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(Facility::class)->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(User::class, 'radiologist_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(Organization::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(Department::class)->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(User::class)->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(AssignmentPanel::class)->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('description')->nullable();
|
||||
$table->string('match_condition')->default(MatchCondition::ANY->value);
|
||||
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('radiologist_profiles', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(User::class)->unique()->constrained()->cascadeOnDelete();
|
||||
$table->string('signature_image_path')->nullable();
|
||||
$table->text('signature_text')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('radiologist_profiles');
|
||||
}
|
||||
};
|
@ -3,9 +3,9 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domain\Rule\MatchMode;
|
||||
use App\Models\Department;
|
||||
use App\Models\DicomServer;
|
||||
use App\Models\Facility;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -13,31 +13,31 @@ class InstituteSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
Institute::create([
|
||||
Organization::create([
|
||||
'name' => 'CATCH-ALL',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$chev = Institute::create([
|
||||
$chev = Organization::create([
|
||||
'name' => 'Chevron',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$cmch = Institute::create([
|
||||
$cmch = Organization::create([
|
||||
'name' => 'CMCH',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$dummy = Institute::create([
|
||||
$dummy = Organization::create([
|
||||
'name' => 'Dummy Site',
|
||||
'is_active' => false,
|
||||
]);
|
||||
|
||||
$chev_xr = Facility::create(
|
||||
$chev_xr = Department::create(
|
||||
[
|
||||
'is_active' => true,
|
||||
'name' => 'Chevron XR',
|
||||
'institute_id' => $chev->id,
|
||||
]
|
||||
);
|
||||
$cmch_mr = Facility::create(
|
||||
$cmch_mr = Department::create(
|
||||
[
|
||||
'is_active' => false,
|
||||
'name' => 'CMCH MR',
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domain\ACL\Role;
|
||||
use App\Models\Institute;
|
||||
use App\Models\Organization;
|
||||
use App\Models\RadiologistProfile;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
@ -33,8 +33,8 @@ public function run(): void
|
||||
]);
|
||||
$usr->assignRole(Role::Admin);
|
||||
|
||||
$chevron = Institute::where('name', 'Chevron')->first();
|
||||
$cmch = Institute::where('name', 'CMCH')->first();
|
||||
$chevron = Organization::where('name', 'Chevron')->first();
|
||||
$cmch = Organization::where('name', 'CMCH')->first();
|
||||
|
||||
User::factory(4)
|
||||
->create([
|
||||
|
Loading…
Reference in New Issue
Block a user