Compare commits

...

10 Commits

Author SHA1 Message Date
8e3798b32b minor 2025-02-01 13:44:10 +06:00
7f5d594a24 seeding - images, rules 2025-02-01 13:41:03 +06:00
05b615fc75 misc 2025-02-01 13:01:05 +06:00
6a1dd35da5 phone number fix 2025-02-01 12:55:29 +06:00
ef2dd84cfb seeding from CSV 2025-02-01 12:46:34 +06:00
8565d35fe9 enhanced array trim 2025-02-01 12:46:23 +06:00
7e1d141338 seed 2025-02-01 12:46:11 +06:00
fcfe1278f7 FIX - array-trim 2025-02-01 12:25:37 +06:00
3ad9e8633e wip 2025-02-01 12:25:30 +06:00
10c96a54c4 users 2025-02-01 11:48:34 +06:00
10 changed files with 212 additions and 226 deletions

View File

@ -36,16 +36,11 @@ function array_purge(array $ary): array
}
if (! function_exists('array_trim_strings')) {
function array_trim_strings(array $ary): array
function array_trim_strings(array $ary, bool $null_if_blank = false): array
{
return array_filter($ary, function ($v) {
if (! is_string($v)) {
return $v;
}
$v = trim($v);
$trimmed = array_map(static fn ($v) => is_string($v) ? trim($v) : $v, $ary);
return blank($v) ? null : $v;
});
return $null_if_blank ? array_map(static fn ($v) => empty($v) ? null : $v, $trimmed) : $trimmed;
}
}

View File

@ -0,0 +1,3 @@
is_active,organization,name
1,Chevron Panchlaish,DR
1,Chevron Panchlaish,Imaging
1 is_active organization name
2 1 Chevron Panchlaish DR
3 1 Chevron Panchlaish Imaging

View File

@ -0,0 +1,3 @@
is_active,server_name,geo_code,host,http_port,dicom_port,rest_api_endpoint,ae_title,username,password,wado_path,stone_viewer_path,ohif_viewer_path,meddream_viewer_path,organization,department
1,CTG-1,BD,cgp1.telerad24.com,8042,4242,http://cgp1.telerad24.com:8042/,BLACKFISH,,,dicom-web,stone-webviewer/index.html,ohif/viewer,,,
1,NBG-1,DE,de1.telerad24.com,8042,4242,http://de1.telerad24.com:8042/,BLACKFISH,,,dicom-web,stone-webviewer/index.html,ohif/viewer,,,
1 is_active server_name geo_code host http_port dicom_port rest_api_endpoint ae_title username password wado_path stone_viewer_path ohif_viewer_path meddream_viewer_path organization department
2 1 CTG-1 BD cgp1.telerad24.com 8042 4242 http://cgp1.telerad24.com:8042/ BLACKFISH dicom-web stone-webviewer/index.html ohif/viewer
3 1 NBG-1 DE de1.telerad24.com 8042 4242 http://de1.telerad24.com:8042/ BLACKFISH dicom-web stone-webviewer/index.html ohif/viewer

View File

@ -0,0 +1,5 @@
name,is_active
CATCH-ALL,1
Chevron Panchlaish,1
Chevron Boropole,1
Chevron Shantibag,1
1 name is_active
2 CATCH-ALL 1
3 Chevron Panchlaish 1
4 Chevron Boropole 1
5 Chevron Shantibag 1

27
database/data/users.csv Normal file
View File

