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

83 lines
6.0 KiB
PHP
Raw Normal View History

2025-09-11 11:09:04 +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 DummySeeder extends Seeder
{
public function run()
{
2025-10-15 16:08:52 +07:00
$now = date('Y-m-d H:i:s');
$yesterday = date('Y-m-d H:i:s', strtotime('-1 day'));
$twoDaysAgo = date('Y-m-d H:i:s', strtotime('-2 days'));
$threeDaysAgo = date('Y-m-d H:i:s', strtotime('-3 days'));
2025-12-17 15:19:55 +07:00
// users
2025-12-22 16:54:19 +07:00
// Password: 'password' for all users (bcrypt hash)
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
$passwordHash = password_hash('123', PASSWORD_BCRYPT);
$data = [
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
['id' => 1, 'role_id' => 1, 'username' => 'lisfse', 'password' => $passwordHash],
['id' => 2, 'role_id' => 1, 'username' => 'tes', 'password' => $passwordHash]
];
$this->db->table('users')->insertBatch($data);
// patvisit - 4 visits for 3 patients
// Visit 1: Patient 1 - Discharged (complete history)
// Visit 2: Patient 1 - Discharged (complete history)
// Visit 3: Patient 2 - Active (no discharge yet)
// Visit 4: Patient 3 - Discharged (complete history)
2025-12-17 15:19:55 +07:00
$data = [
['InternalPVID' => 1, "PVID" => "DV00001", "InternalPID" => 1, "EpisodeID" => 1, "CreateDate" => "$threeDaysAgo"],
['InternalPVID' => 2, "PVID" => "DV00002", "InternalPID" => 1, "EpisodeID" => 1, "CreateDate" => "$twoDaysAgo"],
['InternalPVID' => 3, "PVID" => "DV00003", "InternalPID" => 2, "EpisodeID" => 2, "CreateDate" => "$yesterday"],
['InternalPVID' => 4, "PVID" => "DV00004", "InternalPID" => 3, "EpisodeID" => 3, "CreateDate" => "$threeDaysAgo"],
2025-11-13 13:49:24 +07:00
];
$this->db->table('patvisit')->insertBatch($data);
// patvisitadt - ADT history for each visit
// A04: Register, A01: Admit, A02: Transfer, A03: Discharge
2025-12-17 15:19:55 +07:00
$data = [
// Visit 1 (InternalPVID=1) - Discharged: ER -> Ward A -> Ward B -> Discharge
['InternalPVID' => 1, "ADTCode" => "A04", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => null, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => "$threeDaysAgo", "EndDate" => null],
['InternalPVID' => 1, "ADTCode" => "A01", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => null, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => date('Y-m-d H:i:s', strtotime('-2 days +2 hours')), "EndDate" => null],
['InternalPVID' => 1, "ADTCode" => "A02", "LocationID" => 2, "AttDoc" => 1, "RefDoc" => 2, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => date('Y-m-d H:i:s', strtotime('-2 days +6 hours')), "EndDate" => null],
['InternalPVID' => 1, "ADTCode" => "A02", "LocationID" => 2, "AttDoc" => 2, "RefDoc" => 2, "AdmDoc" => 1, "CnsDoc" => 2, "CreateDate" => date('Y-m-d H:i:s', strtotime('-1 day +8 hours')), "EndDate" => null],
['InternalPVID' => 1, "ADTCode" => "A03", "LocationID" => null, "AttDoc" => 2, "RefDoc" => 2, "AdmDoc" => 1, "CnsDoc" => 2, "CreateDate" => date('Y-m-d H:i:s', strtotime('-1 day +12 hours')), "EndDate" => null],
// Visit 2 (InternalPVID=2) - Discharged: ER -> ICU -> Discharge
['InternalPVID' => 2, "ADTCode" => "A04", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => null, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => "$twoDaysAgo", "EndDate" => null],
['InternalPVID' => 2, "ADTCode" => "A01", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => null, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => date('Y-m-d H:i:s', strtotime('-1 day +1 hour')), "EndDate" => null],
['InternalPVID' => 2, "ADTCode" => "A02", "LocationID" => 2, "AttDoc" => 2, "RefDoc" => 1, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => date('Y-m-d H:i:s', strtotime('-1 day +4 hours')), "EndDate" => null],
['InternalPVID' => 2, "ADTCode" => "A03", "LocationID" => null, "AttDoc" => 2, "RefDoc" => 1, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => "$yesterday", "EndDate" => null],
// Visit 3 (InternalPVID=3) - ACTIVE: ER -> Ward A (no discharge - still admitted)
['InternalPVID' => 3, "ADTCode" => "A04", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => null, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => "$yesterday", "EndDate" => null],
['InternalPVID' => 3, "ADTCode" => "A01", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => null, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => date('Y-m-d H:i:s', strtotime('-1 day +2 hours')), "EndDate" => null],
['InternalPVID' => 3, "ADTCode" => "A02", "LocationID" => 2, "AttDoc" => 2, "RefDoc" => 2, "AdmDoc" => 1, "CnsDoc" => null, "CreateDate" => "$now", "EndDate" => null],
// Note: No A03 (discharge) - this visit is still active
// Visit 4 (InternalPVID=4) - Discharged: Direct admit -> Ward B -> Discharge
['InternalPVID' => 4, "ADTCode" => "A04", "LocationID" => 2, "AttDoc" => 2, "RefDoc" => null, "AdmDoc" => 2, "CnsDoc" => null, "CreateDate" => "$threeDaysAgo", "EndDate" => null],
['InternalPVID' => 4, "ADTCode" => "A01", "LocationID" => 2, "AttDoc" => 2, "RefDoc" => null, "AdmDoc" => 2, "CnsDoc" => null, "CreateDate" => date('Y-m-d H:i:s', strtotime('-2 days +3 hours')), "EndDate" => null],
['InternalPVID' => 4, "ADTCode" => "A02", "LocationID" => 1, "AttDoc" => 1, "RefDoc" => 2, "AdmDoc" => 2, "CnsDoc" => 1, "CreateDate" => date('Y-m-d H:i:s', strtotime('-2 days +12 hours')), "EndDate" => null],
['InternalPVID' => 4, "ADTCode" => "A03", "LocationID" => null, "AttDoc" => 1, "RefDoc" => 2, "AdmDoc" => 2, "CnsDoc" => 1, "CreateDate" => date('Y-m-d H:i:s', strtotime('-1 day +6 hours')), "EndDate" => null],
2025-11-13 13:49:24 +07:00
];
$this->db->table('patvisitadt')->insertBatch($data);
echo "✅ Dummy ADT data seeded successfully!\n";
echo "-------------------------------------------\n";
echo "Visits created: 4\n";
echo " - Visit 1 (DV00001): Complete ADT history with discharge\n";
echo " - Visit 2 (DV00002): Complete ADT history with discharge\n";
echo " - Visit 3 (DV00003): ACTIVE (no discharge yet)\n";
echo " - Visit 4 (DV00004): Complete ADT history with discharge\n";
echo "-------------------------------------------\n";
echo "ADT Records: 18 total\n";
echo " - A04 (Register): 4 records\n";
echo " - A01 (Admit): 4 records\n";
echo " - A02 (Transfer): 6 records\n";
echo " - A03 (Discharge): 3 records\n";
echo "-------------------------------------------\n";
2025-09-11 11:09:04 +07:00
}
}