compression support

This commit is contained in:
Masroor Ehsan 2025-01-08 18:21:11 +06:00
parent ef82c77e0d
commit 33873729b6
5 changed files with 43 additions and 5 deletions

19
app/Casts/Compressed.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;
class Compressed implements CastsAttributes
{
public function get(Model $model, string $key, mixed $value, array $attributes): mixed
{
return gzinflate($value);
}
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
{
return gzdeflate($value);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Casts\Compressed;
use App\Models\Traits\HashableId; use App\Models\Traits\HashableId;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -40,6 +41,10 @@ protected function casts(): array
'properties' => 'array', 'properties' => 'array',
'series' => 'array', 'series' => 'array',
'assignment_log' => 'array', 'assignment_log' => 'array',
'clinical_history' => Compressed::class,
'surgical_history' => Compressed::class,
'lab_results' => Compressed::class,
'clinical_diagnosis' => Compressed::class,
]; ];
} }
} }

View File

@ -2,10 +2,14 @@
namespace App\Models; namespace App\Models;
use App\Casts\Compressed;
use Illuminate\Database\Eloquent\Concerns\HasTimestamps;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
class StudyReport extends BaseModel class StudyReport extends BaseModel
{ {
use HasTimestamps;
public function study(): BelongsTo public function study(): BelongsTo
{ {
return $this->belongsTo(Study::class); return $this->belongsTo(Study::class);
@ -15,4 +19,14 @@ public function radiologist(): BelongsTo
{ {
return $this->belongsTo(User::class, 'radiologist_id'); return $this->belongsTo(User::class, 'radiologist_id');
} }
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'content' => Compressed::class,
];
}
} }

View File

@ -20,7 +20,6 @@ public function up(): void
$table->foreignIdFor(Institute::class)->index()->nullable()->constrained()->nullOnDelete(); $table->foreignIdFor(Institute::class)->index()->nullable()->constrained()->nullOnDelete();
$table->foreignIdFor(Facility::class)->index()->nullable()->constrained()->nullOnDelete(); $table->foreignIdFor(Facility::class)->index()->nullable()->constrained()->nullOnDelete();
$table->foreignIdFor(Study::class)->index()->constrained()->cascadeOnDelete(); $table->foreignIdFor(Study::class)->index()->constrained()->cascadeOnDelete();
$table->foreignIdFor(User::class, 'radiologist_id')->index()->constrained()->cascadeOnDelete(); $table->foreignIdFor(User::class, 'radiologist_id')->index()->constrained()->cascadeOnDelete();

View File

@ -13,10 +13,11 @@ public function up(): void
$table->foreignId('study_id')->unique()->constrained('studies')->cascadeOnDelete(); $table->foreignId('study_id')->unique()->constrained('studies')->cascadeOnDelete();
$table->string('orthanc_uuid')->unique(); $table->string('orthanc_uuid')->unique();
// $table->foreignId('user_id')->constrained('users'); // $table->foreignId('user_id')->constrained('users');
$table->text('clinical_history')->nullable(); $table->binary('clinical_history')->nullable();
$table->text('surgical_history')->nullable(); $table->binary('surgical_history')->nullable();
$table->text('lab_results')->nullable(); $table->binary('lab_results')->nullable();
$table->text('clinical_diagnosis')->nullable(); $table->binary('clinical_diagnosis')->nullable();
$table->jsonb('dicom_properties')->nullable();
$table->jsonb('properties')->nullable(); $table->jsonb('properties')->nullable();
$table->jsonb('series')->nullable(); $table->jsonb('series')->nullable();
$table->jsonb('assignment_log')->nullable(); $table->jsonb('assignment_log')->nullable();