This commit is contained in:
Masroor Ehsan 2025-01-22 18:46:48 +06:00
parent dd7c59498b
commit 0593602452
6 changed files with 85 additions and 25 deletions

View File

@ -8,5 +8,6 @@ enum MatchMode: string
case Contains = 'CONTAINS';
case StartsWith = 'STARTS_WITH';
case EndsWith = 'ENDS_WITH';
case InArray = 'IN_ARRAY';
case Regex = 'REGEX';
}

View File

@ -8,7 +8,7 @@
{
public function up(): void
{
Schema::create('institutes', static function (Blueprint $table) {
Schema::create('organizations', static function (Blueprint $table) {
$table->id();
$table->string('guid', 40)->unique()->index()->default(DB::raw("concat('INS-', gen_random_uuid())"));
$table->string('name')->unique();
@ -21,6 +21,6 @@ public function up(): void
public function down(): void
{
Schema::dropIfExists('institutes');
Schema::dropIfExists('organizations');
}
};

View File

@ -1,5 +1,6 @@
<?php
use App\Models\Organization;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -8,20 +9,21 @@
{
public function up(): void
{
Schema::create('facilities', static function (Blueprint $table) {
Schema::create('departments', static function (Blueprint $table) {
$table->id();
$table->string('guid', 40)->unique()->index()->default(DB::raw("concat('FAC-', gen_random_uuid())"));
$table->boolean('is_active')->default(false);
$table->foreignId('institute_id')->constrained('institutes')->cascadeOnDelete();
$table->boolean('is_active')->default(false)->index();
$table->foreignIdFor(Organization::class)->constrained()->cascadeOnDelete();
$table->string('name');
$table->timestamps();
$table->unique(['institute_id', 'name']);
$table->unique(['organization_id', 'name']);
$table->index(['organization_id', 'is_active']);
});
}
public function down(): void
{
Schema::dropIfExists('facilities');
Schema::dropIfExists('departments');
}
};

View File

@ -20,7 +20,7 @@ public function up(): void
$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('name')->nullable();
$table->string('match_condition')->default(MatchCondition::ANY->value);
$table->unsignedTinyInteger('priority')->default(0);
$table->timestamps();

View File

@ -1,6 +1,7 @@
<?php
use App\Domain\Rule\MatchMode;
use App\Models\DicomRoutingRule;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -11,7 +12,7 @@ public function up(): void
{
Schema::create('dicom_rule_conditions', function (Blueprint $table) {
$table->id();
$table->foreignId('dicom_routing_rule_id')->constrained()->cascadeOnDelete();
$table->foreignIdFor(DicomRoutingRule::class)->constrained()->cascadeOnDelete();
$table->string('dicom_tag');
$table->string('search_pattern');
$table->boolean('case_sensitive')->default(false);
@ -19,7 +20,7 @@ public function up(): void
$table->unsignedTinyInteger('priority')->default(0);
$table->timestamps();
$table->index(['dicom_mapping_rules_id', 'priority']);
$table->index(['dicom_routing_rule_id', 'priority']);
});
}

View File

@ -2,12 +2,15 @@
namespace Database\Seeders;
use App\Domain\Rule\MatchCondition;
use App\Domain\Rule\MatchMode;
use App\Models\Department;
use App\Models\DicomRoutingRule;
use App\Models\DicomRuleCondition;
use App\Models\DicomServer;
use App\Models\Organization;
use App\Services\StudyRouter\DicomTagIdentifiers;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class InstituteSeeder extends Seeder
{
@ -34,28 +37,81 @@ public function run(): void
[
'is_active' => true,
'name' => 'Chevron XR',
'institute_id' => $chev->id,
'organization_id' => $chev->id,
]
);
$chev_dep_ct_mr = Department::create(
[
'is_active' => true,
'name' => 'Chevron CT/MR',
'organization_id' => $chev->id,
]
);
$cmch_mr = Department::create(
[
'is_active' => false,
'name' => 'CMCH MR',
'institute_id' => $cmch->id,
'organization_id' => $cmch->id,
]
);
DB::table('dicom_mapping_rules')->insert([
'dicom_tag' => 'InstitutionName',
'name' => 'CHEVRON CLINICAL LABORATORY , PANCHLAISH,CTG',
'search_pattern' => $chev->id,
'match_mode' => MatchMode::Exact->value,
$rul_chev_mr = DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron MR',
'organization_id' => $chev->id,
'department_id' => $chev_dep_ct_mr->id,
'match_condition' => MatchCondition::ALL->value,
]
);
$rul_chev_ct = DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron CT',
'organization_id' => $chev->id,
'department_id' => $chev_dep_ct_mr->id,
'match_condition' => MatchCondition::ALL->value,
]
);
$rul_chev_xr = DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron XR',
'organization_id' => $chev->id,
'department_id' => $chev_dep_ct_mr->id,
'match_condition' => MatchCondition::ALL->value,
]
);
DicomRuleCondition::create([
'dicom_tag' => DicomTagIdentifiers::InstitutionName->value,
'search_pattern' => 'chevron',
'dicom_routing_rule_id' => $rul_chev_mr->id,
'match_mode' => MatchMode::Contains->value,
'case_sensitive' => false,
]);
DB::table('dicom_mapping_rules')->insert([
'dicom_tag' => 'InstitutionName',
'search_pattern' => 'CHEVRON CLINICAL',
'institute_id' => $chev->id,
'match_mode' => MatchMode::StartsWith->value,
DicomRuleCondition::create([
'dicom_tag' => DicomTagIdentifiers::Modality->value,
'search_pattern' => 'MR,CT',
'dicom_routing_rule_id' => $rul_chev_mr->id,
'match_mode' => MatchMode::InArray->value,
'case_sensitive' => true,
]);
DicomRuleCondition::create([
'dicom_tag' => DicomTagIdentifiers::InstitutionName->value,
'search_pattern' => 'chevron',
'dicom_routing_rule_id' => $rul_chev_xr->id,
'match_mode' => MatchMode::Contains->value,
'case_sensitive' => false,
]);
DicomRuleCondition::create([
'dicom_tag' => DicomTagIdentifiers::Modality->value,
'search_pattern' => 'CR,DX',
'dicom_routing_rule_id' => $rul_chev_xr->id,
'match_mode' => MatchMode::InArray->value,
'case_sensitive' => true,
]);
DicomServer::create(
@ -82,8 +138,8 @@ public function run(): void
'wado_path' => 'dicom-web',
'stone_viewer_path' => 'stone-webviewer/index.html',
'ohif_viewer_path' => 'ohif/viewer',
'institute_id' => $chev->id,
'facility_id' => $chev_xr->id,
'organization_id' => $chev->id,
'department_id' => $chev_xr->id,
]
);
}