New-Thanasoft/thanasoft-back/database/seeders/ThanatopractitionerSeeder.php
2025-11-05 17:09:12 +03:00

278 lines
11 KiB
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Thanatopractitioner;
use App\Models\PractitionerDocument;
class ThanatopractitionerSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// First, we need to create employees that will become thanatopractitioners
$employees = [
[
'first_name' => 'Jean-Baptiste',
'last_name' => 'Ramanana',
'email' => 'jb.ramanana@thanasoft.com',
'phone' => '+261341235001',
'job_title' => 'Thanatopracteur Senior',
'hire_date' => '2020-08-01',
'active' => true,
],
[
'first_name' => 'Marie',
'last_name' => 'Andriamanantsoa',
'email' => 'marie.andriamanantsoa@thanasoft.com',
'phone' => '+261341235003',
'job_title' => 'Thanatopracteur Spécialisé',
'hire_date' => '2019-07-01',
'active' => true,
],
[
'first_name' => 'Paul',
'last_name' => 'Rakotomanga',
'email' => 'paul.rakotomanga@thanasoft.com',
'phone' => '+261341235005',
'job_title' => 'Thanatopracteur Junior',
'hire_date' => '2021-11-01',
'active' => true,
],
[
'first_name' => 'Sophie',
'last_name' => 'Andriatiana',
'email' => 'sophie.andriatiana@thanasoft.com',
'phone' => '+261341235007',
'job_title' => 'Thanatopracteur Expert',
'hire_date' => '2018-06-01',
'active' => true,
],
[
'first_name' => 'David',
'last_name' => 'Randriamahandry',
'email' => 'david.randriamahandry@thanasoft.com',
'phone' => '+261341235009',
'job_title' => 'Thanatopracteur',
'hire_date' => '2022-03-01',
'active' => true,
],
[
'first_name' => 'Lina',
'last_name' => 'Ramaniraka',
'email' => 'lina.ramaniraka@thanasoft.com',
'phone' => '+261341235011',
'job_title' => 'Thanatopracteur',
'hire_date' => '2023-10-01',
'active' => true,
],
[
'first_name' => 'Marc',
'last_name' => 'Andriamatsiroa',
'email' => 'marc.andriamatsiroa@thanasoft.com',
'phone' => '+261341235013',
'job_title' => 'Thanatopracteur Chief',
'hire_date' => '2018-01-01',
'active' => true,
],
[
'first_name' => 'Julie',
'last_name' => 'Rakotomalala',
'email' => 'julie.rakotomalala@thanasoft.com',
'phone' => '+261341235015',
'job_title' => 'Thanatopracteur Assistant',
'hire_date' => '2024-05-01',
'active' => true,
],
];
// Create employees and get their IDs
$employeeIds = [];
foreach ($employees as $employeeData) {
$employee = \App\Models\Employee::create($employeeData);
$employeeIds[] = $employee->id;
}
// Create thanatopractitioners linked to the employees
$thanatopractitioners = [
[
'employee_id' => $employeeIds[0],
'diploma_number' => 'TP-DIPL-001-2020',
'diploma_date' => '2020-06-15',
'authorization_number' => 'TP-AUTH-001-2020',
'authorization_issue_date' => '2020-07-01',
'authorization_expiry_date' => '2025-07-01',
'notes' => 'Thanatopracteur senior spécialisé en thanatopraxie générale et reconstructive.',
],
[
'employee_id' => $employeeIds[1],
'diploma_number' => 'TP-DIPL-002-2019',
'diploma_date' => '2019-05-10',
'authorization_number' => 'TP-AUTH-002-2019',
'authorization_issue_date' => '2019-06-01',
'authorization_expiry_date' => '2024-06-01',
'notes' => 'Spécialiste en thanatopraxie pédiatrique avec 5 ans d\'expérience.',
],
[
'employee_id' => $employeeIds[2],
'diploma_number' => 'TP-DIPL-003-2021',
'diploma_date' => '2021-09-22',
'authorization_number' => 'TP-AUTH-003-2021',
'authorization_issue_date' => '2021-10-01',
'authorization_expiry_date' => '2026-10-01',
'notes' => 'Thanatopracteur junior spécialisé en thanatopraxie esthétique.',
],
[
'employee_id' => $employeeIds[3],
'diploma_number' => 'TP-DIPL-004-2018',
'diploma_date' => '2018-04-05',
'authorization_number' => 'TP-AUTH-004-2018',
'authorization_issue_date' => '2018-05-01',
'authorization_expiry_date' => '2023-05-01',
'notes' => 'Expert en thanatopraxie reconstructive et histopathologie.',
],
[
'employee_id' => $employeeIds[4],
'diploma_number' => 'TP-DIPL-005-2022',
'diploma_date' => '2022-01-18',
'authorization_number' => 'TP-AUTH-005-2022',
'authorization_issue_date' => '2022-02-01',
'authorization_expiry_date' => '2027-02-01',
'notes' => 'Spécialiste en thanatopraxie traditionnelle et culturelle.',
],
[
'employee_id' => $employeeIds[5],
'diploma_number' => 'TP-DIPL-006-2023',
'diploma_date' => '2023-08-12',
'authorization_number' => 'TP-AUTH-006-2023',
'authorization_issue_date' => '2023-09-01',
'authorization_expiry_date' => '2028-09-01',
'notes' => 'Thanatopracteur nouvellement certifiée, spécialisée en techniques modernes.',
],
[
'employee_id' => $employeeIds[6],
'diploma_number' => 'TP-DIPL-007-2017',
'diploma_date' => '2017-11-30',
'authorization_number' => 'TP-AUTH-007-2017',
'authorization_issue_date' => '2018-01-01',
'authorization_expiry_date' => '2023-01-01',
'notes' => 'Responsable principal des thanatopracteurs, expert en histopathologie.',
],
[
'employee_id' => $employeeIds[7],
'diploma_number' => 'TP-DIPL-008-2024',
'diploma_date' => '2024-03-25',
'authorization_number' => 'TP-AUTH-008-2024',
'authorization_issue_date' => '2024-04-01',
'authorization_expiry_date' => '2029-04-01',
'notes' => 'Thanatopracteur assistante, en formation continue en thanatopraxie assistée.',
],
];
foreach ($thanatopractitioners as $thanatopractitionerData) {
$thanatopractitioner = Thanatopractitioner::create($thanatopractitionerData);
// Create some practitioner documents for each thanatopractitioner
$this->createPractitionerDocuments($thanatopractitioner);
}
// Create inactive thanatopractitioners for testing
$inactiveEmployee1 = \App\Models\Employee::create([
'first_name' => 'Ancien',
'last_name' => 'Thanatopracteur',
'email' => 'ancien.thanato@thanasoft.com',
'phone' => '+261341235017',
'job_title' => 'Ancien Thanatopracteur',
'hire_date' => '2015-03-01',
'active' => false,
]);
$inactive1 = Thanatopractitioner::create([
'employee_id' => $inactiveEmployee1->id,
'diploma_number' => 'TP-DIPL-TEST-001',
'diploma_date' => '2015-01-01',
'authorization_number' => 'TP-AUTH-TEST-001',
'authorization_issue_date' => '2015-02-01',
'authorization_expiry_date' => '2020-02-01',
'notes' => 'Thanatopracteur inactif, autorisation expirée.',
]);
$this->createPractitionerDocuments($inactive1);
$inactiveEmployee2 = \App\Models\Employee::create([
'first_name' => 'Thanatopracteur',
'last_name' => 'Suspendu',
'email' => 'thanato.suspendu@thanasoft.com',
'phone' => '+261341235019',
'job_title' => 'Thanatopracteur Suspendu',
'hire_date' => '2018-08-01',
'active' => false,
]);
$inactive2 = Thanatopractitioner::create([
'employee_id' => $inactiveEmployee2->id,
'diploma_number' => 'TP-DIPL-TEST-002',
'diploma_date' => '2018-06-01',
'authorization_number' => 'TP-AUTH-TEST-002',
'authorization_issue_date' => '2018-07-01',
'authorization_expiry_date' => '2023-07-01',
'notes' => 'Thanatopracteur temporairement suspendu.',
]);
$this->createPractitionerDocuments($inactive2);
}
/**
* Create practitioner documents for a thanatopractitioner.
*/
private function createPractitionerDocuments(Thanatopractitioner $thanatopractitioner): void
{
$documents = [
[
'doc_type' => 'diploma',
'issue_date' => $thanatopractitioner->diploma_date,
'expiry_date' => date('Y-m-d', strtotime('+5 years', strtotime($thanatopractitioner->diploma_date))),
'status' => 'active',
],
[
'doc_type' => 'certification',
'issue_date' => date('Y-01-01'),
'expiry_date' => date('Y-12-31'),
'status' => 'active',
],
];
// Add specialized documents based on notes content
if (strpos($thanatopractitioner->notes, 'reconstructive') !== false ||
strpos($thanatopractitioner->notes, 'histopathologie') !== false) {
$documents[] = [
'doc_type' => 'specialization',
'issue_date' => $thanatopractitioner->diploma_date,
'expiry_date' => date('Y-m-d', strtotime('+3 years', strtotime($thanatopractitioner->diploma_date))),
'status' => 'active',
];
}
// Add expired documents for inactive thanatopractitioners
$employee = $thanatopractitioner->employee;
if ($employee->active === false) {
$documents[] = [
'doc_type' => 'expired_certificate',
'issue_date' => '2020-01-01',
'expiry_date' => '2023-01-01',
'status' => 'expired',
];
}
foreach ($documents as $documentData) {
PractitionerDocument::create(array_merge($documentData, [
'practitioner_id' => $thanatopractitioner->id,
'file_id' => null, // Will be set when files table is implemented
]));
}
}
}