@ -0,0 +1,27 @@
DNAME,PREFIX,FNAME,LNAME,DEGREE,USERNAME,EMAIL,PHONE,ROLE,ORG,DEPT,SIGN_IMG
Dr. Sadrul ,Dr.,Sadrul ,Amin ,"MBBS, FCPS, M-Phil, MD (Radiology & Imaging), Ex-Associate Professor, Department of Radiology & Imaging, Bangabandhu Sheikh Mujib Medical University, BMDC Reg. No: A-26619",aminsadrul@gmail.com,aminsadrul@gmail.com,8801711362820,RAD,,,sadrul-amin.png
Prof. Dr. Subash ,Prof. Dr.,Subash ,Mazumder,"MBBS, MD, HOD (Radiology & Imaging), Chittagong Medical College Hospital. BMDC Reg. No: A 23715",subashmajumder@yahoo.com,subashmajumder@yahoo.com,8801819329484,RAD,,,subash.png
Dr. Goutam ,Dr.,Goutam,Chowdhury ,"MBBS, M.MED, MRCR (London), Fellow Radiology, Act (Neuro-Radiology), Consultant, Radiology & Imaging. BMDC Reg. No: A-32086",drgoutam,,,RAD,,,
Brig. Gen. Khairul,Brig. Gen. Dr.,Md. Khairul ,Islam,"MBBS, FCPS (Radiology & Imaging), Advanced Training on MRI, CT & Coronary CT Angiogram (India). Senior Consultant, Radiology & Imaging",drkhairul,,8801715059151,RAD,,,khairul-islam.png
Prof. Dr. Col. Nasir,Prof. Dr.Col. (Retd),Md. Nasir ,Uddin,"MBBS, FCPS, ARDMS, RVT, ARMRIT (USA), TMSS Medical College & Hospital, Bogura, Consultant Radiologist, Popular Diagnostic Center. BMDC Reg. No: A-21609",drnasir770@gmail.com,drnasir770@gmail.com,8801715748987,RAD,,,nasir-uddin.png
Prof. Brig. Gen. Saad ,Prof. (Brig. Gen),A M Hossain,Saad,"Classified Specialist, Radiology & Imaging, Armed Forces Medical College, Dhaka Cantonment. MBBS, FCPS. Fellow CT Scan (Dublin & Germany). Fellow MRI (KSA)",drsaad,,8801715059151,RAD,,,hossain-saad.png
Brig. Gen. Anwarul,Brig. Gen. (Retd),M Anwarul ,Haque,"MBBS. FCPS.(Radiology). Advance Training in CT & MRI (KSA), BMDC Reg. No: A -13336",dr.mahaque60@gmail.com,dr.mahaque60@gmail.com,8801911302505,RAD,,,
Dr. Moinul ,Dr.,Mohammad Moinul,Hossain,"MBBS, MD (Radiology & Imaging)-BSMMU, Consultant (Radiology & Imaging), Radiology & Imaging Specialist, BMDC Reg. No: A-33097",mmhossainsa06@gmail.com,mmhossainsa06@gmail.com,8801715129437,RAD,,,
Prof. Rabeya ,Asst. Prof. Dr. ,Rabeya,Khatoon,"MBBS, MCPS, MD (BSMMU), Consultant, Radiolgoy & Imaging, BIRDEM, Dhaka. BMDC Reg. No: A-47981",drrabeya,,,RAD,,,rabeya-khatoon.png
Prof. Col. Anowar,Prof. Col. Dr.,Anowar ,Hossain,"MBBS,FCPS (Radiology & Imaging), Fellow Cardiovascular Imaging (CT and MRI). All India Institute of Medical Science, New Delhi, India. Department of Radiology & Imaging Armed Forces Medical College & CMH Dhaka, BMDC Reg No : A-32496",dranowar,,8801795430240,RAD,,,
Dr. Hamid,Dr.,Hamid ,Alam ,,drhamid,,16462956323,RAD,,,
Dr. Shabiha ,Dr.,Shabiha,Quadir ,,dr.shabihaquadir@gmail.com,dr.shabihaquadir@gmail.com,8801819876760,RAD,,,
Dr. Ehsan,Dr.,Ehsan S,Choudhury,,ehsanchy@gmail.com,ehsanchy@gmail.com,8801711898269,RAD,,,
Dr. Mobin,Dr.,Mobinul Alam,Chowdhury ,,mobinchy@hotmail.com,mobinchy@hotmail.com,8801819775757,RAD,,,
Noor Mohammad ,,Noor ,Mohammad ,,noor.mohammad024@gmail.com,noor.mohammad024@gmail.com,8801716817712,TECH,Chevron Panchlaish,Imaging,
Ali Akbar ,,Ali ,Akbar ,,ali.akbar.ri@gmail.com,ali.akbar.ri@gmail.com,8801816913564,TECH,Chevron Panchlaish,Imaging,
Bulbul,,Mahbubul ,Islam ,,bulbulislam10@gmail.com,bulbulislam10@gmail.com,8801761587552,TECH,Chevron Panchlaish,Imaging,
Zulhas,,Zillur Rahman,Zulhas,,rahmanmdzillur9@gmail.com,rahmanmdzillur9@gmail.com,8801868658028,TECH,Chevron Panchlaish,Imaging,
Dr. Masroor,Dr.,Masroor Ehsan,Choudhury,,masroor,masroore@gmail.com,8801733938582,ADMIN,,,
Sumit,,Sumit,Majumder,,sumit.chvrnit@gmail.com,sumit.chvrnit@gmail.com,8801822224492,ADMIN,,,
Saiful,,Saiful,Islam,,saiful,,8801824534945,TECH,Chevron Panchlaish,Imaging,
Apon,,Apon,,,apon,,8801627970974,TECH,Chevron Panchlaish,Imaging,
Chevron CR,,X-ray,Tech,,chevroncr,,,TECH,Chevron Panchlaish,DR,
Dr. Gopinathan,Dr.,Gopinathan,,"MBBS, MDRD, Reg No.62980",drgopinathan,,,RAD,,,
Dr. Sudha,Dr.,K Sudha,,"MBBS, MDRD",drsudha,,,RAD,,,
Dr. Rajkumar,Dr.,Rajkumar,,MBBS MDRD Reg No.TMMC130572,drrajkumar,,,RAD,,,
1 DNAME PREFIX FNAME LNAME DEGREE USERNAME EMAIL PHONE ROLE ORG DEPT SIGN_IMG
2 Dr. Sadrul Dr. Sadrul Amin MBBS, FCPS, M-Phil, MD (Radiology & Imaging), Ex-Associate Professor, Department of Radiology & Imaging, Bangabandhu Sheikh Mujib Medical University, BMDC Reg. No: A-26619 aminsadrul@gmail.com aminsadrul@gmail.com 8801711362820 RAD sadrul-amin.png
3 Prof. Dr. Subash Prof. Dr. Subash Mazumder MBBS, MD, HOD (Radiology & Imaging), Chittagong Medical College Hospital. BMDC Reg. No: A 23715 subashmajumder@yahoo.com subashmajumder@yahoo.com 8801819329484 RAD subash.png
4 Dr. Goutam Dr. Goutam Chowdhury MBBS, M.MED, MRCR (London), Fellow Radiology, Act (Neuro-Radiology), Consultant, Radiology & Imaging. BMDC Reg. No: A-32086 drgoutam RAD
5 Brig. Gen. Khairul Brig. Gen. Dr. Md. Khairul Islam MBBS, FCPS (Radiology & Imaging), Advanced Training on MRI, CT & Coronary CT Angiogram (India). Senior Consultant, Radiology & Imaging drkhairul 8801715059151 RAD khairul-islam.png
6 Prof. Dr. Col. Nasir Prof. Dr.Col. (Retd) Md. Nasir Uddin MBBS, FCPS, ARDMS, RVT, ARMRIT (USA), TMSS Medical College & Hospital, Bogura, Consultant Radiologist, Popular Diagnostic Center. BMDC Reg. No: A-21609 drnasir770@gmail.com drnasir770@gmail.com 8801715748987 RAD nasir-uddin.png
7 Prof. Brig. Gen. Saad Prof. (Brig. Gen) A M Hossain Saad Classified Specialist, Radiology & Imaging, Armed Forces Medical College, Dhaka Cantonment. MBBS, FCPS. Fellow CT Scan (Dublin & Germany). Fellow MRI (KSA) drsaad 8801715059151 RAD hossain-saad.png
8 Brig. Gen. Anwarul Brig. Gen. (Retd) M Anwarul Haque MBBS. FCPS.(Radiology). Advance Training in CT & MRI (KSA), BMDC Reg. No: A -13336 dr.mahaque60@gmail.com dr.mahaque60@gmail.com 8801911302505 RAD
9 Dr. Moinul Dr. Mohammad Moinul Hossain MBBS, MD (Radiology & Imaging)-BSMMU, Consultant (Radiology & Imaging), Radiology & Imaging Specialist, BMDC Reg. No: A-33097 mmhossainsa06@gmail.com mmhossainsa06@gmail.com 8801715129437 RAD
10 Prof. Rabeya Asst. Prof. Dr. Rabeya Khatoon MBBS, MCPS, MD (BSMMU), Consultant, Radiolgoy & Imaging, BIRDEM, Dhaka. BMDC Reg. No: A-47981 drrabeya RAD rabeya-khatoon.png
11 Prof. Col. Anowar Prof. Col. Dr. Anowar Hossain MBBS,FCPS (Radiology & Imaging), Fellow Cardiovascular Imaging (CT and MRI). All India Institute of Medical Science, New Delhi, India. Department of Radiology & Imaging Armed Forces Medical College & CMH Dhaka, BMDC Reg No : A-32496 dranowar 8801795430240 RAD
12 Dr. Hamid Dr. Hamid Alam drhamid 16462956323 RAD
13 Dr. Shabiha Dr. Shabiha Quadir dr.shabihaquadir@gmail.com dr.shabihaquadir@gmail.com 8801819876760 RAD
14 Dr. Ehsan Dr. Ehsan S Choudhury ehsanchy@gmail.com ehsanchy@gmail.com 8801711898269 RAD
15 Dr. Mobin Dr. Mobinul Alam Chowdhury mobinchy@hotmail.com mobinchy@hotmail.com 8801819775757 RAD
16 Noor Mohammad Noor Mohammad noor.mohammad024@gmail.com noor.mohammad024@gmail.com 8801716817712 TECH Chevron Panchlaish Imaging
17 Ali Akbar Ali Akbar ali.akbar.ri@gmail.com ali.akbar.ri@gmail.com 8801816913564 TECH Chevron Panchlaish Imaging
18 Bulbul Mahbubul Islam bulbulislam10@gmail.com bulbulislam10@gmail.com 8801761587552 TECH Chevron Panchlaish Imaging
19 Zulhas Zillur Rahman Zulhas rahmanmdzillur9@gmail.com rahmanmdzillur9@gmail.com 8801868658028 TECH Chevron Panchlaish Imaging
20 Dr. Masroor Dr. Masroor Ehsan Choudhury masroor masroore@gmail.com 8801733938582 ADMIN
21 Sumit Sumit Majumder sumit.chvrnit@gmail.com sumit.chvrnit@gmail.com 8801822224492 ADMIN
22 Saiful Saiful Islam saiful 8801824534945 TECH Chevron Panchlaish Imaging
23 Apon Apon apon 8801627970974 TECH Chevron Panchlaish Imaging
24 Chevron CR X-ray Tech chevroncr TECH Chevron Panchlaish DR
25 Dr. Gopinathan Dr. Gopinathan MBBS, MDRD, Reg No.62980 drgopinathan RAD
26 Dr. Sudha Dr. K Sudha MBBS, MDRD drsudha RAD
27 Dr. Rajkumar Dr. Rajkumar MBBS MDRD Reg No.TMMC130572 drrajkumar RAD

