86 lines
2.9 KiB
PHP
86 lines
2.9 KiB
PHP
<?php
|
||
|
||
use App\Models\Department;
|
||
use App\Models\HospitalUnit;
|
||
use App\Models\Profile;
|
||
use Database\Seeders\DepartmentSeeder;
|
||
use Database\Seeders\HospitalUnitSeeder;
|
||
use Database\Seeders\ProfileSeeder;
|
||
|
||
test('finance profiles and hospital units are seeded from configured structure', function () {
|
||
$this->seed([
|
||
ProfileSeeder::class,
|
||
HospitalUnitSeeder::class,
|
||
]);
|
||
|
||
expect(Profile::query()->orderBy('sort_order')->pluck('name')->all())->toBe([
|
||
'Терапевтический',
|
||
'Хирургический',
|
||
'ОПЦ',
|
||
'РСЦ',
|
||
'Реанимации',
|
||
'Прочие',
|
||
]);
|
||
|
||
$unit = HospitalUnit::query()
|
||
->where('name', 'Рентгенологическое отделение')
|
||
->first();
|
||
|
||
expect($unit)->not->toBeNull();
|
||
expect($unit?->profile?->name)->toBe('Прочие');
|
||
expect($unit?->is_reporting_unit)->toBeTrue();
|
||
expect($unit?->report_input_type)->toBe('sectioned_department_metrics');
|
||
});
|
||
|
||
test('non-reporting finance rows remain in the structure but are not marked as reporting units', function () {
|
||
$this->seed([
|
||
ProfileSeeder::class,
|
||
HospitalUnitSeeder::class,
|
||
]);
|
||
|
||
$unit = HospitalUnit::query()
|
||
->where('name', 'Сотрудники')
|
||
->first();
|
||
|
||
expect($unit)->not->toBeNull();
|
||
expect($unit?->profile?->name)->toBe('Прочие');
|
||
expect($unit?->is_reporting_unit)->toBeFalse();
|
||
expect($unit?->report_input_type)->toBeNull();
|
||
});
|
||
|
||
test('department abbreviations are mapped to finance hospital units where configured', function () {
|
||
$this->seed([
|
||
ProfileSeeder::class,
|
||
HospitalUnitSeeder::class,
|
||
DepartmentSeeder::class,
|
||
]);
|
||
|
||
$department = Department::query()
|
||
->where('name', 'Гематология')
|
||
->first();
|
||
|
||
expect($department)->not->toBeNull();
|
||
expect($department?->hospitalUnit?->name)->toBe('Гематологическое отделение');
|
||
|
||
$adultClinic = Department::query()
|
||
->where('name', 'П-ка взрослая')
|
||
->first();
|
||
|
||
expect($adultClinic)->not->toBeNull();
|
||
expect($adultClinic?->hospitalUnit?->name)->toBe('Областная консультативно-диагностическая поликлиника');
|
||
|
||
$intensiveCare = Department::query()
|
||
->where('name', 'РАО 1')
|
||
->first();
|
||
|
||
expect($intensiveCare)->not->toBeNull();
|
||
expect($intensiveCare?->hospitalUnit?->name)->toBe('Отделение анестезиологии-реанимации с палатами реанимации и интенсивной терапии');
|
||
|
||
$pathology = Department::query()
|
||
->where('name', 'ПАО')
|
||
->first();
|
||
|
||
expect($pathology)->not->toBeNull();
|
||
expect($pathology?->hospitalUnit?->name)->toBe('Патологоанатомическое отделение');
|
||
});
|