first commit
Some checks failed
tests / ci (8.5) (push) Has been cancelled
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled

This commit is contained in:
brusnitsyn
2026-04-03 17:20:05 +09:00
commit 3edc8e667e
358 changed files with 39258 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace Database\Seeders;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
$this->call(ProfileSeeder::class);
$this->call(HospitalUnitSeeder::class);
$this->call(DepartmentSeeder::class);
$this->call(MedicalReportSeeder::class);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
use App\Models\Department;
use App\Models\HospitalUnit;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class DepartmentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$departmentUnitMap = collect(config('medical-report.hospital_department_unit_map', []))
->filter(fn (mixed $value, mixed $key): bool => is_string($key) && $key !== '' && is_string($value) && $value !== '');
collect(config('medical-report.hospital_departments', []))
->filter(fn (mixed $name): bool => is_string($name) && trim($name) !== '')
->each(function (string $name) use ($departmentUnitMap): void {
$hospitalUnitId = null;
$mappedUnitName = $departmentUnitMap->get($name);
if (is_string($mappedUnitName) && $mappedUnitName !== '') {
$hospitalUnitId = HospitalUnit::query()
->where('name', $mappedUnitName)
->value('id');
}
Department::query()->updateOrCreate(
['code' => Str::slug(Str::ascii($name))],
[
'name' => $name,
'hospital_unit_id' => $hospitalUnitId,
'is_active' => true,
],
);
});
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Database\Seeders;
use App\Models\HospitalUnit;
use App\Models\Profile;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class HospitalUnitSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$reportingUnits = collect(config('medical-report.reporting_units', []))
->filter(fn (mixed $value): bool => is_string($value) && trim($value) !== '')
->values();
$reportInputTypes = config('medical-report.reporting_unit_input_types', []);
collect(config('medical-report.finance_profiles', []))
->each(function (array $profile) use ($reportingUnits, $reportInputTypes): void {
$profileModel = Profile::query()->where('name', $profile['name'])->firstOrFail();
collect($profile['units'] ?? [])
->filter(fn (mixed $value): bool => is_string($value) && trim($value) !== '')
->values()
->each(function (string $unitName) use ($profileModel, $reportingUnits, $reportInputTypes): void {
HospitalUnit::query()->updateOrCreate(
['slug' => Str::slug(Str::ascii($unitName))],
[
'profile_id' => $profileModel->id,
'name' => $unitName,
'is_reporting_unit' => $reportingUnits->contains($unitName),
'report_input_type' => $reportInputTypes[$unitName] ?? null,
'is_active' => true,
],
);
});
});
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Database\Seeders;
use App\Models\MedicalReport;
use Illuminate\Database\Seeder;
class MedicalReportSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
MedicalReport::query()->firstOrCreate(
['year' => 2026],
[
'name' => 'МЕД 2026',
'input_overrides' => [],
],
);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Seeders;
use App\Models\Profile;
use Illuminate\Database\Seeder;
class ProfileSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
collect(config('medical-report.finance_profiles', []))
->values()
->each(function (array $profile, int $index): void {
Profile::query()->updateOrCreate(
['name' => $profile['name']],
['sort_order' => $index + 1],
);
});
}
}