feat: add lab tests, patient file management, and prescription improvements
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('doctors', function (Blueprint $table) {
|
||||
$table->boolean('is_default')->default(false)->after('license_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('doctors', function (Blueprint $table) {
|
||||
$table->dropColumn('is_default');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('lab_tests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 255)->comment('نام آزمایش');
|
||||
$table->string('category', 100)->nullable()->comment('دستهبندی (مثلاً هماتولوژی، بیوشیمی، سرولوژی)');
|
||||
$table->text('notes')->nullable()->comment('یادداشتها');
|
||||
$table->boolean('is_default')->default(false);
|
||||
$table->boolean('is_active')->default(true)->comment('فعال/غیرفعال');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('lab_tests');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('prescriptions', function (Blueprint $table) {
|
||||
$table->json('lab_test_ids')->nullable()->after('medication_ids')->comment('آرایه شناسههای آزمایشهای انتخابشده');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('prescriptions', function (Blueprint $table) {
|
||||
$table->dropColumn('lab_test_ids');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('lab_tests', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('lab_tests', function (Blueprint $table) {
|
||||
$table->string('category', 100)->nullable()->after('name');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('prescriptions', function (Blueprint $table) {
|
||||
$table->mediumText('lab_content')->nullable()->after('content')->comment('متن درخواست آزمایش');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('prescriptions', function (Blueprint $table) {
|
||||
$table->dropColumn('lab_content');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\LabTest;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LabTestSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$tests = [
|
||||
'CBC',
|
||||
'PT/PTT/INR',
|
||||
'BS',
|
||||
'HIV/Ab',
|
||||
'HBS/Ag',
|
||||
'Hcv/Ab',
|
||||
];
|
||||
|
||||
foreach ($tests as $name) {
|
||||
LabTest::firstOrCreate(
|
||||
['name' => $name],
|
||||
['is_default' => true, 'is_active' => true],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RolePermissionSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
$resources = [
|
||||
'user',
|
||||
'role',
|
||||
'doctor',
|
||||
'patient',
|
||||
'visit',
|
||||
'prescription',
|
||||
'medication',
|
||||
'treatment',
|
||||
'payment_type',
|
||||
'patient_illness',
|
||||
'surgery_center',
|
||||
'surgery_appointment',
|
||||
'osurg_initial',
|
||||
'osurg_audit',
|
||||
];
|
||||
|
||||
$actions = ['view_any', 'view', 'create', 'update', 'delete', 'delete_any', 'restore', 'restore_any', 'replicate', 'reorder', 'force_delete', 'force_delete_any'];
|
||||
|
||||
$pages = ['page_dashboard', 'page_sync_page', 'page_sms_logs_page'];
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
foreach ($actions as $action) {
|
||||
Permission::firstOrCreate([
|
||||
'name' => "{$action}_{$resource}",
|
||||
'guard_name' => 'web',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($pages as $page) {
|
||||
Permission::firstOrCreate([
|
||||
'name' => $page,
|
||||
'guard_name' => 'web',
|
||||
]);
|
||||
}
|
||||
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
$superAdmin = Role::firstOrCreate(['name' => 'super_admin', 'guard_name' => 'web']);
|
||||
$superAdmin->syncPermissions(Permission::all());
|
||||
|
||||
Role::firstOrCreate(['name' => 'panel_user', 'guard_name' => 'web']);
|
||||
|
||||
$admin = User::where('username', 'admin')->first();
|
||||
if ($admin) {
|
||||
$admin->syncRoles(['super_admin']);
|
||||
$this->command->info("super_admin role assigned to user: {$admin->name}");
|
||||
} else {
|
||||
$this->command->warn('Admin user not found!');
|
||||
}
|
||||
|
||||
$this->command->info('Roles and permissions seeded successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user