seeding from CSV
This commit is contained in:
parent
8565d35fe9
commit
ef2dd84cfb
@ -15,6 +15,7 @@ public function run(): void
|
|||||||
$this->call([
|
$this->call([
|
||||||
RoleSeeder::class,
|
RoleSeeder::class,
|
||||||
OrganizationSeeder::class,
|
OrganizationSeeder::class,
|
||||||
|
DicomServerSeeder::class,
|
||||||
UserSeeder::class,
|
UserSeeder::class,
|
||||||
ModalityProcedureSeeder::class,
|
ModalityProcedureSeeder::class,
|
||||||
]);
|
]);
|
||||||
|
@ -2,12 +2,42 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\DicomServer;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DicomServerSeeder extends Seeder
|
class DicomServerSeeder extends Seeder
|
||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
|
$skip_first = true;
|
||||||
|
$csv_file = fopen(base_path('database/data/dicom-servers.csv'), 'r');
|
||||||
|
while (($data = fgetcsv($csv_file, 2000, ',')) !== false) {
|
||||||
|
if ($skip_first) {
|
||||||
|
$skip_first = false;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$data = array_trim_strings($data, true);
|
||||||
|
DicomServer::create([
|
||||||
|
'is_active' => (bool) $data['0'],
|
||||||
|
'server_name' => strtoupper($data['1']),
|
||||||
|
'geo_code' => $data['2'],
|
||||||
|
'host' => $data['3'],
|
||||||
|
'http_port' => $data['4'],
|
||||||
|
'dicom_port' => $data['5'],
|
||||||
|
'rest_api_endpoint' => $data['6'],
|
||||||
|
'ae_title' => strtoupper($data['7']),
|
||||||
|
'username' => strtolower($data['8'] ?? ''),
|
||||||
|
'password' => $data['9'],
|
||||||
|
'wado_path' => $data['10'],
|
||||||
|
'stone_viewer_path' => $data['11'],
|
||||||
|
'ohif_viewer_path' => $data['12'],
|
||||||
|
'meddream_viewer_path' => $data['13'],
|
||||||
|
// 'organization' => $data['14'],
|
||||||
|
// 'department' => $data['15'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
fclose($csv_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use App\Models\Department;
|
use App\Models\Department;
|
||||||
use App\Models\DicomRoutingRule;
|
use App\Models\DicomRoutingRule;
|
||||||
use App\Models\DicomServer;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
@ -12,45 +11,42 @@ class OrganizationSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
Organization::create([
|
$organizations = [];
|
||||||
'name' => 'CATCH-ALL',
|
|
||||||
'is_active' => true,
|
|
||||||
]);
|
|
||||||
$chev = Organization::create([
|
|
||||||
'name' => 'Chevron',
|
|
||||||
'is_active' => true,
|
|
||||||
]);
|
|
||||||
$cmch = Organization::create([
|
|
||||||
'name' => 'CMCH',
|
|
||||||
'is_active' => true,
|
|
||||||
]);
|
|
||||||
$dummy = Organization::create([
|
|
||||||
'name' => 'Dummy Site',
|
|
||||||
'is_active' => false,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$dept_chev_xr = Department::create(
|
$skip_first = true;
|
||||||
[
|
$org_csv = fopen(base_path('database/data/organizations.csv'), 'r');
|
||||||
'is_active' => true,
|
while (($data = fgetcsv($org_csv, 2000, ',')) !== false) {
|
||||||
'name' => 'Chev-CR',
|
if (! $skip_first) {
|
||||||
'organization_id' => $chev->id,
|
$data = array_trim_strings($data);
|
||||||
]
|
$name = $data['0'];
|
||||||
);
|
$organizations[$name] = Organization::create([
|
||||||
$chev_dep_ct_mr = Department::create(
|
'name' => $name,
|
||||||
[
|
'is_active' => (bool) $data['1'],
|
||||||
'is_active' => true,
|
]);
|
||||||
'name' => 'Chev-MR',
|
}
|
||||||
'organization_id' => $chev->id,
|
$skip_first = false;
|
||||||
]
|
}
|
||||||
);
|
fclose($org_csv);
|
||||||
$dept_cmch_mr = Department::create(
|
|
||||||
[
|
|
||||||
'is_active' => false,
|
|
||||||
'name' => 'CMCH MR',
|
|
||||||
'organization_id' => $cmch->id,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
|
$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(
|
$rul_chev_mr_ct = DicomRoutingRule::create(
|
||||||
[
|
[
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
@ -71,98 +67,6 @@ public function run(): void
|
|||||||
'priority' => 99,
|
'priority' => 99,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
DicomServer::create(
|
|
||||||
[
|
|
||||||
'is_active' => true,
|
|
||||||
'server_name' => 'CTG-1',
|
|
||||||
'geo_code' => 'BD',
|
|
||||||
'host' => 'pacs.mylabctg.com',
|
|
||||||
'http_port' => 8042,
|
|
||||||
'dicom_port' => 4242,
|
|
||||||
'rest_api_endpoint' => 'http://pacs.mylabctg.com:8042/',
|
|
||||||
'wado_path' => 'dicom-web',
|
|
||||||
'ae_title' => 'BLACKFISH',
|
|
||||||
'stone_viewer_path' => 'stone-webviewer/index.html',
|
|
||||||
'ohif_viewer_path' => 'ohif/viewer',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
DicomServer::create(
|
|
||||||
[
|
|
||||||
'is_active' => true,
|
|
||||||
'server_name' => 'HEL-1',
|
|
||||||
'geo_code' => 'FI',
|
|
||||||
'host' => 'helsinki.mylabctg.com',
|
|
||||||
'http_port' => 8042,
|
|
||||||
'dicom_port' => 4242,
|
|
||||||
'rest_api_endpoint' => 'http://helsinki.mylabctg.com:8042/',
|
|
||||||
'wado_path' => 'dicom-web',
|
|
||||||
'ae_title' => 'BLACKFISH',
|
|
||||||
'stone_viewer_path' => 'stone-webviewer/index.html',
|
|
||||||
'ohif_viewer_path' => 'ohif/viewer',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
DicomServer::create(
|
|
||||||
[
|
|
||||||
'is_active' => true,
|
|
||||||
'server_name' => 'SGP-1',
|
|
||||||
'geo_code' => 'SG',
|
|
||||||
'host' => 'singapore.mylabctg.com',
|
|
||||||
'http_port' => 8042,
|
|
||||||
'dicom_port' => 4242,
|
|
||||||
'rest_api_endpoint' => 'http://singapore.mylabctg.com:8042/',
|
|
||||||
'wado_path' => 'dicom-web',
|
|
||||||
'ae_title' => 'BLACKFISH',
|
|
||||||
'stone_viewer_path' => 'stone-webviewer/index.html',
|
|
||||||
'ohif_viewer_path' => 'ohif/viewer',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
DicomServer::create(
|
|
||||||
[
|
|
||||||
'is_active' => true,
|
|
||||||
'server_name' => 'Texas',
|
|
||||||
'geo_code' => 'US',
|
|
||||||
'host' => 'texas.mylabctg.com',
|
|
||||||
'http_port' => 8042,
|
|
||||||
'dicom_port' => 4242,
|
|
||||||
'rest_api_endpoint' => 'http://texas.mylabctg.com:8042/',
|
|
||||||
'wado_path' => 'dicom-web',
|
|
||||||
'ae_title' => 'BLACKFISH',
|
|
||||||
'stone_viewer_path' => 'stone-webviewer/index.html',
|
|
||||||
'ohif_viewer_path' => 'ohif/viewer',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
DicomServer::create(
|
|
||||||
[
|
|
||||||
'is_active' => false,
|
|
||||||
'server_name' => 'San Jose',
|
|
||||||
'geo_code' => 'US',
|
|
||||||
'host' => 'san-jose.mylabctg.com',
|
|
||||||
'http_port' => 8042,
|
|
||||||
'dicom_port' => 4242,
|
|
||||||
'rest_api_endpoint' => 'http://san-jose.mylabctg.com:8042/',
|
|
||||||
'wado_path' => 'dicom-web',
|
|
||||||
'ae_title' => 'BLACKFISH',
|
|
||||||
'stone_viewer_path' => 'stone-webviewer/index.html',
|
|
||||||
'ohif_viewer_path' => 'ohif/viewer',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
DicomServer::create(
|
|
||||||
[
|
|
||||||
'is_active' => false,
|
|
||||||
'server_name' => 'MAA-1',
|
|
||||||
'host' => 'pacs.mylabctg.com',
|
|
||||||
'geo_code' => 'IN',
|
|
||||||
'http_port' => 8043,
|
|
||||||
'dicom_port' => 4242,
|
|
||||||
'rest_api_endpoint' => 'http://pacs.mylabctg.com:8042/',
|
|
||||||
'ae_title' => 'BLACKFISH',
|
|
||||||
'wado_path' => 'dicom-web',
|
|
||||||
'stone_viewer_path' => 'stone-webviewer/index.html',
|
|
||||||
'ohif_viewer_path' => 'ohif/viewer',
|
|
||||||
'organization_id' => $chev->id,
|
|
||||||
'department_id' => $dept_chev_xr->id,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\Pacs\Sync\StudiesSync;
|
use App\Services\Pacs\Sync\StudiesSync;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Spatie\Permission\Models\Role as SpatieRole;
|
||||||
|
|
||||||
class UserSeeder extends Seeder
|
class UserSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -24,75 +25,40 @@ public function run(): void
|
|||||||
]);
|
]);
|
||||||
$usr->assignRole(Role::SystemAgent);
|
$usr->assignRole(Role::SystemAgent);
|
||||||
|
|
||||||
$usr = User::factory()->create([
|
$orgs = Organization::pluck('id', 'name');
|
||||||
'first_name' => 'Administrator',
|
$depts = Department::pluck('id', 'name');
|
||||||
'display_name' => 'Admin',
|
$roles = SpatieRole::pluck('id', 'name');
|
||||||
'username' => 'admin',
|
|
||||||
'email' => 'admin@example.com',
|
$skip_first = true;
|
||||||
'email_verified_at' => now(),
|
$csv_file = fopen(base_path('database/data/users.csv'), 'r');
|
||||||
'phone' => '+8801733938582',
|
while (($data = fgetcsv($csv_file, 2000, ',')) !== false) {
|
||||||
|
if ($skip_first) {
|
||||||
|
$skip_first = false;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$data = array_trim_strings($data, true);
|
||||||
|
$org_id = $data[9] ? $orgs[$data[9]] : null;
|
||||||
|
$dept_id = $data[10] ? $depts[$data[10]] : null;
|
||||||
|
$role = Role::from(strtolower($data[8]));
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
|
'display_name' => $data[0],
|
||||||
|
'prefix' => $data[1],
|
||||||
|
'first_name' => $data[2],
|
||||||
|
'last_name' => $data[3],
|
||||||
|
'signature_text' => $data[4],
|
||||||
|
'username' => $data[5],
|
||||||
|
'password' => bcrypt('password'),
|
||||||
|
'email' => strtolower($data[6]),
|
||||||
|
'phone' => (string) $data[7],
|
||||||
|
'email_verified_at' => $data[6] ? now() : null,
|
||||||
|
'organization_id' => $org_id,
|
||||||
|
'department_id' => $dept_id,
|
||||||
]);
|
]);
|
||||||
$usr->assignRole(Role::Admin);
|
$user->assignRole($role->value);
|
||||||
|
}
|
||||||
$chevron = Organization::where('name', 'Chevron')->first();
|
fclose($csv_file);
|
||||||
$cmch = Organization::where('name', 'CMCH')->first();
|
|
||||||
|
|
||||||
$chev_xr = Department::where('organization_id', $chevron->id)->first();
|
|
||||||
User::factory(4)
|
|
||||||
->create([
|
|
||||||
'organization_id' => $chevron->id,
|
|
||||||
])
|
|
||||||
->each(function ($u, $key) {
|
|
||||||
$u->assignRole(Role::Technician);
|
|
||||||
$u->update([
|
|
||||||
'username' => sprintf('tech%d', $key + 1),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
User::factory(4)
|
|
||||||
->create([
|
|
||||||
'organization_id' => $chevron->id,
|
|
||||||
'department_id' => $chev_xr->id,
|
|
||||||
])
|
|
||||||
->each(function ($u, $key) {
|
|
||||||
$u->assignRole(Role::Technician);
|
|
||||||
$u->update([
|
|
||||||
'username' => sprintf('xrt%d', $key + 1),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
User::factory(4)
|
|
||||||
->create([
|
|
||||||
'organization_id' => $cmch->id,
|
|
||||||
])
|
|
||||||
->each(function ($u, $key) {
|
|
||||||
$u->assignRole(Role::Technician);
|
|
||||||
$u->update([
|
|
||||||
'username' => sprintf('cmctech%d', $key + 1),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
$images = [
|
|
||||||
'hossain-saad.png', 'nasir-uddin.png', 'sadrul-amin.png',
|
|
||||||
'khairul-islam.png', 'rabeya-khatoon.png', 'subash.png',
|
|
||||||
];
|
|
||||||
|
|
||||||
User::factory(9)
|
|
||||||
->create()
|
|
||||||
->each(function (User $u, $key) use ($images) {
|
|
||||||
$u->assignRole(Role::Radiologist);
|
|
||||||
$u->update([
|
|
||||||
'display_name' => sprintf('Dr. %s.%d', $u->first_name, $key + 1),
|
|
||||||
'username' => sprintf('rad%d', $key + 1),
|
|
||||||
'signature_image_path' => 'signatures/' . fake()->randomElement($images),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
User::factory(3)
|
|
||||||
->create()
|
|
||||||
->each(function ($u) {
|
|
||||||
$u->assignRole(Role::Guest);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user