From 312b6bed6e1fc3707e09bdfbe0613202535e5194 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Sat, 28 Dec 2024 11:22:29 +0600 Subject: [PATCH] wip --- app/Models/Enums/StudyModality.php | 2 +- app/Models/Study.php | 4 +-- app/Models/StudyAttachment.php | 4 +-- app/Models/StudyNote.php | 4 +-- app/Models/StudyReport.php | 19 +++++++++++++ app/Models/User.php | 2 +- ...2024_12_27_060234_create_studies_table.php | 10 ++++--- ..._035932_create_study_attachments_table.php | 6 ++-- ..._12_28_043818_create_study_notes_table.php | 6 +++- ...2_28_051451_create_study_reports_table.php | 28 +++++++++++++++++++ 10 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 app/Models/StudyReport.php create mode 100644 database/migrations/2024_12_28_051451_create_study_reports_table.php diff --git a/app/Models/Enums/StudyModality.php b/app/Models/Enums/StudyModality.php index ec57ad2..dfbea40 100644 --- a/app/Models/Enums/StudyModality.php +++ b/app/Models/Enums/StudyModality.php @@ -2,7 +2,7 @@ namespace App\Models\Enums; -enum StudyModality:string +enum StudyModality: string { case CR = 'CR'; case CT = 'CT'; diff --git a/app/Models/Study.php b/app/Models/Study.php index 38cd85a..3363044 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -4,6 +4,4 @@ use Illuminate\Database\Eloquent\Model; -class Study extends Model -{ -} +class Study extends Model {} diff --git a/app/Models/StudyAttachment.php b/app/Models/StudyAttachment.php index 389afbb..f4df83e 100644 --- a/app/Models/StudyAttachment.php +++ b/app/Models/StudyAttachment.php @@ -4,6 +4,4 @@ use Illuminate\Database\Eloquent\Model; -class StudyAttachment extends Model -{ -} +class StudyAttachment extends Model {} diff --git a/app/Models/StudyNote.php b/app/Models/StudyNote.php index 963d143..1166fad 100644 --- a/app/Models/StudyNote.php +++ b/app/Models/StudyNote.php @@ -4,6 +4,4 @@ use Illuminate\Database\Eloquent\Model; -class StudyNote extends Model -{ -} +class StudyNote extends Model {} diff --git a/app/Models/StudyReport.php b/app/Models/StudyReport.php new file mode 100644 index 0000000..26faa4f --- /dev/null +++ b/app/Models/StudyReport.php @@ -0,0 +1,19 @@ +belongsTo(Study::class); + } + + public function radiologist(): BelongsTo + { + return $this->belongsTo(User::class, 'radiologist_id'); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index ae0127b..b3298a1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -14,11 +14,11 @@ class User extends Authenticatable { use HasApiTokens; + /** @use HasFactory<\Database\Factories\UserFactory> */ use HasFactory; use HasProfilePhoto; - use HasRoles; use Notifiable; use TwoFactorAuthenticatable; 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 71a738a..f34bc60 100644 --- a/database/migrations/2024_12_27_060234_create_studies_table.php +++ b/database/migrations/2024_12_27_060234_create_studies_table.php @@ -6,14 +6,15 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration { +return new class extends Migration +{ public function up(): void { Schema::create('studies', function (Blueprint $table) { $table->id(); $table->string('orthanc_uid')->unique(); $table->boolean('is_active')->default(true); - $table->tinyInteger('priority')->default(0); + $table->unsignedTinyInteger('study_priority')->default(0); $table->string('patient_id')->nullable(); $table->string('patient_name'); $table->string('patient_sex'); @@ -25,9 +26,10 @@ public function up(): void $table->text('history')->nullable(); $table->dateTime('study_date')->index(); $table->dateTime('upload_date')->index(); + $table->dateTime('report_date')->nullable(); $table->foreignIdFor(Site::class)->constrained()->onDelete('cascade'); - $table->tinyInteger('report_status')->default(0); - $table->string('study_modality',4); + $table->unsignedTinyInteger('report_status')->default(0); + $table->string('study_modality', 4); $table->foreignIdFor(User::class, 'assigned_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'interpreting_physician_id')->nullable()->constrained()->onDelete('set null'); $table->timestamps(); diff --git a/database/migrations/2024_12_28_035932_create_study_attachments_table.php b/database/migrations/2024_12_28_035932_create_study_attachments_table.php index 8f8db3d..ad61e11 100644 --- a/database/migrations/2024_12_28_035932_create_study_attachments_table.php +++ b/database/migrations/2024_12_28_035932_create_study_attachments_table.php @@ -6,13 +6,15 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration { +return new class extends Migration +{ public function up(): void { Schema::create('study_attachments', function (Blueprint $table) { $table->id(); $table->string('file_name'); - $table->integer('file_size'); + $table->integer('file_size')->nullable(); + $table->string('file_type')->nullable(); $table->foreignIdFor(Study::class)->constrained()->onDelete('cascade'); $table->foreignIdFor(User::class)->nullable()->constrained()->onDelete('SET NULL'); $table->timestamps(); diff --git a/database/migrations/2024_12_28_043818_create_study_notes_table.php b/database/migrations/2024_12_28_043818_create_study_notes_table.php index 4ee69aa..66207ce 100644 --- a/database/migrations/2024_12_28_043818_create_study_notes_table.php +++ b/database/migrations/2024_12_28_043818_create_study_notes_table.php @@ -6,15 +6,19 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration { +return new class extends Migration +{ public function up(): void { Schema::create('study_notes', function (Blueprint $table) { $table->id(); $table->foreignIdFor(Study::class)->constrained()->onDelete('cascade'); $table->foreignIdFor(User::class)->nullable()->constrained()->onDelete('cascade'); + $table->string('title')->nullable(); $table->text('note'); $table->timestamps(); + + $table->index(['study_id', 'created_at']); }); } 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 new file mode 100644 index 0000000..c64500f --- /dev/null +++ b/database/migrations/2024_12_28_051451_create_study_reports_table.php @@ -0,0 +1,28 @@ +id(); + $table->unsignedTinyInteger('report_status')->default(0); + $table->foreignId('study_id')->constrained('studies'); + $table->foreignId('radiologist_id')->constrained('users'); + $table->string('file_path'); + $table->string('pdf_path')->nullable(); + $table->timestamps(); + + $table->unique(['study_id', 'created_at']); + }); + } + + public function down(): void + { + Schema::dropIfExists('study_reports'); + } +};