2025-11-26 16:53:14 +07:00
< ? php
namespace App\Database\Seeds ;
use CodeIgniter\Database\Seeder ;
2026-01-13 16:48:43 +07:00
use App\Libraries\ValueSet ;
class TestSeeder extends Seeder
{
private function getKey ( string $lookupName , string $key ) : ? string
{
$data = ValueSet :: getRaw ( $lookupName );
if ( $data === null ) return null ;
foreach ( $data as $item ) {
if (( $item [ 'key' ] ? ? '' ) === $key ) {
return $item [ 'key' ];
}
}
return null ;
}
2025-11-26 16:53:14 +07:00
2026-01-13 16:48:43 +07:00
public function run ()
{
2025-11-26 16:53:14 +07:00
$now = date ( 'Y-m-d H:i:s' );
2025-12-16 13:43:06 +07:00
2026-01-13 16:48:43 +07:00
$tIDs = [];
2025-12-16 13:43:06 +07:00
// ========================================
// TEST TYPE - Actual Laboratory Tests
// ========================================
2026-02-19 13:20:24 +07:00
// Hematology Tests - Technical details merged into testdefsite
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'HB' , 'TestSiteName' => 'Hemoglobin' , 'TestType' => 'TEST' , 'Description' => '' , 'SeqScr' => '2' , 'SeqRpt' => '2' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'g/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'HB' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'HCT' , 'TestSiteName' => 'Hematocrit' , 'TestType' => 'TEST' , 'Description' => '' , 'SeqScr' => '3' , 'SeqRpt' => '3' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => '%' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'HCT' ] = $this -> db -> insertID ();
2025-11-26 16:53:14 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'RBC' , 'TestSiteName' => 'Red Blood Cell' , 'TestType' => 'TEST' , 'Description' => 'Eritrosit' , 'SeqScr' => '4' , 'SeqRpt' => '4' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'x10^6/uL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '2' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'RBC' ] = $this -> db -> insertID ();
2025-11-26 16:53:14 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'WBC' , 'TestSiteName' => 'White Blood Cell' , 'TestType' => 'TEST' , 'Description' => 'Leukosit' , 'SeqScr' => '5' , 'SeqRpt' => '5' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'x10^3/uL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '2' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'WBC' ] = $this -> db -> insertID ();
2025-11-26 16:53:14 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'PLT' , 'TestSiteName' => 'Platelet' , 'TestType' => 'TEST' , 'Description' => 'Trombosit' , 'SeqScr' => '6' , 'SeqRpt' => '6' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'x10^3/uL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'PLT' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'MCV' , 'TestSiteName' => 'MCV' , 'TestType' => 'TEST' , 'Description' => 'Mean Corpuscular Volume' , 'SeqScr' => '7' , 'SeqRpt' => '7' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'fL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'MCV' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'MCH' , 'TestSiteName' => 'MCH' , 'TestType' => 'TEST' , 'Description' => 'Mean Corpuscular Hemoglobin' , 'SeqScr' => '8' , 'SeqRpt' => '8' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'pg' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'MCH' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'MCHC' , 'TestSiteName' => 'MCHC' , 'TestType' => 'TEST' , 'Description' => 'Mean Corpuscular Hemoglobin Concentration' , 'SeqScr' => '9' , 'SeqRpt' => '9' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '1' , 'DepartmentID' => '1' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '500' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'g/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => 'CBC Analyzer' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'MCHC' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
// Chemistry Tests
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'GLU' , 'TestSiteName' => 'Glucose' , 'TestType' => 'TEST' , 'Description' => 'Glukosa Sewaktu' , 'SeqScr' => '11' , 'SeqRpt' => '11' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '0.0555' , 'Unit2' => 'mmol/L' , 'Decimal' => '0' , 'Method' => 'Hexokinase' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'GLU' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'CREA' , 'TestSiteName' => 'Creatinine' , 'TestType' => 'TEST' , 'Description' => 'Kreatinin' , 'SeqScr' => '12' , 'SeqRpt' => '12' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '88.4' , 'Unit2' => 'umol/L' , 'Decimal' => '2' , 'Method' => 'Enzymatic' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'CREA' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'UREA' , 'TestSiteName' => 'Blood Urea Nitrogen' , 'TestType' => 'TEST' , 'Description' => 'BUN' , 'SeqScr' => '13' , 'SeqRpt' => '13' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => 'Urease-GLDH' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'UREA' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'SGOT' , 'TestSiteName' => 'AST (SGOT)' , 'TestType' => 'TEST' , 'Description' => 'Aspartate Aminotransferase' , 'SeqScr' => '14' , 'SeqRpt' => '14' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'U/L' , 'Factor' => '0.017' , 'Unit2' => 'ukat/L' , 'Decimal' => '0' , 'Method' => 'IFCC' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'SGOT' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'SGPT' , 'TestSiteName' => 'ALT (SGPT)' , 'TestType' => 'TEST' , 'Description' => 'Alanine Aminotransferase' , 'SeqScr' => '15' , 'SeqRpt' => '15' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'U/L' , 'Factor' => '0.017' , 'Unit2' => 'ukat/L' , 'Decimal' => '0' , 'Method' => 'IFCC' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'SGPT' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'CHOL' , 'TestSiteName' => 'Total Cholesterol' , 'TestType' => 'TEST' , 'Description' => 'Kolesterol Total' , 'SeqScr' => '16' , 'SeqRpt' => '16' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => 'Enzymatic' , 'CreateDate' => " $now " ];
2025-11-26 16:53:14 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'CHOL' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'TG' , 'TestSiteName' => 'Triglycerides' , 'TestType' => 'TEST' , 'Description' => 'Trigliserida' , 'SeqScr' => '17' , 'SeqRpt' => '17' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => 'GPO-PAP' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'TG' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'HDL' , 'TestSiteName' => 'HDL Cholesterol' , 'TestType' => 'TEST' , 'Description' => 'Kolesterol HDL' , 'SeqScr' => '18' , 'SeqRpt' => '18' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => 'Direct' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'HDL' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'LDL' , 'TestSiteName' => 'LDL Cholesterol' , 'TestType' => 'TEST' , 'Description' => 'Kolesterol LDL' , 'SeqScr' => '19' , 'SeqRpt' => '19' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'ResultType' => 'NMRIC' , 'RefType' => 'RANGE' , 'VSet' => '' , 'ReqQty' => '300' , 'ReqQtyUnit' => 'uL' , 'Unit1' => 'mg/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => 'Direct' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'LDL' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
// ========================================
// PARAM TYPE - Parameters (non-lab values)
// ========================================
2026-02-19 13:20:24 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'HEIGHT' , 'TestSiteName' => 'Height' , 'TestType' => 'PARAM' , 'Description' => 'Tinggi Badan' , 'SeqScr' => '40' , 'SeqRpt' => '40' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '0' , 'CountStat' => '0' , 'DisciplineID' => '10' , 'DepartmentID' => '' , 'ResultType' => 'NMRIC' , 'RefType' => '' , 'VSet' => '' , 'ReqQty' => '' , 'ReqQtyUnit' => '' , 'Unit1' => 'cm' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => '' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'HEIGHT' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-19 13:20:24 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'WEIGHT' , 'TestSiteName' => 'Weight' , 'TestType' => 'PARAM' , 'Description' => 'Berat Badan' , 'SeqScr' => '41' , 'SeqRpt' => '41' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '0' , 'CountStat' => '0' , 'DisciplineID' => '10' , 'DepartmentID' => '' , 'ResultType' => 'NMRIC' , 'RefType' => '' , 'VSet' => '' , 'ReqQty' => '' , 'ReqQtyUnit' => '' , 'Unit1' => 'kg' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'Method' => '' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'WEIGHT' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-19 13:20:24 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'AGE' , 'TestSiteName' => 'Age' , 'TestType' => 'PARAM' , 'Description' => 'Usia' , 'SeqScr' => '42' , 'SeqRpt' => '42' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '0' , 'CountStat' => '0' , 'DisciplineID' => '10' , 'DepartmentID' => '' , 'ResultType' => 'NMRIC' , 'RefType' => '' , 'VSet' => '' , 'ReqQty' => '' , 'ReqQtyUnit' => '' , 'Unit1' => 'years' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => '' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'AGE' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-19 13:20:24 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'SYSTL' , 'TestSiteName' => 'Systolic BP' , 'TestType' => 'PARAM' , 'Description' => 'Tekanan Darah Sistolik' , 'SeqScr' => '43' , 'SeqRpt' => '43' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '0' , 'CountStat' => '0' , 'DisciplineID' => '10' , 'DepartmentID' => '' , 'ResultType' => 'NMRIC' , 'RefType' => '' , 'VSet' => '' , 'ReqQty' => '' , 'ReqQtyUnit' => '' , 'Unit1' => 'mmHg' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => '' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'SYSTL' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-19 13:20:24 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'DIASTL' , 'TestSiteName' => 'Diastolic BP' , 'TestType' => 'PARAM' , 'Description' => 'Tekanan Darah Diastolik' , 'SeqScr' => '44' , 'SeqRpt' => '44' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '0' , 'CountStat' => '0' , 'DisciplineID' => '10' , 'DepartmentID' => '' , 'ResultType' => 'NMRIC' , 'RefType' => '' , 'VSet' => '' , 'ReqQty' => '' , 'ReqQtyUnit' => '' , 'Unit1' => 'mmHg' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'Method' => '' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'DIASTL' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
// ========================================
// CALC TYPE - Calculated Tests
// ========================================
2026-01-13 16:48:43 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'BMI' , 'TestSiteName' => 'Body Mass Index' , 'TestType' => 'CALC' , 'Description' => 'Indeks Massa Tubuh - weight/(height^2)' , 'SeqScr' => '45' , 'SeqRpt' => '45' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '0' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'BMI' ] = $this -> db -> insertID ();
2026-02-23 05:11:23 +07:00
$data = [ 'TestSiteID' => $tIDs [ 'BMI' ], 'DisciplineID' => '10' , 'DepartmentID' => '' , 'FormulaInput' => 'WEIGHT,HEIGHT' , 'FormulaCode' => 'WEIGHT / ((HEIGHT/100) * (HEIGHT/100))' , 'RefType' => 'RANGE' , 'Unit1' => 'kg/m2' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '1' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefcal' ) -> insert ( $data );
2026-01-13 16:48:43 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'EGFR' , 'TestSiteName' => 'eGFR (CKD-EPI)' , 'TestType' => 'CALC' , 'Description' => 'Estimated Glomerular Filtration Rate' , 'SeqScr' => '20' , 'SeqRpt' => '20' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '0' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'EGFR' ] = $this -> db -> insertID ();
2026-02-23 05:11:23 +07:00
$data = [ 'TestSiteID' => $tIDs [ 'EGFR' ], 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'FormulaInput' => 'CREA,AGE,GENDER' , 'FormulaCode' => 'CKD_EPI(CREA,AGE,GENDER)' , 'RefType' => 'RANGE' , 'Unit1' => 'mL/min/1.73m2' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefcal' ) -> insert ( $data );
2026-01-13 16:48:43 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'LDLCALC' , 'TestSiteName' => 'LDL Cholesterol (Calculated)' , 'TestType' => 'CALC' , 'Description' => 'Friedewald formula: TC - HDL - (TG/5)' , 'SeqScr' => '21' , 'SeqRpt' => '21' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '0' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'LDLCALC' ] = $this -> db -> insertID ();
2026-02-23 05:11:23 +07:00
$data = [ 'TestSiteID' => $tIDs [ 'LDLCALC' ], 'DisciplineID' => '2' , 'DepartmentID' => '2' , 'FormulaInput' => 'CHOL,HDL,TG' , 'FormulaCode' => 'CHOL - HDL - (TG/5)' , 'RefType' => 'RANGE' , 'Unit1' => 'mg/dL' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '0' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefcal' ) -> insert ( $data );
// ========================================
// GROUP TYPE - Panel/Profile Tests
// ========================================
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'CBC' , 'TestSiteName' => 'Complete Blood Count' , 'TestType' => 'GROUP' , 'Description' => 'Darah Lengkap' , 'SeqScr' => '50' , 'SeqRpt' => '50' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'ResultType' => 'NORES' , 'RefType' => 'NOREF' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'CBC' ] = $this -> db -> insertID ();
$this -> db -> table ( 'testdefgrp' ) -> insertBatch ([
2025-12-29 12:55:31 +07:00
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'HB' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'HCT' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'RBC' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'WBC' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'PLT' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'MCV' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'MCH' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'CBC' ], 'Member' => $tIDs [ 'MCHC' ], 'CreateDate' => " $now " ]
2025-12-17 10:06:05 +07:00
]);
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'LIPID' , 'TestSiteName' => 'Lipid Profile' , 'TestType' => 'GROUP' , 'Description' => 'Profil Lipid' , 'SeqScr' => '51' , 'SeqRpt' => '51' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'ResultType' => 'NORES' , 'RefType' => 'NOREF' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'LIPID' ] = $this -> db -> insertID ();
$this -> db -> table ( 'testdefgrp' ) -> insertBatch ([
2025-12-29 12:55:31 +07:00
[ 'TestSiteID' => $tIDs [ 'LIPID' ], 'Member' => $tIDs [ 'CHOL' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'LIPID' ], 'Member' => $tIDs [ 'TG' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'LIPID' ], 'Member' => $tIDs [ 'HDL' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'LIPID' ], 'Member' => $tIDs [ 'LDL' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'LIPID' ], 'Member' => $tIDs [ 'LDLCALC' ], 'CreateDate' => " $now " ]
2025-12-17 10:06:05 +07:00
]);
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'LFT' , 'TestSiteName' => 'Liver Function Test' , 'TestType' => 'GROUP' , 'Description' => 'Fungsi Hati' , 'SeqScr' => '52' , 'SeqRpt' => '52' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'ResultType' => 'NORES' , 'RefType' => 'NOREF' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'LFT' ] = $this -> db -> insertID ();
$this -> db -> table ( 'testdefgrp' ) -> insertBatch ([
2025-12-29 12:55:31 +07:00
[ 'TestSiteID' => $tIDs [ 'LFT' ], 'Member' => $tIDs [ 'SGOT' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'LFT' ], 'Member' => $tIDs [ 'SGPT' ], 'CreateDate' => " $now " ]
2025-12-17 10:06:05 +07:00
]);
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'RFT' , 'TestSiteName' => 'Renal Function Test' , 'TestType' => 'GROUP' , 'Description' => 'Fungsi Ginjal' , 'SeqScr' => '53' , 'SeqRpt' => '53' , 'IndentLeft' => '0' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'ResultType' => 'NORES' , 'RefType' => 'NOREF' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'RFT' ] = $this -> db -> insertID ();
$this -> db -> table ( 'testdefgrp' ) -> insertBatch ([
2025-12-29 12:55:31 +07:00
[ 'TestSiteID' => $tIDs [ 'RFT' ], 'Member' => $tIDs [ 'UREA' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'RFT' ], 'Member' => $tIDs [ 'CREA' ], 'CreateDate' => " $now " ],
[ 'TestSiteID' => $tIDs [ 'RFT' ], 'Member' => $tIDs [ 'EGFR' ], 'CreateDate' => " $now " ]
2025-12-17 10:06:05 +07:00
]);
2025-12-16 13:43:06 +07:00
// Urinalysis Tests (with valueset result type)
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'UCOLOR' , 'TestSiteName' => 'Urine Color' , 'TestType' => 'TEST' , 'Description' => 'Warna Urine' , 'SeqScr' => '31' , 'SeqRpt' => '31' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '4' , 'DepartmentID' => '4' , 'ResultType' => 'VSET' , 'RefType' => 'VSET' , 'VSet' => '1001' , 'ReqQty' => '10' , 'ReqQtyUnit' => 'mL' , 'Unit1' => '' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '' , 'Method' => 'Visual' , 'CreateDate' => " $now " ];
2025-12-16 13:43:06 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'UCOLOR' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'UGLUC' , 'TestSiteName' => 'Urine Glucose' , 'TestType' => 'TEST' , 'Description' => 'Glukosa Urine' , 'SeqScr' => '32' , 'SeqRpt' => '32' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '4' , 'DepartmentID' => '4' , 'ResultType' => 'VSET' , 'RefType' => 'VSET' , 'VSet' => '1002' , 'ReqQty' => '10' , 'ReqQtyUnit' => 'mL' , 'Unit1' => '' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '' , 'Method' => 'Dipstick' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'UGLUC' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$data = [ 'SiteID' => '1' , 'TestSiteCode' => 'UPROT' , 'TestSiteName' => 'Urine Protein' , 'TestType' => 'TEST' , 'Description' => 'Protein Urine' , 'SeqScr' => '33' , 'SeqRpt' => '33' , 'IndentLeft' => '1' , 'VisibleScr' => '1' , 'VisibleRpt' => '1' , 'CountStat' => '1' , 'DisciplineID' => '4' , 'DepartmentID' => '4' , 'ResultType' => 'VSET' , 'RefType' => 'VSET' , 'VSet' => '1003' , 'ReqQty' => '10' , 'ReqQtyUnit' => 'mL' , 'Unit1' => '' , 'Factor' => '' , 'Unit2' => '' , 'Decimal' => '' , 'Method' => 'Dipstick' , 'CreateDate' => " $now " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'UPROT' ] = $this -> db -> insertID ();
2025-12-16 13:43:06 +07:00
2026-02-20 13:47:47 +07:00
$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 " ];
2025-11-27 14:15:10 +07:00
$this -> db -> table ( 'testdefsite' ) -> insert ( $data );
2025-12-17 10:06:05 +07:00
$tIDs [ 'PH' ] = $this -> db -> insertID ();
2026-02-24 06:11:18 +07:00
// ========================================
// 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 );
2026-01-13 16:48:43 +07:00
}
2026-01-05 07:21:12 +07:00
}