diff --git a/app/Casts/Compressed.php b/app/Casts/Compressed.php new file mode 100644 index 0000000..859ef9f --- /dev/null +++ b/app/Casts/Compressed.php @@ -0,0 +1,19 @@ + 'array', 'series' => 'array', 'assignment_log' => 'array', + 'clinical_history' => Compressed::class, + 'surgical_history' => Compressed::class, + 'lab_results' => Compressed::class, + 'clinical_diagnosis' => Compressed::class, ]; } } diff --git a/app/Models/StudyReport.php b/app/Models/StudyReport.php index dfb878e..1d4cf9f 100644 --- a/app/Models/StudyReport.php +++ b/app/Models/StudyReport.php @@ -2,10 +2,14 @@ namespace App\Models; +use App\Casts\Compressed; +use Illuminate\Database\Eloquent\Concerns\HasTimestamps; use Illuminate\Database\Eloquent\Relations\BelongsTo; class StudyReport extends BaseModel { + use HasTimestamps; + public function study(): BelongsTo { return $this->belongsTo(Study::class); @@ -15,4 +19,14 @@ public function radiologist(): BelongsTo { return $this->belongsTo(User::class, 'radiologist_id'); } + + /** + * @return array + */ + protected function casts(): array + { + return [ + 'content' => Compressed::class, + ]; + } } diff --git a/database/migrations/2024_12_28_051451_create_study_reports_table.php b/database/migrations/2024_12_28_051451_create_study_reports_table.php index e37ba62..90ee120 100644 --- a/database/migrations/2024_12_28_051451_create_study_reports_table.php +++ b/database/migrations/2024_12_28_051451_create_study_reports_table.php @@ -20,7 +20,6 @@ public function up(): void $table->foreignIdFor(Institute::class)->index()->nullable()->constrained()->nullOnDelete(); $table->foreignIdFor(Facility::class)->index()->nullable()->constrained()->nullOnDelete(); - $table->foreignIdFor(Study::class)->index()->constrained()->cascadeOnDelete(); $table->foreignIdFor(User::class, 'radiologist_id')->index()->constrained()->cascadeOnDelete(); diff --git a/database/migrations/2024_12_28_144858_create_study_details_table.php b/database/migrations/2024_12_28_144858_create_study_details_table.php index 941a687..690b1aa 100644 --- a/database/migrations/2024_12_28_144858_create_study_details_table.php +++ b/database/migrations/2024_12_28_144858_create_study_details_table.php @@ -13,10 +13,11 @@ public function up(): void $table->foreignId('study_id')->unique()->constrained('studies')->cascadeOnDelete(); $table->string('orthanc_uuid')->unique(); // $table->foreignId('user_id')->constrained('users'); - $table->text('clinical_history')->nullable(); - $table->text('surgical_history')->nullable(); - $table->text('lab_results')->nullable(); - $table->text('clinical_diagnosis')->nullable(); + $table->binary('clinical_history')->nullable(); + $table->binary('surgical_history')->nullable(); + $table->binary('lab_results')->nullable(); + $table->binary('clinical_diagnosis')->nullable(); + $table->jsonb('dicom_properties')->nullable(); $table->jsonb('properties')->nullable(); $table->jsonb('series')->nullable(); $table->jsonb('assignment_log')->nullable();