From 3a30629e159d67a151fa05f8f55566eb50666b94 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Tue, 24 Feb 2026 06:11:18 +0700 Subject: [PATCH] feat: add urine workstations and test specimen mappings to seeders --- app/Database/Seeds/OrganizationSeeder.php | 2 + app/Database/Seeds/TestSeeder.php | 167 ++++++++++++++++++++++ 2 files changed, 169 insertions(+) diff --git a/app/Database/Seeds/OrganizationSeeder.php b/app/Database/Seeds/OrganizationSeeder.php index 79ff1f7..afd08eb 100644 --- a/app/Database/Seeds/OrganizationSeeder.php +++ b/app/Database/Seeds/OrganizationSeeder.php @@ -60,6 +60,8 @@ class OrganizationSeeder extends Seeder ['WorkstationID' => '5', 'DepartmentID' => '3', 'WorkstationCode' => 'CMAN', 'WorkstationName' => 'Kimia Manual', 'Type' => '0', 'LinkTo' => '', 'Enable' => '1', 'CreateDate' => "$now"], ['WorkstationID' => '6', 'DepartmentID' => '4', 'WorkstationCode' => 'IAUTO', 'WorkstationName' => 'Imunologi Auto', 'Type' => '0', 'LinkTo' => '', 'Enable' => '1', 'CreateDate' => "$now"], ['WorkstationID' => '7', 'DepartmentID' => '4', 'WorkstationCode' => 'IMAN', 'WorkstationName' => 'Imunologi Manual', 'Type' => '0', 'LinkTo' => '', 'Enable' => '1', 'CreateDate' => "$now"], + ['WorkstationID' => '8', 'DepartmentID' => '6', 'WorkstationCode' => 'UAUTO', 'WorkstationName' => 'Urin Auto', 'Type' => '0', 'LinkTo' => '', 'Enable' => '1', 'CreateDate' => "$now"], + ['WorkstationID' => '9', 'DepartmentID' => '6', 'WorkstationCode' => 'UMAN', 'WorkstationName' => 'Urin Manual', 'Type' => '0', 'LinkTo' => '', 'Enable' => '1', 'CreateDate' => "$now"], ]; $this->db->table('workstation')->insertBatch($data); } diff --git a/app/Database/Seeds/TestSeeder.php b/app/Database/Seeds/TestSeeder.php index bf45ce8..e4543f1 100644 --- a/app/Database/Seeds/TestSeeder.php +++ b/app/Database/Seeds/TestSeeder.php @@ -203,5 +203,172 @@ class TestSeeder extends Seeder $data = ['SiteID' => '1', 'TestSiteCode' => 'PH', 'TestSiteName' => 'Urine pH', 'TestType' => 'TEST', 'Description' => 'pH Urine', 'SeqScr' => '34', 'SeqRpt' => '34', 'IndentLeft' => '1', 'VisibleScr' => '1', 'VisibleRpt' => '1', 'CountStat' => '1', 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => 'NMRIC', 'RefType' => 'RANGE', 'VSet' => '', 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['PH'] = $this->db->insertID(); + + // ======================================== + // TEST MAP - Specimen Mapping + // Maps tests to workstations and containers + // ======================================== + + // Get container IDs (inserted by SpecimenSeeder in order) + // ConCode order: 1, 11, 12, 13, 14, 15, 16, 20, 101, 150, 200, 290, 295, 900 + $conSST = 1; // SST (Serum Separator Tube) + $conEDTA = 9; // EDTA - Hematology + $conCitrate = 10; // Citrate - Koagulasi + $conPotUrin = 12; // Pot Urin + $conUrine = 13; // Urine Container + + // Workstation IDs from OrganizationSeeder + $wsHAuto = 1; // Hematologi Auto + $wsCAuto = 3; // Kimia Auto + $wsIAuto = 6; // Imunologi Auto + $wsUAuto = 8; // Urin Auto + + $testMaps = []; + + // Hematology tests → HAUTO workstation + EDTA container + $hematologyTests = ['HB', 'HCT', 'RBC', 'WBC', 'PLT', 'MCV', 'MCH', 'MCHC']; + foreach ($hematologyTests as $testCode) { + $testMaps[] = [ + 'TestSiteID' => $tIDs[$testCode], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => $testCode, + 'HostTestName' => $testCode, + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsHAuto, + 'ConDefID' => $conEDTA, + 'ClientTestCode' => $testCode, + 'ClientTestName' => $testCode, + 'CreateDate' => $now + ]; + } + + // Chemistry tests → CAUTO workstation + SST container + $chemistryTests = ['GLU', 'CREA', 'UREA', 'SGOT', 'SGPT', 'CHOL', 'TG', 'HDL', 'LDL']; + foreach ($chemistryTests as $testCode) { + $testMaps[] = [ + 'TestSiteID' => $tIDs[$testCode], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => $testCode, + 'HostTestName' => $testCode, + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsCAuto, + 'ConDefID' => $conSST, + 'ClientTestCode' => $testCode, + 'ClientTestName' => $testCode, + 'CreateDate' => $now + ]; + } + + // Calculated chemistry tests → CAUTO workstation + SST container (inherited from parents) + $calcChemistryTests = ['EGFR', 'LDLCALC']; + foreach ($calcChemistryTests as $testCode) { + $testMaps[] = [ + 'TestSiteID' => $tIDs[$testCode], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => $testCode, + 'HostTestName' => $testCode, + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsCAuto, + 'ConDefID' => $conSST, + 'ClientTestCode' => $testCode, + 'ClientTestName' => $testCode, + 'CreateDate' => $now + ]; + } + + // Urinalysis tests → UAUTO workstation + Pot Urin container + $urineTests = ['UCOLOR', 'UGLUC', 'UPROT', 'PH']; + foreach ($urineTests as $testCode) { + $testMaps[] = [ + 'TestSiteID' => $tIDs[$testCode], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => $testCode, + 'HostTestName' => $testCode, + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsUAuto, + 'ConDefID' => $conPotUrin, + 'ClientTestCode' => $testCode, + 'ClientTestName' => $testCode, + 'CreateDate' => $now + ]; + } + + // Panel/Group tests - map to primary container (EDTA for CBC, SST for LIPID/LFT/RFT) + $testMaps[] = [ + 'TestSiteID' => $tIDs['CBC'], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => 'CBC', + 'HostTestName' => 'CBC', + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsHAuto, + 'ConDefID' => $conEDTA, + 'ClientTestCode' => 'CBC', + 'ClientTestName' => 'CBC', + 'CreateDate' => $now + ]; + + $testMaps[] = [ + 'TestSiteID' => $tIDs['LIPID'], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => 'LIPID', + 'HostTestName' => 'LIPID', + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsCAuto, + 'ConDefID' => $conSST, + 'ClientTestCode' => 'LIPID', + 'ClientTestName' => 'LIPID', + 'CreateDate' => $now + ]; + + $testMaps[] = [ + 'TestSiteID' => $tIDs['LFT'], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => 'LFT', + 'HostTestName' => 'LFT', + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsCAuto, + 'ConDefID' => $conSST, + 'ClientTestCode' => 'LFT', + 'ClientTestName' => 'LFT', + 'CreateDate' => $now + ]; + + $testMaps[] = [ + 'TestSiteID' => $tIDs['RFT'], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => 'RFT', + 'HostTestName' => 'RFT', + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsCAuto, + 'ConDefID' => $conSST, + 'ClientTestCode' => 'RFT', + 'ClientTestName' => 'RFT', + 'CreateDate' => $now + ]; + + // BMI parameter - no container needed (calculated from parameters) + $testMaps[] = [ + 'TestSiteID' => $tIDs['BMI'], + 'HostType' => 'SITE', + 'HostID' => '1', + 'HostTestCode' => 'BMI', + 'HostTestName' => 'BMI', + 'ClientType' => 'WORKSTATION', + 'ClientID' => (string)$wsCAuto, + 'ConDefID' => null, + 'ClientTestCode' => 'BMI', + 'ClientTestName' => 'BMI', + 'CreateDate' => $now + ]; + + $this->db->table('testmap')->insertBatch($testMaps); } }