radfusion/database/seeders/OrganizationSeeder.php

73 lines
2.3 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\Department;
use App\Models\DicomRoutingRule;
use App\Models\Organization;
use Illuminate\Database\Seeder;
class OrganizationSeeder extends Seeder
{
public function run(): void
{
$organizations = [];
$skip_first = true;
$org_csv = fopen(base_path('database/data/organizations.csv'), 'r');
while (($data = fgetcsv($org_csv, 2000, ',')) !== false) {
if (! $skip_first) {
$data = array_trim_strings($data);
$name = $data['0'];
$organizations[$name] = Organization::create([
'name' => $name,
'is_active' => (bool) $data['1'],
]);
}
$skip_first = false;
}
fclose($org_csv);
$dept_csv = fopen(base_path('database/data/departments.csv'), 'r');
$skip_first = true;
while (($data = fgetcsv($dept_csv, 2000, ',')) !== false) {
if (! $skip_first) {
$data = array_trim_strings($data, true);
$name = $data['2'];
$org_name = $data['1'];
$org = $organizations[$org_name];
Department::create([
'name' => $name,
'is_active' => (bool) $data['0'],
'organization_id' => $org->id,
]);
}
$skip_first = false;
}
fclose($dept_csv);
/*
$rul_chev_mr_ct = DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron MR/CT',
'organization_id' => $chev->id,
'department_id' => $chev_dep_ct_mr->id,
'condition' => '(study.institution_name ?? "" starts with "chevron") and (study.modality not in ["CR", "DX", "MG"])',
]
);
$rul_chev_xr = DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron X-ray',
'organization_id' => $chev->id,
'department_id' => $dept_chev_xr->id,
'condition' => '(study.institution_name ?? "" starts with "chevron") and (study.modality in ["CR", "DX", "MG"])',
'priority' => 99,
]
);
*/
}
}