diff --git a/app/Services/Pacs/DicomUtils.php b/app/Services/Pacs/DicomUtils.php index 89e5f21..3e97a56 100644 --- a/app/Services/Pacs/DicomUtils.php +++ b/app/Services/Pacs/DicomUtils.php @@ -18,7 +18,7 @@ public static function dateToCarbon(?string $datePart, string $timezone = 'UTC') public static function dateTimeToCarbon(?string $datePart, ?string $timePart, string $timezone = 'UTC'): ?Carbon { - if ($datePart === null || $timePart === null) { + if (blank($datePart) || blank($timePart)) { return null; } diff --git a/app/Services/Pacs/InstituteMapper.php b/app/Services/Pacs/InstituteMapper.php index 6bd5793..7fc63df 100644 --- a/app/Services/Pacs/InstituteMapper.php +++ b/app/Services/Pacs/InstituteMapper.php @@ -13,7 +13,7 @@ final class InstituteMapper private static int $catchAll = -1; - public static function map(string $input): int + public static function map(?string $input): int { if (empty(self::$patterns)) { self::$patterns = Cache::remember('institute_names', now()->addDay(), function () { @@ -22,11 +22,13 @@ public static function map(string $input): int self::$catchAll = DB::table('institutes')->first('id')->id; } - $input = strtolower($input); + if (! blank($input)) { + $input = strtolower($input); - foreach (self::$patterns as $pattern) { - if (InputMatcher::match($input, $pattern->name, NameMatchModes::from($pattern->match_mode))) { - return $pattern->institute_id; + foreach (self::$patterns as $pattern) { + if (InputMatcher::match($input, $pattern->name, NameMatchModes::from($pattern->match_mode))) { + return $pattern->institute_id; + } } } diff --git a/app/Services/Pacs/Sync/StudiesSync.php b/app/Services/Pacs/Sync/StudiesSync.php index 7fbd6cd..858e474 100644 --- a/app/Services/Pacs/Sync/StudiesSync.php +++ b/app/Services/Pacs/Sync/StudiesSync.php @@ -119,7 +119,7 @@ public function transformData(mixed $orthanc_src): array 'study_modality' => data_get($orthanc_src, 'RequestedTags.Modality'), 'body_part_examined' => data_get($orthanc_src, 'RequestedTags.BodyPartExamined'), - 'study_date' => DicomUtils::dateTimeToCarbon($orthanc_src['MainDicomTags']['StudyDate'], $orthanc_src['MainDicomTags']['StudyTime']), + 'study_date' => DicomUtils::dateTimeToCarbon($orthanc_src['MainDicomTags']['StudyDate'], $orthanc_src['MainDicomTags']['StudyTime']) ?? now('UTC'), 'received_at' => Carbon::parse($orthanc_src['LastUpdate'], 'UTC'), 'image_count' => data_get($orthanc_src, 'Statistics.CountInstances'), 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 f94b9a4..fa27882 100644 --- a/database/migrations/2024_12_27_060234_create_studies_table.php +++ b/database/migrations/2024_12_27_060234_create_studies_table.php @@ -34,12 +34,12 @@ public function up(): void $table->string('referring_physician_name')->nullable(); $table->string('study_modality', 4)->nullable(); - $table->dateTime('study_date'); - - $table->dateTime('received_at'); - $table->dateTime('assigned_at')->nullable(); - $table->dateTime('reported_at')->nullable(); - $table->dateTime('authorized_at')->nullable(); + $table->timestamp('study_date'); + $table->timestamp('received_at'); + $table->timestamp('assigned_at')->nullable(); + $table->timestamp('reported_at')->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->timestamp('archived_at')->nullable(); $table->foreignIdFor(Institute::class)->constrained()->cascadeOnDelete(); $table->foreignIdFor(Facility::class)->nullable()->constrained()->cascadeOnDelete(); diff --git a/database/migrations/2024_12_30_152300_create_audit_logs_table.php b/database/migrations/2024_12_30_152300_create_audit_logs_table.php index 2a72485..895eb83 100644 --- a/database/migrations/2024_12_30_152300_create_audit_logs_table.php +++ b/database/migrations/2024_12_30_152300_create_audit_logs_table.php @@ -19,8 +19,7 @@ public function up(): void $table->string('orthanc_uuid')->nullable(); $table->text('url')->nullable(); $table->text('notes')->nullable(); - - $table->timestamps(); + $table->timestamp('created_at'); }); } diff --git a/database/migrations/2024_12_31_102417_create_settings_table.php b/database/migrations/2024_12_31_102417_create_settings_table.php index b06322a..ed5da91 100644 --- a/database/migrations/2024_12_31_102417_create_settings_table.php +++ b/database/migrations/2024_12_31_102417_create_settings_table.php @@ -9,7 +9,7 @@ public function up(): void { Schema::create(config('settings.table'), function (Blueprint $table) { - $table->bigIncrements('id'); + $table->id(); $table->string('key')->unique()->index(); $table->longText('value')->nullable(); });