clqms-be/app/Database/Seeds/PatientSeeder.php

250 lines
7.3 KiB
PHP
Raw Normal View History

2025-12-17 15:19:55 +07:00
<?php
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
feat(routes): add container alias endpoint for ContainerDefController Added an alternative route alias 'container' that points to ContainerDefController, providing backward compatibility and flexibility in API endpoint naming. - Routes '/api/specimen/container' to ContainerDefController methods - Supports GET, GET with ID, POST, and PATCH operations - Existing '/api/specimen/containerdef' routes remain unchanged File: app/Config/Routes.php (+7 lines) --- refactor(seeds): update and standardize seed data across multiple seeders Improved data consistency and coverage in database seeds: AreaGeoSeeder.php: - Updated geographic area data for better regional coverage - Standardized data format and field values DummySeeder.php: - Refactored dummy data generation for test environments - Improved data integrity and relationships PatientSeeder.php: - Enhanced patient test data with more realistic scenarios - Updated patient demographic information - Improved test result distributions Total: 111 lines changed across seed files --- docs: add CLQMS project documentation - Added project documentation file: "prj_clinical laboratory quality management system_3a.docx" - Comprehensive project specification and requirements document --- test: remove deprecated TestDefSiteTest.php - Removed obsolete test file that is no longer needed - Test coverage consolidated into other test classes File: tests/feature/TestDef/TestDefSiteTest.php (-374 lines) --- Summary: - +58 lines added (routes, seeds, docs) - -434 lines removed (deprecated test file) - 6 files affected
2026-01-07 16:55:25 +07:00
class PatientSeeder extends Seeder
2025-12-17 15:19:55 +07:00
{
feat(routes): add container alias endpoint for ContainerDefController Added an alternative route alias 'container' that points to ContainerDefController, providing backward compatibility and flexibility in API endpoint naming. - Routes '/api/specimen/container' to ContainerDefController methods - Supports GET, GET with ID, POST, and PATCH operations - Existing '/api/specimen/containerdef' routes remain unchanged File: app/Config/Routes.php (+7 lines) --- refactor(seeds): update and standardize seed data across multiple seeders Improved data consistency and coverage in database seeds: AreaGeoSeeder.php: - Updated geographic area data for better regional coverage - Standardized data format and field values DummySeeder.php: - Refactored dummy data generation for test environments - Improved data integrity and relationships PatientSeeder.php: - Enhanced patient test data with more realistic scenarios - Updated patient demographic information - Improved test result distributions Total: 111 lines changed across seed files --- docs: add CLQMS project documentation - Added project documentation file: "prj_clinical laboratory quality management system_3a.docx" - Comprehensive project specification and requirements document --- test: remove deprecated TestDefSiteTest.php - Removed obsolete test file that is no longer needed - Test coverage consolidated into other test classes File: tests/feature/TestDef/TestDefSiteTest.php (-374 lines) --- Summary: - +58 lines added (routes, seeds, docs) - -434 lines removed (deprecated test file) - 6 files affected
2026-01-07 16:55:25 +07:00
public function run()
2025-12-17 15:19:55 +07:00
{
$now = date('Y-m-d H:i:s');
feat(routes): add container alias endpoint for ContainerDefController Added an alternative route alias 'container' that points to ContainerDefController, providing backward compatibility and flexibility in API endpoint naming. - Routes '/api/specimen/container' to ContainerDefController methods - Supports GET, GET with ID, POST, and PATCH operations - Existing '/api/specimen/containerdef' routes remain unchanged File: app/Config/Routes.php (+7 lines) --- refactor(seeds): update and standardize seed data across multiple seeders Improved data consistency and coverage in database seeds: AreaGeoSeeder.php: - Updated geographic area data for better regional coverage - Standardized data format and field values DummySeeder.php: - Refactored dummy data generation for test environments - Improved data integrity and relationships PatientSeeder.php: - Enhanced patient test data with more realistic scenarios - Updated patient demographic information - Improved test result distributions Total: 111 lines changed across seed files --- docs: add CLQMS project documentation - Added project documentation file: "prj_clinical laboratory quality management system_3a.docx" - Comprehensive project specification and requirements document --- test: remove deprecated TestDefSiteTest.php - Removed obsolete test file that is no longer needed - Test coverage consolidated into other test classes File: tests/feature/TestDef/TestDefSiteTest.php (-374 lines) --- Summary: - +58 lines added (routes, seeds, docs) - -434 lines removed (deprecated test file) - 6 files affected
2026-01-07 16:55:25 +07:00
2025-12-17 15:19:55 +07:00
// ========================================
// PATIENT - Main patient data
2025-12-17 15:19:55 +07:00
// ========================================
$patients = [
[
'InternalPID' => 1,
'PatientID' => 'SMAJ1',
'AlternatePID' => 'ALT001',
'Prefix' => 'Mr.',
'NameFirst' => 'Dummy',
'NameMiddle' => 'Test',
'NameMaiden' => null,
'NameLast' => 'Patient',
'Suffix' => 'S.Kom',
'NameAlias' => 'DummyTest',
'Sex' => '1',
2025-12-17 15:19:55 +07:00
'PlaceOfBirth' => 'Jakarta',
'Birthdate' => '1990-05-15',
'Street_1' => 'Jl. Sudirman No. 123',
'Street_2' => 'RT 01 RW 02',
'Street_3' => 'Kelurahan Menteng',
feat(routes): add container alias endpoint for ContainerDefController Added an alternative route alias 'container' that points to ContainerDefController, providing backward compatibility and flexibility in API endpoint naming. - Routes '/api/specimen/container' to ContainerDefController methods - Supports GET, GET with ID, POST, and PATCH operations - Existing '/api/specimen/containerdef' routes remain unchanged File: app/Config/Routes.php (+7 lines) --- refactor(seeds): update and standardize seed data across multiple seeders Improved data consistency and coverage in database seeds: AreaGeoSeeder.php: - Updated geographic area data for better regional coverage - Standardized data format and field values DummySeeder.php: - Refactored dummy data generation for test environments - Improved data integrity and relationships PatientSeeder.php: - Enhanced patient test data with more realistic scenarios - Updated patient demographic information - Improved test result distributions Total: 111 lines changed across seed files --- docs: add CLQMS project documentation - Added project documentation file: "prj_clinical laboratory quality management system_3a.docx" - Comprehensive project specification and requirements document --- test: remove deprecated TestDefSiteTest.php - Removed obsolete test file that is no longer needed - Test coverage consolidated into other test classes File: tests/feature/TestDef/TestDefSiteTest.php (-374 lines) --- Summary: - +58 lines added (routes, seeds, docs) - -434 lines removed (deprecated test file) - 6 files affected
2026-01-07 16:55:25 +07:00
'City' => '2',
'Province' => '1',
2025-12-17 15:19:55 +07:00
'ZIP' => '10110',
'EmailAddress1' => 'dummy1@test.com',
'EmailAddress2' => 'dummy1alt@test.com',
'Phone' => '02112345678',
'MobilePhone' => '081234567890',
'Custodian' => null,
'AccountNumber' => null,
'Country' => 'IDN',
'Race' => 'JAWA',
'MaritalStatus' => 'M',
'Religion' => 'ISLAM',
'Ethnic' => 'TNGHA',
2025-12-17 15:19:55 +07:00
'Citizenship' => 'WNI',
'DeathIndicator' => 'N',
2025-12-17 15:19:55 +07:00
'TimeOfDeath' => null,
'LinkTo' => null,
'CreateDate' => $now,
'DelDate' => null
],
[
'InternalPID' => 2,
'PatientID' => 'PAT002',
'AlternatePID' => 'ALT002',
'Prefix' => 'Mrs.',
'NameFirst' => 'Jane',
'NameMiddle' => null,
'NameMaiden' => 'Smith',
'NameLast' => 'Doe',
'Suffix' => null,
'NameAlias' => 'JaneDoe',
'Sex' => '2',
2025-12-17 15:19:55 +07:00
'PlaceOfBirth' => 'Bandung',
'Birthdate' => '1985-10-20',
'Street_1' => 'Jl. Asia Afrika No. 456',
'Street_2' => 'RT 03 RW 04',
'Street_3' => null,
'City' => '8',
'Province' => '7',
2025-12-17 15:19:55 +07:00
'ZIP' => '40112',
'EmailAddress1' => 'jane.doe@test.com',
'EmailAddress2' => null,
'Phone' => '02298765432',
'MobilePhone' => '089876543210',
'Custodian' => null,
'AccountNumber' => null,
'Country' => 'IDN',
'Race' => 'JAWA',
'MaritalStatus' => 'S',
'Religion' => 'KRSTN',
'Ethnic' => 'TNGHA',
2025-12-17 15:19:55 +07:00
'Citizenship' => 'WNI',
'DeathIndicator' => 'N',
2025-12-17 15:19:55 +07:00
'TimeOfDeath' => null,
'LinkTo' => null,
'CreateDate' => $now,
'DelDate' => null
],
[
'InternalPID' => 3,
'PatientID' => 'PAT003',
'AlternatePID' => 'ALT003',
'Prefix' => 'Mr.',
'NameFirst' => 'Budi',
'NameMiddle' => 'Santoso',
'NameMaiden' => null,
'NameLast' => 'Wijaya',
'Suffix' => null,
'NameAlias' => 'BudiW',
'Sex' => '1',
2025-12-17 15:19:55 +07:00
'PlaceOfBirth' => 'Surabaya',
'Birthdate' => '2000-01-01',
'Street_1' => 'Jl. Pahlawan No. 789',
'Street_2' => 'RT 05 RW 06',
'Street_3' => null,
'City' => '2',
'Province' => '1',
'ZIP' => '10220',
'EmailAddress1' => 'budi.wijaya@test.com',
'EmailAddress2' => null,
'Phone' => null,
'MobilePhone' => '081111222333',
'Custodian' => 1,
'AccountNumber' => null,
'Country' => 'IDN',
'Race' => 'JAWA',
'MaritalStatus' => 'S',
'Religion' => 'ISLAM',
'Ethnic' => 'TNGHA',
2025-12-17 15:19:55 +07:00
'Citizenship' => 'WNI',
'DeathIndicator' => 'N',
2025-12-17 15:19:55 +07:00
'TimeOfDeath' => null,
'LinkTo' => '1,2',
'CreateDate' => $now,
'DelDate' => null
],
];
foreach ($patients as $patient) {
$exists = $this->db->table('patient')->where('InternalPID', $patient['InternalPID'])->get()->getRow();
if (!$exists) {
$this->db->table('patient')->insert($patient);
}
}
echo "Patient data seeded (3 patients).\n";
// ========================================
// PATIDT - Patient Identifiers (KTP, etc.)
2025-12-17 15:19:55 +07:00
// ========================================
$patidts = [
[
'PatIdtID' => 1,
'InternalPID' => 1,
'IdentifierType' => 'KTP',
'Identifier' => '3171234567890001',
'EffectiveDate' => '2015-01-01',
'ExpirationDate' => '2025-01-01',
'CreateDate' => $now,
'DelDate' => null
],
[
'PatIdtID' => 2,
'InternalPID' => 3,
'IdentifierType' => 'SIM',
'Identifier' => '1234567890123456789',
'EffectiveDate' => '2020-06-15',
'ExpirationDate' => '2025-06-15',
'CreateDate' => $now,
'DelDate' => null
],
];
foreach ($patidts as $patidt) {
$exists = $this->db->table('patidt')->where('PatIdtID', $patidt['PatIdtID'])->get()->getRow();
if (!$exists) {
$this->db->table('patidt')->insert($patidt);
}
}
echo "PatIdt data seeded (2 identifiers).\n";
// ========================================
// PATATT - Patient Attachments
2025-12-17 15:19:55 +07:00
// ========================================
$patatts = [
[
'PatAttID' => 1,
'InternalPID' => 1,
'Address' => '/api/upload/patient1_photo1.jpg',
'UserID' => 1,
'CreateDate' => $now,
'DelDate' => null
],
[
'PatAttID' => 2,
'InternalPID' => 1,
'Address' => '/api/upload/patient1_ktp.jpg',
'UserID' => 1,
'CreateDate' => $now,
'DelDate' => null
],
[
'PatAttID' => 3,
'InternalPID' => 3,
'Address' => '/api/upload/patient3_photo.jpg',
'UserID' => 1,
'CreateDate' => $now,
'DelDate' => null
],
];
foreach ($patatts as $patatt) {
$exists = $this->db->table('patatt')->where('PatAttID', $patatt['PatAttID'])->get()->getRow();
if (!$exists) {
$this->db->table('patatt')->insert($patatt);
}
}
echo "PatAtt data seeded (3 attachments).\n";
// ========================================
// PATCOM - Patient Comments
2025-12-17 15:19:55 +07:00
// ========================================
$patcoms = [
[
'PatComID' => 1,
'InternalPID' => 1,
'Comment' => 'Test patient for unit testing. Has complete data including ID and attachments.',
'CreateDate' => $now,
'EndDate' => null
],
[
'PatComID' => 2,
'InternalPID' => 3,
'Comment' => 'Patient with custodian relationship to patient 1.',
'CreateDate' => $now,
'EndDate' => null
],
];
foreach ($patcoms as $patcom) {
$exists = $this->db->table('patcom')->where('PatComID', $patcom['PatComID'])->get()->getRow();
if (!$exists) {
$this->db->table('patcom')->insert($patcom);
}
}
echo "PatCom data seeded (2 comments).\n";
echo "\n✅ All Patient test data seeded successfully!\n";
echo "-------------------------------------------\n";
echo "Patients: 3 (IDs: 1, 2, 3)\n";
echo " - Patient 1: Full data with PatIdt, PatAtt (2), PatCom\n";
echo " - Patient 2: No PatIdt, PatAtt, PatCom (for null testing)\n";
echo " - Patient 3: Has PatIdt, PatAtt, PatCom, and Custodian link\n";
echo "-------------------------------------------\n";
}
}