Работа над журналом для ст. мед сестер

This commit is contained in:
brusnitsyn
2026-05-04 17:11:16 +09:00
parent f107ebd167
commit 7a58812072
61 changed files with 3532 additions and 1163 deletions

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('report_patient_types', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_patient_types');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('report_patient_statuses', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_patient_statuses');
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('report_statuses', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_statuses');
}
};

View File

@@ -0,0 +1,137 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$teams = config('permission.teams');
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
throw_if(empty($tableNames), 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
/**
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
*/
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
$table->id(); // permission id
$table->string('name');
$table->string('guard_name');
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
/**
* See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered.
*/
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
$table->id(); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name');
$table->string('guard_name');
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
$table->unsignedBigInteger($pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->cascadeOnDelete();
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
$table->unsignedBigInteger($pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->cascadeOnDelete();
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
$table->unsignedBigInteger($pivotPermission);
$table->unsignedBigInteger($pivotRole);
$table->foreign($pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->cascadeOnDelete();
$table->foreign($pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->cascadeOnDelete();
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$tableNames = config('permission.table_names');
throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
Schema::dropIfExists($tableNames['role_has_permissions']);
Schema::dropIfExists($tableNames['model_has_roles']);
Schema::dropIfExists($tableNames['model_has_permissions']);
Schema::dropIfExists($tableNames['roles']);
Schema::dropIfExists($tableNames['permissions']);
}
};

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('report_nurses', function (Blueprint $table) {
$table->id();
$table->date('report_date');
$table->dateTime('sent_at')->nullable();
$table->string('period_type')->default('day') // day|week|month|year
->comment('Тип отчетного периода');
$table->dateTime('period_start')->nullable()
->comment('Начало отчетного периода');
$table->dateTime('period_end')->nullable()
->comment('Окончание отчетного периода');
$table->integer('report_month')->storedAs('EXTRACT(MONTH FROM created_at)::integer')
->comment('Отчетный месяц');
$table->integer('report_year')->storedAs('EXTRACT(YEAR FROM created_at)::integer')
->comment('Отчетный год');
$table->foreignIdFor(\App\Models\ReportStatus::class, 'status_id');
$table->foreignIdFor(\App\Models\MisLpuDoctor::class, 'rf_lpudoctor_id')->nullable();
$table->foreignIdFor(\App\Models\Department::class, 'rf_department_id')->default(1);
$table->foreignIdFor(\App\Models\User::class, 'rf_user_id')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('report_nurses');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('medical_history_corrections', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\MedicalHistory::class, 'medical_history_id');
$table->string('medical_card_number')->nullable();
$table->string('full_name')->nullable();
$table->dateTime('birth_date')->nullable();
$table->dateTime('recipient_date')->nullable();
$table->dateTime('extract_date')->nullable();
$table->dateTime('death_date')->nullable();
$table->boolean('male')->nullable();
$table->integer('urgency_id')->nullable();
$table->integer('hospital_result_id')->nullable();
$table->integer('visit_result_id')->nullable();
$table->foreignIdFor(\App\Models\User::class, 'user_id');
$table->integer('mis_user_id');
$table->text('comment')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('medical_history_corrections');
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('medical_history_nurses', function (Blueprint $table) {
$table->id();
$table->string('source_type')->default('manual');
$table->string('medical_card_number');
$table->string('full_name');
$table->date('birth_date');
$table->dateTime('recipient_date');
$table->dateTime('extract_date')->nullable();
$table->dateTime('death_date')->nullable();
$table->boolean('male')->default(false);
$table->integer('urgency_id');
$table->integer('hospital_result_id')->nullable();
$table->integer('visit_result_id')->nullable();
$table->foreignIdFor(\App\Models\User::class, 'user_id');
$table->integer('mis_user_id')->nullable();
$table->text('comment')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('medical_history_nurses');
}
};

View File

@@ -0,0 +1,62 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;
class PermissionAndRoleSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Permission::create(['name' => 'Создание отчета']);
Permission::create(['name' => 'Редактирование отчета']);
Permission::create(['name' => 'Просмотр статистики']);
Permission::create(['name' => 'Создание и редактирование пользователей']);
Permission::create(['name' => 'Создание и редактирование прав и ролей']);
Permission::create(['name' => 'Создание и редактирование метрик']);
$admin = Role::create(['name' => 'admin']);
$gv = Role::create(['name' => 'gv']);
$zam = Role::create(['name' => 'zam']);
$zav = Role::create(['name' => 'zav']);
$dej = Role::create(['name' => 'dej']);
$nurse = Role::create(['name' => 'nurse']);
$admin->givePermissionTo([
'Создание отчета',
'Редактирование отчета',
'Просмотр статистики',
'Создание и редактирование пользователей',
'Создание и редактирование прав и ролей',
'Создание и редактирование метрик',
]);
$gv->givePermissionTo([
'Создание отчета',
'Редактирование отчета',
'Просмотр статистики',
]);
$zam->givePermissionTo([
'Создание отчета',
'Редактирование отчета',
'Просмотр статистики',
]);
$zav->givePermissionTo([
'Создание отчета',
'Редактирование отчета',
'Просмотр статистики',
]);
$dej->givePermissionTo([
'Создание отчета',
]);
$nurse->givePermissionTo([
'Создание отчета',
]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ReportLibSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}