From 3a9b27ef193644291a4d28be69698a8444d6c504 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Sat, 28 Dec 2024 22:35:52 +0600 Subject: [PATCH] study importer --- app/Http/Controllers/PacsController.php | 7 ++++--- app/Services/Pacs/OrthancRestClient.php | 2 +- app/Services/Pacs/StudyImporter.php | 13 ++++--------- .../2024_12_27_060234_create_studies_table.php | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/PacsController.php b/app/Http/Controllers/PacsController.php index 70cefb5..5088171 100644 --- a/app/Http/Controllers/PacsController.php +++ b/app/Http/Controllers/PacsController.php @@ -29,9 +29,10 @@ public function show($id) public function import() { - $studies = (new OrthancRestClient)->getStudies(); - - (new StudyImporter)->import($studies); + $svc = (new StudyImporter); + $svc->scanStudies(); + $svc->filterStudies(); + $svc->importStudies(); return redirect()->route('studies.index'); } diff --git a/app/Services/Pacs/OrthancRestClient.php b/app/Services/Pacs/OrthancRestClient.php index 9330995..84529ef 100644 --- a/app/Services/Pacs/OrthancRestClient.php +++ b/app/Services/Pacs/OrthancRestClient.php @@ -25,7 +25,7 @@ public function getStudyDetails(string $study_id): array $query = [ 'requested-tags' => implode(';', array_column(DicomTags::cases(), 'value')), ]; - $response = $this->getClient()->get('/studies/'.$study_id.http_build_query($query)); + $response = $this->getClient()->get('/studies/'.$study_id.'?'.http_build_query($query)); return json_decode($response->getBody()->getContents(), true); } diff --git a/app/Services/Pacs/StudyImporter.php b/app/Services/Pacs/StudyImporter.php index e5a0a03..f043b83 100644 --- a/app/Services/Pacs/StudyImporter.php +++ b/app/Services/Pacs/StudyImporter.php @@ -22,13 +22,6 @@ public function __construct(?OrthancRestClient $client = null) $this->client = $client ?? new OrthancRestClient; } - public function import(array $studies): void - { - foreach ($studies as $study) { - $this->importStudy($study); - } - } - public function scanStudies() { $this->study_ids = $this->client->getStudiesIds(); @@ -38,8 +31,10 @@ private function checkUpdate(string $orthanc_uid): void { $row = DB::table('studies')->where('orthanc_uid', $orthanc_uid)->first(['id', 'study_status']); - if ($row == null) { + if ($row === null) { $this->insert_queue[] = $orthanc_uid; + + return; } if ($row->study_status < StudyLevelStatus::StudyArrived->value) { @@ -140,7 +135,7 @@ private function prepareData(mixed $study): array if ($descr != null) { $descr = data_get($study, 'RequestedTags.AcquisitionDeviceProcessingDescription'); } - $data['study_description'] = trim($descr); + $data['study_descrip¶tion'] = trim($descr); return $data; } 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 c14d6ba..4c4f3d4 100644 --- a/database/migrations/2024_12_27_060234_create_studies_table.php +++ b/database/migrations/2024_12_27_060234_create_studies_table.php @@ -47,7 +47,7 @@ public function up(): void $table->unsignedSmallInteger('image_count')->nullable(); $table->unsignedSmallInteger('series_count')->nullable(); - $table->unsignedSmallInteger('disk_size')->nullable(); + $table->unsignedInteger('disk_size')->nullable(); $table->foreignIdFor(User::class, 'assigned_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'interpreting_physician_id')->nullable()->constrained()->onDelete('set null');