From de0dd230b001a24481d59445f854111c3d05cb45 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Fri, 10 Jan 2025 15:52:28 +0600 Subject: [PATCH] migrated - orthanc_host to dicom_server --- app/DAL/Studies/WorklistBase.php | 2 +- .../Controllers/System/SyncOrthancController.php | 4 ++-- app/Models/{OrthancHost.php => DicomServer.php} | 2 +- app/Models/Study.php | 14 +++++++------- app/Services/Pacs/OrthancRestClient.php | 4 ++-- app/Services/Pacs/PacsUrlGen.php | 12 ++++++------ app/Services/Pacs/Sync/StudiesSync.php | 12 ++++++------ ...00_01_31_074312_create_dicom_servers_table.php} | 4 ++-- .../2024_12_27_060234_create_studies_table.php | 4 ++-- database/seeders/InstituteSeeder.php | 6 +++--- 10 files changed, 32 insertions(+), 32 deletions(-) rename app/Models/{OrthancHost.php => DicomServer.php} (95%) rename database/migrations/{0000_01_31_074312_create_orthanc_hosts_table.php => 0000_01_31_074312_create_dicom_servers_table.php} (90%) diff --git a/app/DAL/Studies/WorklistBase.php b/app/DAL/Studies/WorklistBase.php index 27b6524..5ffb9a7 100644 --- a/app/DAL/Studies/WorklistBase.php +++ b/app/DAL/Studies/WorklistBase.php @@ -164,7 +164,7 @@ protected function getStudiesQuery(): Builder $q = Study::query(); } - return $q->with(['readingPhysician', 'assignedPhysician', 'orthancHost']); + return $q->with(['readingPhysician', 'assignedPhysician', 'dicomServer']); } protected function applySort(Builder $query): Builder diff --git a/app/Http/Controllers/System/SyncOrthancController.php b/app/Http/Controllers/System/SyncOrthancController.php index 4cf4caa..01ff1e8 100644 --- a/app/Http/Controllers/System/SyncOrthancController.php +++ b/app/Http/Controllers/System/SyncOrthancController.php @@ -3,14 +3,14 @@ namespace App\Http\Controllers\System; use App\Http\Controllers\Controller; -use App\Models\OrthancHost; +use App\Models\DicomServer; use App\Services\Pacs\Sync\StudiesSync; class SyncOrthancController extends Controller { public function __invoke() { - foreach (OrthancHost::active()->get() as $host) { + foreach (DicomServer::active()->get() as $host) { (new StudiesSync($host))->execute(); } diff --git a/app/Models/OrthancHost.php b/app/Models/DicomServer.php similarity index 95% rename from app/Models/OrthancHost.php rename to app/Models/DicomServer.php index 6266b30..d897138 100644 --- a/app/Models/OrthancHost.php +++ b/app/Models/DicomServer.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Uri; -class OrthancHost extends BaseModel +class DicomServer extends BaseModel { use Active; diff --git a/app/Models/Study.php b/app/Models/Study.php index e8b9b0c..06df51b 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -118,9 +118,9 @@ public function assignedPhysician(): BelongsTo return $this->belongsTo(User::class, 'assigned_physician_id'); } - public function orthancHost(): BelongsTo + public function dicomServer(): BelongsTo { - return $this->belongsTo(OrthancHost::class); + return $this->belongsTo(DicomServer::class); } public function isAssigned(int $rad_id): bool @@ -163,7 +163,7 @@ public function getReportStatusLedAttribute(): string public function getArchiveLink(): ?string { if (me()->may(Permission::StudyDownload)) { - return PacsUrlGen::archive($this->orthancHost, $this); + return PacsUrlGen::archive($this->dicomServer, $this); } return null; @@ -172,7 +172,7 @@ public function getArchiveLink(): ?string public function getStoneLink(): ?string { if (me()->may(Permission::StudyDownload)) { - return PacsUrlGen::stoneViewer($this->orthancHost, $this); + return PacsUrlGen::stoneViewer($this->dicomServer, $this); } return null; @@ -181,7 +181,7 @@ public function getStoneLink(): ?string public function getOhifLink(): ?string { if (me()->may(Permission::StudyDownload)) { - return PacsUrlGen::ohifViewer($this->orthancHost, $this); + return PacsUrlGen::ohifViewer($this->dicomServer, $this); } return null; @@ -190,7 +190,7 @@ public function getOhifLink(): ?string public function getOhifSegmentationLink(): ?string { if (me()->may(Permission::StudyDownload)) { - return PacsUrlGen::ohifSegmentation($this->orthancHost, $this); + return PacsUrlGen::ohifSegmentation($this->dicomServer, $this); } return null; @@ -199,7 +199,7 @@ public function getOhifSegmentationLink(): ?string public function getOhifMprLink(): ?string { if (me()->may(Permission::StudyDownload)) { - return PacsUrlGen::ohifViewerMpr($this->orthancHost, $this); + return PacsUrlGen::ohifViewerMpr($this->dicomServer, $this); } return null; diff --git a/app/Services/Pacs/OrthancRestClient.php b/app/Services/Pacs/OrthancRestClient.php index a89419b..01bc272 100644 --- a/app/Services/Pacs/OrthancRestClient.php +++ b/app/Services/Pacs/OrthancRestClient.php @@ -2,12 +2,12 @@ namespace App\Services\Pacs; -use App\Models\OrthancHost; +use App\Models\DicomServer; use GuzzleHttp\Client; final class OrthancRestClient { - public function __construct(private readonly OrthancHost $orthancHost) {} + public function __construct(private readonly DicomServer $orthancHost) {} public function getClient(): Client { diff --git a/app/Services/Pacs/PacsUrlGen.php b/app/Services/Pacs/PacsUrlGen.php index 52f2f85..b07fa54 100644 --- a/app/Services/Pacs/PacsUrlGen.php +++ b/app/Services/Pacs/PacsUrlGen.php @@ -2,20 +2,20 @@ namespace App\Services\Pacs; -use App\Models\OrthancHost; +use App\Models\DicomServer; use App\Models\Study; use Uri; final class PacsUrlGen { - public static function stoneViewer(OrthancHost $host, Study $study): string + public static function stoneViewer(DicomServer $host, Study $study): string { $url = $host->stoneViewerUrl()->withQuery(['study' => $study->study_instance_uid]); return (string) $url; } - public static function ohifViewer(OrthancHost $host, Study $study): string + public static function ohifViewer(DicomServer $host, Study $study): string { $url = $host->ohifViewerUrl() ->withQuery(['StudyInstanceUIDs' => $study->study_instance_uid]); @@ -23,7 +23,7 @@ public static function ohifViewer(OrthancHost $host, Study $study): string return (string) $url; } - public static function ohifViewerMpr(OrthancHost $host, Study $study): string + public static function ohifViewerMpr(DicomServer $host, Study $study): string { $url = $host->ohifViewerUrl() ->withQuery([ @@ -34,7 +34,7 @@ public static function ohifViewerMpr(OrthancHost $host, Study $study): string return (string) $url; } - public static function ohifSegmentation(OrthancHost $host, Study $study): string + public static function ohifSegmentation(DicomServer $host, Study $study): string { $url = $host->ohifViewerUrl() ->withPath('/ohif/segmentation') @@ -43,7 +43,7 @@ public static function ohifSegmentation(OrthancHost $host, Study $study): string return (string) $url; } - public static function archive(OrthancHost $host, Study $study): string + public static function archive(DicomServer $host, Study $study): string { $url = Uri::of($host->rest_api_endpoint) ->withPath('/studies/' . $study->study_instance_uid . '/archive'); diff --git a/app/Services/Pacs/Sync/StudiesSync.php b/app/Services/Pacs/Sync/StudiesSync.php index 1cbea05..bf0cc2a 100644 --- a/app/Services/Pacs/Sync/StudiesSync.php +++ b/app/Services/Pacs/Sync/StudiesSync.php @@ -4,7 +4,7 @@ use App\Domain\Study\Priority; use App\Domain\Study\StudyLevelStatus; -use App\Models\OrthancHost; +use App\Models\DicomServer; use App\Services\Pacs\DicomUtils; use App\Services\Pacs\InstituteMapper; use App\Services\Pacs\OrthancRestClient; @@ -26,16 +26,16 @@ class StudiesSync private OrthancRestClient $client; - public function __construct(private readonly OrthancHost $orthancHost, ?OrthancRestClient $client = null) + public function __construct(private readonly DicomServer $dicomServer, ?OrthancRestClient $client = null) { $this->study_ids = collect(); - $this->client = $client ?? new OrthancRestClient($orthancHost); + $this->client = $client ?? new OrthancRestClient($dicomServer); $this->resetQueues(); } - public function getOrthancHost(): OrthancHost + public function getDicomServer(): DicomServer { - return $this->orthancHost; + return $this->dicomServer; } public function execute(): void @@ -113,7 +113,7 @@ public function transformData(mixed $orthanc_src): array $patient_name = data_get($orthanc_src, 'PatientMainDicomTags.PatientName'); $study = [ - 'orthanc_host_id' => $this->orthancHost->id, + 'dicom_server_id' => $this->dicomServer->id, 'orthanc_uuid' => strtolower($orthanc_src['ID']), 'institution_name' => $inst_name, 'institute_id' => $inst_id, diff --git a/database/migrations/0000_01_31_074312_create_orthanc_hosts_table.php b/database/migrations/0000_01_31_074312_create_dicom_servers_table.php similarity index 90% rename from database/migrations/0000_01_31_074312_create_orthanc_hosts_table.php rename to database/migrations/0000_01_31_074312_create_dicom_servers_table.php index c617c07..21d8fcc 100644 --- a/database/migrations/0000_01_31_074312_create_orthanc_hosts_table.php +++ b/database/migrations/0000_01_31_074312_create_dicom_servers_table.php @@ -10,7 +10,7 @@ { public function up(): void { - Schema::create('orthanc_hosts', static function (Blueprint $table) { + Schema::create('dicom_servers', static function (Blueprint $table) { $table->id(); $table->boolean('is_active')->index(); $table->string('server_name')->unique(); @@ -31,6 +31,6 @@ public function up(): void public function down(): void { - Schema::dropIfExists('orthanc_hosts'); + Schema::dropIfExists('dicom_servers'); } }; 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 712fbf4..aaf4ddd 100644 --- a/database/migrations/2024_12_27_060234_create_studies_table.php +++ b/database/migrations/2024_12_27_060234_create_studies_table.php @@ -3,7 +3,7 @@ use App\Domain\Report\ReportStatus; use App\Domain\Study\Priority; use App\Domain\Study\StudyLevelStatus; -use App\Models\OrthancHost; +use App\Models\DicomServer; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -14,7 +14,7 @@ public function up(): void { Schema::create('studies', function (Blueprint $table) { $table->id(); - $table->foreignIdFor(OrthancHost::class)->index(); + $table->foreignIdFor(DicomServer::class)->index(); $table->string('orthanc_uuid')->index(); $table->unsignedTinyInteger('priority')->default(Priority::Routine); diff --git a/database/seeders/InstituteSeeder.php b/database/seeders/InstituteSeeder.php index 0ed6a04..786210d 100644 --- a/database/seeders/InstituteSeeder.php +++ b/database/seeders/InstituteSeeder.php @@ -3,9 +3,9 @@ namespace Database\Seeders; use App\Domain\Rule\NameMatchModes; +use App\Models\DicomServer; use App\Models\Facility; use App\Models\Institute; -use App\Models\OrthancHost; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; @@ -56,7 +56,7 @@ public function run(): void 'match_mode' => NameMatchModes::StartsWith->value, ]); - OrthancHost::create( + DicomServer::create( [ 'is_active' => true, 'server_name' => 'Orthanc Main', @@ -68,7 +68,7 @@ public function run(): void 'ohif_viewer_path' => 'ohif/viewer', ] ); - OrthancHost::create( + DicomServer::create( [ 'is_active' => false, 'server_name' => 'Orthanc XR',