feat: Implement Fast Request feature with file upload and request management
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\DocumentModalityEnum;
|
||||
use App\Enums\DocumentPriorityEnum;
|
||||
use App\Enums\DocumentStatusEnum;
|
||||
use App\Enums\UserEnum;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DocumentSeeder extends Seeder
|
||||
{
|
||||
protected int $documentsPerOwner = 30;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$doctors = User::where('level', UserEnum::Doctor->value)->get();
|
||||
$owners = User::whereIn('level', [UserEnum::Admin->value, UserEnum::Supervisor->value, UserEnum::Vet->value])->get();
|
||||
|
||||
if ($doctors->isEmpty() || $owners->isEmpty()) {
|
||||
$this->call(FastRequestSeeder::class);
|
||||
$doctors = User::where('level', UserEnum::Doctor->value)->get();
|
||||
$owners = User::whereIn('level', [UserEnum::Admin->value, UserEnum::Supervisor->value, UserEnum::Vet->value])->get();
|
||||
}
|
||||
|
||||
$notes = [
|
||||
'لنگش اندام حرکتی جلو از دو روز پیش، درخواست گرافی مفصل شانه و آرنج.',
|
||||
'استفراغ مکرر و بیاشتهایی، احتمال جسم خارجی در دستگاه گوارش. سونوگرافی شکم انجام شود.',
|
||||
'سرفه مزمن و تنگی نفس، درخواست گرافی قفسه سینه در دو نما.',
|
||||
'تشنج ناگهانی بدون سابقه قبلی، بررسی جمجمه از نظر ضایعه فضاگیر.',
|
||||
'سوفل قلبی درجه سه در سمع، درخواست اکوکاردیوگرافی کامل.',
|
||||
'ضعف پیشرونده اندام حرکتی عقب، بررسی ستون فقرات کمری از نظر دیسک.',
|
||||
'تروما به دنبال تصادف با خودرو، بررسی لگن و اندام حرکتی از نظر شکستگی.',
|
||||
'اتساع شکم و درد در لمس، درخواست سونوگرافی اورژانسی جهت رد پیچخوردگی معده.',
|
||||
'توده قابل لمس در ناحیه گردن، بررسی ابعاد و منشا توده با سونوگرافی.',
|
||||
'کج شدن سر و نیستاگموس، بررسی گوش میانی و داخلی با سیتیاسکن.',
|
||||
'پرنوشی و پرادراری از یک هفته پیش، بررسی کلیهها و مثانه.',
|
||||
'خونریزی از بینی و عطسه مکرر، بررسی حفره بینی از نظر جسم خارجی.',
|
||||
'عدم تحمل وزن روی اندام عقب چپ، احتمال پارگی رباط صلیبی. گرافی زانو انجام شود.',
|
||||
'کاهش وزن مزمن با وجود اشتهای طبیعی، سونوگرافی کامل محوطه بطنی.',
|
||||
'دیسترس تنفسی حاد، بررسی پرده جنب از نظر تجمع مایع.',
|
||||
];
|
||||
|
||||
$rejectionReasons = [
|
||||
'کیفیت تصاویر ارسالی برای تفسیر کافی نیست، لطفا مجددا تصویربرداری شود.',
|
||||
'اطلاعات بالینی ناقص است، شرح حال کامل بیمار ثبت شود.',
|
||||
'نمای درخواستی با شکایت بالینی همخوانی ندارد.',
|
||||
];
|
||||
|
||||
$statuses = [
|
||||
DocumentStatusEnum::Registered,
|
||||
DocumentStatusEnum::InProgress,
|
||||
DocumentStatusEnum::Registered,
|
||||
DocumentStatusEnum::InProgress,
|
||||
DocumentStatusEnum::Registered,
|
||||
DocumentStatusEnum::Completed,
|
||||
DocumentStatusEnum::Registered,
|
||||
DocumentStatusEnum::InProgress,
|
||||
DocumentStatusEnum::Rejected,
|
||||
DocumentStatusEnum::Registered,
|
||||
];
|
||||
|
||||
$deadlineMinutes = [-180, 25, 53, 240, 420, null, 700, 1100, 1400, -30, 1900, 2600];
|
||||
$modalities = DocumentModalityEnum::cases();
|
||||
|
||||
foreach ($owners as $owner) {
|
||||
$pets = $owner->pets;
|
||||
if ($pets->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$missing = $this->documentsPerOwner - Document::where('requester_id', $owner->id)->count();
|
||||
|
||||
for ($i = 0; $i < $missing; $i++) {
|
||||
$status = $statuses[$i % count($statuses)];
|
||||
$deadline = $deadlineMinutes[$i % count($deadlineMinutes)];
|
||||
$submittedAt = now()->subDays(rand(0, 20))->subMinutes(rand(0, 1440));
|
||||
|
||||
$document = Document::create([
|
||||
'modality' => $modalities[$i % count($modalities)]->value,
|
||||
'priority' => ($i % 4 === 0 ? DocumentPriorityEnum::High : DocumentPriorityEnum::Medium)->value,
|
||||
'status' => $status->value,
|
||||
'note' => $notes[$i % count($notes)],
|
||||
'submitted_at' => $submittedAt,
|
||||
'scan_date' => $status === DocumentStatusEnum::Registered ? null : $submittedAt->copy()->addHours(rand(1, 12)),
|
||||
'processing_deadline' => $deadline !== null ? now()->addMinutes($deadline) : null,
|
||||
'finalized_at' => $status === DocumentStatusEnum::Completed ? $submittedAt->copy()->addDays(rand(1, 3)) : null,
|
||||
'finalized_by' => $status === DocumentStatusEnum::Completed ? $doctors->random()->id : null,
|
||||
'rejection_reason' => $status === DocumentStatusEnum::Rejected ? $rejectionReasons[$i % count($rejectionReasons)] : null,
|
||||
'pet_id' => $pets->random()->id,
|
||||
'requester_id' => $owner->id,
|
||||
]);
|
||||
|
||||
$document->assignments()->create([
|
||||
'user_id' => $doctors->random()->id,
|
||||
'role' => 'رادیولوژیست',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user