View File

@ -15,9 +15,10 @@ public function run(): void
$this->call([
RoleSeeder::class,
OrganizationSeeder::class,
DicomServerSeeder::class,
DicomRoutingRuleSeeder::class,
UserSeeder::class,
ModalityProcedureSeeder::class,
]);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace Database\Seeders;
use App\Models\Department;
use App\Models\DicomRoutingRule;
use App\Models\Organization;
use Illuminate\Database\Seeder;
class DicomRoutingRuleSeeder extends Seeder
{
public function run(): void
{
$chev = Organization::where('name', 'Chevron Panchlaish')->first();
$dept_chev_xr = Department::where('name', 'DR')->first();
$chev_dep_ct_mr = Department::where('name', 'Imaging')->first();
$dr_modalities = ['DR', 'CR', 'DX', 'MG', 'OT', 'RF', 'XA', 'XRF', 'DXA', 'DBT', 'OPT'];
$dr = collect($dr_modalities)->map(fn ($modality) => sprintf('"%s"', $modality))->implode(', ');
DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron Panchlaish Imaging',
'organization_id' => $chev->id,
'department_id' => $chev_dep_ct_mr->id,
'condition' => sprintf('(study.institution_name ?? "" starts with "chevron") and (study.modality not in [%s])', $dr),
]
);
DicomRoutingRule::create(
[
'is_active' => true,
'name' => 'Chevron Panchlaish X-ray',
'organization_id' => $chev->id,
'department_id' => $dept_chev_xr->id,
'condition' => sprintf('(study.institution_name ?? "" starts with "chevron") and (study.modality in [%s])', $dr),
'priority' => 99,
]
);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace Database\Seeders;
use App\Models\DicomServer;
use Illuminate\Database\Seeder;
class DicomServerSeeder extends Seeder
{
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);
}
}

