diff --git a/app/Http/Requests/InstituteRequest.php b/app/Http/Requests/InstituteRequest.php new file mode 100644 index 0000000..1bf2e58 --- /dev/null +++ b/app/Http/Requests/InstituteRequest.php @@ -0,0 +1,21 @@ + ['required'], + 'is_active' => ['boolean'], + ]; + } + + public function authorize(): bool + { + return true; + } +} diff --git a/app/Http/Resources/InstituteResource.php b/app/Http/Resources/InstituteResource.php new file mode 100644 index 0000000..a7c0e3f --- /dev/null +++ b/app/Http/Resources/InstituteResource.php @@ -0,0 +1,22 @@ + $this->id, + 'name' => $this->name, + 'is_active' => $this->is_active, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]; + } +} diff --git a/app/Models/Enums/NameMatchModes.php b/app/Models/Enums/NameMatchModes.php new file mode 100644 index 0000000..4fbe9e1 --- /dev/null +++ b/app/Models/Enums/NameMatchModes.php @@ -0,0 +1,12 @@ + $this->faker->name(), + 'is_active' => $this->faker->boolean(), + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ]; + } +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index ee72725..5ceb9f0 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -42,7 +42,7 @@ public function definition(): array 'remember_token' => Str::random(10), 'profile_photo_path' => null, 'current_team_id' => null, - 'site_id' => null, + 'institute_id' => null, ]; } diff --git a/database/migrations/0000_01_26_171436_create_sites_table.php b/database/migrations/0000_00_00_163912_create_institutes_table.php similarity index 60% rename from database/migrations/0000_01_26_171436_create_sites_table.php rename to database/migrations/0000_00_00_163912_create_institutes_table.php index 15fd44c..1ba250f 100644 --- a/database/migrations/0000_01_26_171436_create_sites_table.php +++ b/database/migrations/0000_00_00_163912_create_institutes_table.php @@ -8,16 +8,16 @@ { public function up(): void { - Schema::create('sites', function (Blueprint $table) { + Schema::create('institutes', function (Blueprint $table) { $table->id(); - $table->string('name'); - $table->boolean('is_active')->default(true); + $table->string('name')->unique(); + $table->boolean('is_active')->default(false); $table->timestamps(); }); } public function down(): void { - Schema::dropIfExists('sites'); + Schema::dropIfExists('institutes'); } }; diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index eefd1f2..88985d1 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -1,7 +1,7 @@ unsignedTinyInteger('role')->default(UserRole::Guest->value); $table->foreignId('current_team_id')->nullable(); $table->string('profile_photo_path')->nullable(); - $table->foreignIdFor(Site::class)->nullable()->index(); + $table->foreignIdFor(Institute::class)->nullable()->index(); $table->timestamps(); }); 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 debdc6e..6aafa16 100644 --- a/database/migrations/2024_12_27_060234_create_studies_table.php +++ b/database/migrations/2024_12_27_060234_create_studies_table.php @@ -1,7 +1,7 @@ id(); $table->string('orthanc_uid')->unique(); $table->boolean('is_active')->default(true); - $table->unsignedTinyInteger('priority')->default(0); + $table->boolean('is_locked')->default(true); + $table->unsignedTinyInteger('study_priority')->default(0); $table->string('patient_id')->nullable(); $table->string('patient_name'); $table->string('patient_sex'); @@ -24,24 +25,28 @@ public function up(): void $table->string('institution_name'); $table->string('accession_number')->nullable(); $table->string('study_description')->nullable(); - $table->dateTime('study_date')->index(); - $table->dateTime('receive_date')->index(); + $table->string('study_modality', 4)->nullable(); + $table->dateTime('study_date'); + $table->dateTime('receive_date'); $table->dateTime('report_date')->nullable(); - $table->foreignIdFor(Site::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(Institute::class)->constrained()->onDelete('cascade'); $table->unsignedTinyInteger('report_status')->default(0); - $table->string('study_modality', 4); + $table->unsignedSmallInteger('image_count')->default(0); + $table->unsignedSmallInteger('series_count')->default(0); + $table->foreignIdFor(User::class, 'assigned_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'interpreting_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'referring_physician_id')->nullable()->constrained()->onDelete('set null'); + $table->foreignIdFor(User::class, 'reading_physician_id')->nullable()->constrained()->onDelete('set null'); + $table->unsignedTinyInteger('access_flags')->default(StudyAccessFlags::None->value); $table->string('access_password')->nullable(); $table->timestamps(); $table->index(['referring_physician_id', 'receive_date']); - $table->index(['site_id', 'receive_date']); - $table->index(['site_id', 'accession_number']); - $table->index(['site_id', 'report_status', 'priority', 'receive_date']); - $table->index(['assigned_physician_id', 'report_status', 'priority', 'receive_date']); + $table->index(['institute_id', 'receive_date']); + $table->index(['institute_id', 'report_status', 'study_priority', 'receive_date']); + $table->index(['assigned_physician_id', 'report_status', 'study_priority', 'receive_date']); }); } diff --git a/database/migrations/2024_12_28_051451_create_study_reports_table.php b/database/migrations/2024_12_28_051451_create_study_reports_table.php index c64500f..aafb925 100644 --- a/database/migrations/2024_12_28_051451_create_study_reports_table.php +++ b/database/migrations/2024_12_28_051451_create_study_reports_table.php @@ -1,5 +1,8 @@ id(); - $table->unsignedTinyInteger('report_status')->default(0); - $table->foreignId('study_id')->constrained('studies'); - $table->foreignId('radiologist_id')->constrained('users'); + $table->unsignedTinyInteger('report_status')->default(ReportStatus::Pending->value); + $table->foreignIdFor(Study::class)->index()->constrained()->onDelete('cascade'); + $table->foreignIdFor(User::class)->index()->constrained()->onDelete('cascade'); $table->string('file_path'); $table->string('pdf_path')->nullable(); $table->timestamps(); - - $table->unique(['study_id', 'created_at']); }); } diff --git a/database/migrations/2024_12_28_175040_create_institute_names_table.php b/database/migrations/2024_12_28_175040_create_institute_names_table.php new file mode 100644 index 0000000..46ac29c --- /dev/null +++ b/database/migrations/2024_12_28_175040_create_institute_names_table.php @@ -0,0 +1,27 @@ +id(); + $table->foreignIdFor(Institute::class)->constrained()->onDelete('CASCADE'); + $table->string('name')->unique(); + $table->unsignedTinyInteger('match_mode')->default(NameMatchModes::Exact->value); + $table->unsignedTinyInteger('priority')->default(0); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('institute_names'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 63e60e0..7143d52 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,7 +13,7 @@ class DatabaseSeeder extends Seeder public function run(): void { $this->call([ - SiteSeeder::class, + InstituteSeeder::class, UserSeeder::class, ]); diff --git a/database/seeders/InstituteSeeder.php b/database/seeders/InstituteSeeder.php new file mode 100644 index 0000000..322945e --- /dev/null +++ b/database/seeders/InstituteSeeder.php @@ -0,0 +1,42 @@ + 'Catch-all', + 'is_active' => true, + ]); + $chev = Institute::create([ + 'name' => 'Chevron', + 'is_active' => true, + ]); + $srini = Institute::create([ + 'name' => 'Srinivasa', + 'is_active' => true, + ]); + Institute::create([ + 'name' => 'Dummy Site', + 'is_active' => false, + ]); + + DB::table('institute_names')->insert([ + 'name' => 'CHEVRON CLINICAL LABORATORY , PANCHLAISH,CTG', + 'institute_id' => $chev->id, + 'match_mode' => NameMatchModes::Exact->value, + ]); + DB::table('institute_names')->insert([ + 'name' => 'CHEVRON CLINICAL', + 'institute_id' => $chev->id, + 'match_mode' => NameMatchModes::StartsWith->value, + ]); + } +} diff --git a/database/seeders/SiteSeeder.php b/database/seeders/SiteSeeder.php deleted file mode 100644 index 8bc9ea7..0000000 --- a/database/seeders/SiteSeeder.php +++ /dev/null @@ -1,25 +0,0 @@ - 'Chevron', - 'is_active' => true, - ]); - Site::create([ - 'name' => 'Srinivasa', - 'is_active' => true, - ]); - Site::create([ - 'name' => 'Dummy Site', - 'is_active' => false, - ]); - } -} diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index c95959e..77a6e9b 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -3,6 +3,7 @@ namespace Database\Seeders; use App\Models\Enums\UserRole; +use App\Models\Institute; use App\Models\User; use Illuminate\Database\Seeder; @@ -19,13 +20,16 @@ public function run(): void 'role' => UserRole::Admin->value, ]); + $chevron = Institute::where('name', 'Chevron')->first(); + $srini = Institute::where('name', 'Srinivasa')->first(); + User::factory(2)->create([ - 'site_id' => 1, + 'institute_id' => $chevron->id, 'role' => UserRole::Technologist->value, ]); User::factory(2)->create([ - 'site_id' => 2, + 'institute_id' => $srini->id, 'role' => UserRole::Technologist->value, ]); }