From 3b7c5c3a6f616f93aa7b7f8321e03b4ff4080944 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Wed, 22 Jan 2025 13:07:08 +0600 Subject: [PATCH] wip --- app/Models/DicomRoutingRule.php | 4 ++-- app/Models/DicomRuleCondition.php | 5 +---- app/Services/Pacs/DicomUtils.php | 1 + app/Services/Pacs/Sync/StudiesSync.php | 4 ++-- .../DicomStudyRouter.php} | 17 ++++++++--------- .../DicomTagIdentifiers.php | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) rename app/Services/{Pacs/DicomStudyMapper.php => StudyRouter/DicomStudyRouter.php} (71%) rename app/Services/{Pacs => StudyRouter}/DicomTagIdentifiers.php (98%) diff --git a/app/Models/DicomRoutingRule.php b/app/Models/DicomRoutingRule.php index c96bfb9..5a6e822 100644 --- a/app/Models/DicomRoutingRule.php +++ b/app/Models/DicomRoutingRule.php @@ -3,13 +3,13 @@ namespace App\Models; use App\Domain\Rule\MatchCondition; -use Illuminate\Database\Eloquent\Factories\HasFactory; +use App\Models\Traits\Active; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; class DicomRoutingRule extends BaseModel { - use HasFactory; + use Active; public function conditions(): HasMany { diff --git a/app/Models/DicomRuleCondition.php b/app/Models/DicomRuleCondition.php index 54f365a..b4b9668 100644 --- a/app/Models/DicomRuleCondition.php +++ b/app/Models/DicomRuleCondition.php @@ -3,14 +3,11 @@ namespace App\Models; use App\Domain\Rule\MatchMode; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; class DicomRuleCondition extends BaseModel { - use HasFactory; - - public function routingRule(): BelongsTo + public function rule(): BelongsTo { return $this->belongsTo(DicomRoutingRule::class); } diff --git a/app/Services/Pacs/DicomUtils.php b/app/Services/Pacs/DicomUtils.php index 547d511..411041e 100644 --- a/app/Services/Pacs/DicomUtils.php +++ b/app/Services/Pacs/DicomUtils.php @@ -2,6 +2,7 @@ namespace App\Services\Pacs; +use App\Services\StudyRouter\DicomTagIdentifiers; use Carbon\Carbon; use Illuminate\Support\Str; diff --git a/app/Services/Pacs/Sync/StudiesSync.php b/app/Services/Pacs/Sync/StudiesSync.php index 84ba427..75a6a16 100644 --- a/app/Services/Pacs/Sync/StudiesSync.php +++ b/app/Services/Pacs/Sync/StudiesSync.php @@ -5,9 +5,9 @@ use App\Domain\Study\Priority; use App\Domain\Study\StudyLevelStatus; use App\Models\DicomServer; -use App\Services\Pacs\DicomStudyMapper; use App\Services\Pacs\DicomUtils; use App\Services\Pacs\OrthancRestClient; +use App\Services\StudyRouter\DicomStudyRouter; use Carbon\Carbon; use Exception; use Illuminate\Pipeline\Pipeline; @@ -108,7 +108,7 @@ public function fetchStudyDetails(string $orthanc_uuid): ?array public function transformData(mixed $orthanc_src): array { $inst_name = data_get($orthanc_src, 'MainDicomTags.InstitutionName'); - $inst_id = DicomStudyMapper::map($inst_name); + $inst_id = DicomStudyRouter::map($inst_name); $patient_name = data_get($orthanc_src, 'PatientMainDicomTags.PatientName'); diff --git a/app/Services/Pacs/DicomStudyMapper.php b/app/Services/StudyRouter/DicomStudyRouter.php similarity index 71% rename from app/Services/Pacs/DicomStudyMapper.php rename to app/Services/StudyRouter/DicomStudyRouter.php index 14958cd..2a9f0c4 100644 --- a/app/Services/Pacs/DicomStudyMapper.php +++ b/app/Services/StudyRouter/DicomStudyRouter.php @@ -1,15 +1,17 @@ addMinutes(15), - fn () => DB::table('dicom_routing_rules') - ->orderByDesc('priority') - ->get() - ->toArray() + fn () => DicomRoutingRule::active()->with('conditions')->get() ); self::$catchAll = DB::table('institutes') ->where('name', 'Catch-all') diff --git a/app/Services/Pacs/DicomTagIdentifiers.php b/app/Services/StudyRouter/DicomTagIdentifiers.php similarity index 98% rename from app/Services/Pacs/DicomTagIdentifiers.php rename to app/Services/StudyRouter/DicomTagIdentifiers.php index 8f79b49..11a5c0d 100644 --- a/app/Services/Pacs/DicomTagIdentifiers.php +++ b/app/Services/StudyRouter/DicomTagIdentifiers.php @@ -1,6 +1,6 @@