View File

@ -3,8 +3,6 @@
namespace Database\Seeders;
use App\Models\Department;
use App\Models\DicomRoutingRule;
use App\Models\DicomServer;
use App\Models\Organization;
use Illuminate\Database\Seeder;
@ -12,157 +10,39 @@ class OrganizationSeeder extends Seeder
{
public function run(): void
{
Organization::create([
'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,
]);
$organizations = [];
$dept_chev_xr = Department::create(
[
'is_active' => true,
'name' => 'Chev-CR',
'organization_id' => $chev->id,
]
);
$chev_dep_ct_mr = Department::create(
[
'is_active' => true,
'name' => 'Chev-MR',
'organization_id' => $chev->id,
]
);
$dept_cmch_mr = Department::create(
[
'is_active' => false,
'name' => 'CMCH MR',
'organization_id' => $cmch->id,
]
);
$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);
$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,
]
);
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,
]
);
$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);
}
}

View File

@ -13,8 +13,6 @@ class UserSeeder extends Seeder
{
public function run(): void
{
// User::factory(10)->create();
$usr = User::factory()->create([
'first_name' => 'PACS Agent',
'display_name' => 'PACS Agent',
@ -24,75 +22,63 @@ public function run(): void
]);
$usr->assignRole(Role::SystemAgent);
$usr = User::factory()->create([
'first_name' => 'Administrator',
'display_name' => 'Admin',
'username' => 'admin',
'email' => 'admin@example.com',
'email_verified_at' => now(),
'phone' => '+8801733938582',
$orgs = Organization::pluck('id', 'name');
$depts = Department::pluck('id', 'name');
$skip_first = true;
$csv_file = fopen(base_path('database/data/users.csv'), 'r');
while (($data = fgetcsv($csv_file, 2 * 1024, ',')) !== false) {
if ($skip_first) {
$skip_first = false;
continue;
}
$data = array_trim_strings($data, true);
$role = Role::from(strtolower($data[8]));
$org_id = $data[9] ? $orgs[$data[9]] : null;
$dept_id = $data[10] ? $depts[$data[10]] : null;
$image = $data[11] ? 'signatures/' . $data[11] : null;
$user = User::create([
'is_active' => true,
'display_name' => $data[0],
'prefix' => $data[1],
'first_name' => $data[2],
'last_name' => $data[3],
'signature_text' => $data[4],
'signature_image_path' => $image,
'username' => $data[5],
'email' => strtolower($data[6]),
'phone' => (string) $data[7],
'email_verified_at' => $data[6] ? now() : null,
'password' => bcrypt('password'),
'organization_id' => $org_id,
'department_id' => $dept_id,
]);
$usr->assignRole(Role::Admin);
$user->assignRole($role->value);
}
fclose($csv_file);
$chevron = Organization::where('name', 'Chevron')->first();
$cmch = Organization::where('name', 'CMCH')->first();
$this->copySignatureImages();
}
$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),
]);
});
private function copySignatureImages()
{
$sourcePath = base_path('resources/report/signatures');
$dest = storage_path('app/public/signatures');
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),
]);
});
if (! is_dir($dest)) {
mkdir($dest, 0755, true);
}
User::factory(4)
->create([
'organization_id' => $cmch->id,
])
->each(function ($u, $key) {
$u->assignRole(Role::Technician);
$u->update([
'username' => sprintf('cmctech%d', $key + 1),
]);
});
$files = scandir($sourcePath);
foreach ($files as $file) {
if (in_array($file, ['.', '..'])) {
continue;
}
$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);
});
copy("{$sourcePath}/{$file}", "{$dest}/{$file}");
}
}
}