From 118d490bbdbf0e189f3de04bc1f425a1e6cdc8a6 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Mon, 29 Dec 2025 12:55:31 +0700 Subject: [PATCH] refactor: update TestSeeder to use dynamic ValueSet lookups - Implemented dynamic VID retrieval from ValueSetModel for all test definitions - Aligned ResultType, RefType, and SpcType with the valueset table - Updated sample data for Hematology, Chemistry, and Urinalysis tests - Ensured consistency between ValueSetSeeder and TestSeeder data --- app/Controllers/Contact/Contact.php | 8 +- app/Controllers/Contact/MedicalSpecialty.php | 8 +- app/Controllers/Contact/Occupation.php | 8 +- app/Controllers/Counter.php | 8 +- app/Controllers/Location.php | 8 +- app/Controllers/OrderTest.php | 4 +- app/Controllers/Organization/Account.php | 8 +- app/Controllers/Organization/Department.php | 9 +- app/Controllers/Organization/Discipline.php | 8 +- app/Controllers/Organization/Site.php | 8 +- app/Controllers/Organization/Workstation.php | 8 +- app/Controllers/PatVisit.php | 7 +- app/Controllers/Patient/Patient.php | 6 +- app/Controllers/Specimen/ContainerDef.php | 7 +- app/Controllers/Specimen/Specimen.php | 7 +- .../Specimen/SpecimenCollection.php | 7 +- app/Controllers/Specimen/SpecimenPrep.php | 7 +- app/Controllers/Specimen/SpecimenStatus.php | 7 +- app/Controllers/Test/TestMap.php | 6 +- app/Controllers/Tests.php | 6 +- app/Controllers/ValueSet/ValueSet.php | 8 +- app/Controllers/ValueSet/ValueSetDef.php | 6 +- app/Database/Seeds/TestSeeder.php | 94 +++++++-------- app/Database/Seeds/ValueSetSeeder.php | 56 ++++++--- app/Models/Location/LocationModel.php | 6 +- app/Models/Organization/AccountModel.php | 6 +- app/Models/Organization/DepartmentModel.php | 6 +- app/Models/Organization/SiteModel.php | 6 +- app/Models/Organization/WorkstationModel.php | 6 +- app/Models/PatVisit/PatVisitModel.php | 6 +- app/Models/Specimen/ContainerDefModel.php | 6 +- check_db.php | 18 +++ sanity.php | 3 + tests/README.md | 13 ++ tests/UniformShowTest_README.md | 33 ++++++ tests/feature/SimpleTest.php | 16 +++ tests/feature/UniformShowTest.php | 111 ++++++++++++++++++ 37 files changed, 386 insertions(+), 159 deletions(-) create mode 100644 check_db.php create mode 100644 sanity.php create mode 100644 tests/UniformShowTest_README.md create mode 100644 tests/feature/SimpleTest.php create mode 100644 tests/feature/UniformShowTest.php diff --git a/app/Controllers/Contact/Contact.php b/app/Controllers/Contact/Contact.php index 3b9ae67..1771b74 100644 --- a/app/Controllers/Contact/Contact.php +++ b/app/Controllers/Contact/Contact.php @@ -33,13 +33,13 @@ class Contact extends BaseController { public function show($ContactID = null) { $model = new ContactModel(); - $rows = $model->getContactWithDetail($ContactID); + $row = $model->getContactWithDetail($ContactID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function delete() { diff --git a/app/Controllers/Contact/MedicalSpecialty.php b/app/Controllers/Contact/MedicalSpecialty.php index 659a465..a8e8730 100644 --- a/app/Controllers/Contact/MedicalSpecialty.php +++ b/app/Controllers/Contact/MedicalSpecialty.php @@ -32,11 +32,11 @@ class MedicalSpecialty extends BaseController { public function show($SpecialtyID = null) { $model = new MedicalSpecialtyModel(); - $rows = $model->find($SpecialtyID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data."], 200); + $row = $model->find($SpecialtyID); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function create() { diff --git a/app/Controllers/Contact/Occupation.php b/app/Controllers/Contact/Occupation.php index 239e142..1bc9087 100644 --- a/app/Controllers/Contact/Occupation.php +++ b/app/Controllers/Contact/Occupation.php @@ -32,11 +32,11 @@ class Occupation extends BaseController { public function show($OccupationID = null) { $model = new OccupationModel(); - $rows = $model->find($OccupationID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data."], 200); + $row = $model->find($OccupationID); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function create() { diff --git a/app/Controllers/Counter.php b/app/Controllers/Counter.php index dbc04a8..9ca0721 100644 --- a/app/Controllers/Counter.php +++ b/app/Controllers/Counter.php @@ -24,13 +24,13 @@ class Counter extends BaseController { } public function show($CounterID = null) { - $rows = $this->model->find($CounterID); + $row = $this->model->find($CounterID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "No Data.", 'data' => [] ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "No Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200); } public function create() { diff --git a/app/Controllers/Location.php b/app/Controllers/Location.php index 1bcfa13..e922d5b 100644 --- a/app/Controllers/Location.php +++ b/app/Controllers/Location.php @@ -31,12 +31,12 @@ class Location extends BaseController { } public function show($LocationID = null) { - $rows = $this->model->getLocation($LocationID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + $row = $this->model->getLocation($LocationID); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function create() { diff --git a/app/Controllers/OrderTest.php b/app/Controllers/OrderTest.php index 9a672dc..140b926 100644 --- a/app/Controllers/OrderTest.php +++ b/app/Controllers/OrderTest.php @@ -34,13 +34,13 @@ class OrderTest extends Controller { } public function show($OrderID = null) { - $row=$this->db->table('ordertest')->select("*")->where('OrderID=', $OrderID)->get()->getResultArray(); + $row=$this->db->table('ordertest')->select("*")->where('OrderID', $OrderID)->get()->getRowArray(); if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "Data not found.", - 'data' => [], + 'data' => null, ], 200); } diff --git a/app/Controllers/Organization/Account.php b/app/Controllers/Organization/Account.php index 1bdf83b..68cc3f1 100644 --- a/app/Controllers/Organization/Account.php +++ b/app/Controllers/Organization/Account.php @@ -34,13 +34,13 @@ class Account extends BaseController { public function show($AccountID = null) { //$rows = $this->model->where('AccountID', $AccountID)->findAll(); - $rows = $this->model->getAccount($AccountID); + $row = $this->model->getAccount($AccountID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function delete() { diff --git a/app/Controllers/Organization/Department.php b/app/Controllers/Organization/Department.php index ae3a43c..3cbe5f2 100644 --- a/app/Controllers/Organization/Department.php +++ b/app/Controllers/Organization/Department.php @@ -32,13 +32,12 @@ class Department extends BaseController { } public function show($DepartmentID = null) { - //$rows = $this->model->where('DepartmentID', $DepartmentID)->findAll(); - $rows = $this->model->getDepartment($DepartmentID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + $row = $this->model->getDepartment($DepartmentID); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function delete() { diff --git a/app/Controllers/Organization/Discipline.php b/app/Controllers/Organization/Discipline.php index 6bcb314..e2cbb7c 100644 --- a/app/Controllers/Organization/Discipline.php +++ b/app/Controllers/Organization/Discipline.php @@ -32,13 +32,13 @@ class Discipline extends BaseController { } public function show($DisciplineID = null) { - $rows = $this->model->where('DisciplineID', $DisciplineID)->findAll(); + $row = $this->model->where('DisciplineID', $DisciplineID)->first(); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function delete() { diff --git a/app/Controllers/Organization/Site.php b/app/Controllers/Organization/Site.php index 03ccc19..37ecf0b 100644 --- a/app/Controllers/Organization/Site.php +++ b/app/Controllers/Organization/Site.php @@ -33,13 +33,13 @@ class Site extends BaseController { public function show($SiteID = null) { //$rows = $this->model->where('SiteID', $SiteID)->findAll(); - $rows = $this->model->getSite($SiteID); + $row = $this->model->getSite($SiteID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function delete() { diff --git a/app/Controllers/Organization/Workstation.php b/app/Controllers/Organization/Workstation.php index 153505e..078c0c5 100644 --- a/app/Controllers/Organization/Workstation.php +++ b/app/Controllers/Organization/Workstation.php @@ -32,13 +32,13 @@ class Workstation extends BaseController { } public function show($WorkstationID = null) { - $rows = $this->model->getWorkstation($WorkstationID); + $row = $this->model->getWorkstation($WorkstationID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $row ], 200); } public function delete() { diff --git a/app/Controllers/PatVisit.php b/app/Controllers/PatVisit.php index f0916da..201a4fa 100644 --- a/app/Controllers/PatVisit.php +++ b/app/Controllers/PatVisit.php @@ -18,9 +18,10 @@ class PatVisit extends BaseController { public function show($PVID = null) { try { $row = $this->model->show($PVID); - if($row == []) { $message = "data not found"; } - else { $message = "data found"; } - return $this->respond([ 'status' => 'success', 'message'=> $message, 'data' => $row ], 200); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200); + } + return $this->respond([ 'status' => 'success', 'message'=> "data found", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Something went wrong '.$e->getMessage()); } diff --git a/app/Controllers/Patient/Patient.php b/app/Controllers/Patient/Patient.php index ae3fb87..4f56469 100644 --- a/app/Controllers/Patient/Patient.php +++ b/app/Controllers/Patient/Patient.php @@ -66,9 +66,9 @@ class Patient extends Controller { public function show($InternalPID = null) { try { - $rows = $this->model->getPatient($InternalPID); - if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found." ], 200); } - return $this->respond([ 'status' => 'success', 'message' => "data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->getPatient($InternalPID); + if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "data not found.", 'data' => null ], 200); } + return $this->respond([ 'status' => 'success', 'message' => "data fetched successfully", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Something went wrong: ' . $e->getMessage()); } diff --git a/app/Controllers/Specimen/ContainerDef.php b/app/Controllers/Specimen/ContainerDef.php index 0c4271d..0bb8c7b 100644 --- a/app/Controllers/Specimen/ContainerDef.php +++ b/app/Controllers/Specimen/ContainerDef.php @@ -37,8 +37,11 @@ class ContainerDef extends BaseController { public function show($ConDefID) { try { - $rows = $this->model->getContainer($ConDefID); - return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->getContainer($ConDefID); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200); + } + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Exception : '.$e->getMessage()); } diff --git a/app/Controllers/Specimen/Specimen.php b/app/Controllers/Specimen/Specimen.php index b7ff7ee..8fb08ee 100644 --- a/app/Controllers/Specimen/Specimen.php +++ b/app/Controllers/Specimen/Specimen.php @@ -30,8 +30,11 @@ class Specimen extends BaseController { public function show($id) { try { - $rows = $this->model->where('SID',$id)->findAll(); - return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->where('SID',$id)->first(); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200); + } + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Exception : '.$e->getMessage()); } diff --git a/app/Controllers/Specimen/SpecimenCollection.php b/app/Controllers/Specimen/SpecimenCollection.php index edcf5af..2ca2962 100644 --- a/app/Controllers/Specimen/SpecimenCollection.php +++ b/app/Controllers/Specimen/SpecimenCollection.php @@ -30,8 +30,11 @@ class SpecimenCollection extends BaseController { public function show($id) { try { - $rows = $this->model->where('SpcColID', $id)->findAll(); - return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->where('SpcColID', $id)->first(); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200); + } + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Exception : '.$e->getMessage()); } diff --git a/app/Controllers/Specimen/SpecimenPrep.php b/app/Controllers/Specimen/SpecimenPrep.php index ac9608c..f694a3d 100644 --- a/app/Controllers/Specimen/SpecimenPrep.php +++ b/app/Controllers/Specimen/SpecimenPrep.php @@ -30,8 +30,11 @@ class SpecimenPrep extends BaseController { public function show($id) { try { - $rows = $this->model->where('SpcPrpID', $id)->findAll(); - return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->where('SpcPrpID', $id)->first(); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200); + } + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Exception : '.$e->getMessage()); } diff --git a/app/Controllers/Specimen/SpecimenStatus.php b/app/Controllers/Specimen/SpecimenStatus.php index f94f263..58bd570 100644 --- a/app/Controllers/Specimen/SpecimenStatus.php +++ b/app/Controllers/Specimen/SpecimenStatus.php @@ -30,8 +30,11 @@ class ContainerDef extends BaseController { public function show($id) { try { - $rows = $this->model->where('SpcStaID', $id)->findAll(); - return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->where('SpcStaID', $id)->first(); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message'=> "data not found", 'data' => null ], 200); + } + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Exception : '.$e->getMessage()); } diff --git a/app/Controllers/Test/TestMap.php b/app/Controllers/Test/TestMap.php index 718600f..3ad323a 100644 --- a/app/Controllers/Test/TestMap.php +++ b/app/Controllers/Test/TestMap.php @@ -24,9 +24,9 @@ class TestMap extends BaseController { } public function show($id = null) { - $rows = $this->model->where('TestMapID',$id)->findAll(); - if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->where('TestMapID',$id)->first(); + if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200); } public function create() { diff --git a/app/Controllers/Tests.php b/app/Controllers/Tests.php index e9c6311..5569dfc 100644 --- a/app/Controllers/Tests.php +++ b/app/Controllers/Tests.php @@ -39,9 +39,9 @@ class Tests extends BaseController { public function show($id = null) { if (!$id) return $this->failValidationErrors('ID is required'); - $rows = $this->model->getTest($id); - if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->getTest($id); + if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200); } public function create() { diff --git a/app/Controllers/ValueSet/ValueSet.php b/app/Controllers/ValueSet/ValueSet.php index f0f753b..e2b072a 100644 --- a/app/Controllers/ValueSet/ValueSet.php +++ b/app/Controllers/ValueSet/ValueSet.php @@ -29,11 +29,11 @@ class ValueSet extends BaseController { } public function show($VID = null) { - $rows = $this->model->getValueSet($VID); - if (empty($rows)) { - return $this->respond([ 'status' => 'success', 'message' => "ValueSet with ID $VID not found.", 'data' => [] ], 200); + $row = $this->model->getValueSet($VID); + if (empty($row)) { + return $this->respond([ 'status' => 'success', 'message' => "ValueSet with ID $VID not found.", 'data' => null ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows], 200); + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row], 200); } public function showByValueSetDef($VSetID = null) { diff --git a/app/Controllers/ValueSet/ValueSetDef.php b/app/Controllers/ValueSet/ValueSetDef.php index a20a7f5..48d00b2 100644 --- a/app/Controllers/ValueSet/ValueSetDef.php +++ b/app/Controllers/ValueSet/ValueSetDef.php @@ -29,9 +29,9 @@ class ValueSetDef extends BaseController { } public function show($VSetID = null) { - $rows = $this->model->find($VSetID); - if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + $row = $this->model->find($VSetID); + if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); } + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $row ], 200); } public function create() { diff --git a/app/Database/Seeds/TestSeeder.php b/app/Database/Seeds/TestSeeder.php index c66fde0..5c5a920 100644 --- a/app/Database/Seeds/TestSeeder.php +++ b/app/Database/Seeds/TestSeeder.php @@ -25,104 +25,104 @@ class TestSeeder extends Seeder { $data = ['SiteID' => '1', 'TestSiteCode' => 'HB', 'TestSiteName' => 'Hemoglobin', 'TestType' => $vs[27]['TEST'], 'Description' => '', 'SeqScr' => '2', 'SeqRpt' => '2', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['HB'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['HB'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'g/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['HB'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'g/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'HCT', 'TestSiteName' => 'Hematocrit', 'TestType' => $vs[27]['TEST'], 'Description' => '', 'SeqScr' => '3', 'SeqRpt' => '3', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['HCT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['HCT'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => '%', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['HCT'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => '%', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'RBC', 'TestSiteName' => 'Red Blood Cell', 'TestType' => $vs[27]['TEST'], 'Description' => 'Eritrosit', 'SeqScr' => '4', 'SeqRpt' => '4', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['RBC'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['RBC'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'x10^6/uL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '2', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['RBC'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'x10^6/uL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '2', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'WBC', 'TestSiteName' => 'White Blood Cell', 'TestType' => $vs[27]['TEST'], 'Description' => 'Leukosit', 'SeqScr' => '5', 'SeqRpt' => '5', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['WBC'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['WBC'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'x10^3/uL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '2', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['WBC'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'x10^3/uL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '2', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'PLT', 'TestSiteName' => 'Platelet', 'TestType' => $vs[27]['TEST'], 'Description' => 'Trombosit', 'SeqScr' => '6', 'SeqRpt' => '6', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['PLT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['PLT'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'x10^3/uL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['PLT'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'x10^3/uL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'MCV', 'TestSiteName' => 'MCV', 'TestType' => $vs[27]['TEST'], 'Description' => 'Mean Corpuscular Volume', 'SeqScr' => '7', 'SeqRpt' => '7', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['MCV'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['MCV'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'fL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['MCV'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'fL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'MCH', 'TestSiteName' => 'MCH', 'TestType' => $vs[27]['TEST'], 'Description' => 'Mean Corpuscular Hemoglobin', 'SeqScr' => '8', 'SeqRpt' => '8', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['MCH'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['MCH'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'pg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['MCH'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'pg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'MCHC', 'TestSiteName' => 'MCHC', 'TestType' => $vs[27]['TEST'], 'Description' => 'Mean Corpuscular Hemoglobin Concentration', 'SeqScr' => '9', 'SeqRpt' => '9', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['MCHC'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['MCHC'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'g/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['MCHC'], 'DisciplineID' => '1', 'DepartmentID' => '1', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['BLD'], 'ReqQty' => '500', 'ReqQtyUnit' => 'uL', 'Unit1' => 'g/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'CBC Analyzer', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); // Chemistry Tests $data = ['SiteID' => '1', 'TestSiteCode' => 'GLU', 'TestSiteName' => 'Glucose', 'TestType' => $vs[27]['TEST'], 'Description' => 'Glukosa Sewaktu', 'SeqScr' => '11', 'SeqRpt' => '11', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['GLU'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['GLU'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '0.0555', 'Unit2' => 'mmol/L', 'Decimal' => '0', 'Method' => 'Hexokinase', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['GLU'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '0.0555', 'Unit2' => 'mmol/L', 'Decimal' => '0', 'Method' => 'Hexokinase', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'CREA', 'TestSiteName' => 'Creatinine', 'TestType' => $vs[27]['TEST'], 'Description' => 'Kreatinin', 'SeqScr' => '12', 'SeqRpt' => '12', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['CREA'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['CREA'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '88.4', 'Unit2' => 'umol/L', 'Decimal' => '2', 'Method' => 'Enzymatic', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['CREA'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '88.4', 'Unit2' => 'umol/L', 'Decimal' => '2', 'Method' => 'Enzymatic', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'UREA', 'TestSiteName' => 'Blood Urea Nitrogen', 'TestType' => $vs[27]['TEST'], 'Description' => 'BUN', 'SeqScr' => '13', 'SeqRpt' => '13', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['UREA'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['UREA'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'Urease-GLDH', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['UREA'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'Urease-GLDH', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'SGOT', 'TestSiteName' => 'AST (SGOT)', 'TestType' => $vs[27]['TEST'], 'Description' => 'Aspartate Aminotransferase', 'SeqScr' => '14', 'SeqRpt' => '14', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['SGOT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['SGOT'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'U/L', 'Factor' => '0.017', 'Unit2' => 'ukat/L', 'Decimal' => '0', 'Method' => 'IFCC', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['SGOT'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'U/L', 'Factor' => '0.017', 'Unit2' => 'ukat/L', 'Decimal' => '0', 'Method' => 'IFCC', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'SGPT', 'TestSiteName' => 'ALT (SGPT)', 'TestType' => $vs[27]['TEST'], 'Description' => 'Alanine Aminotransferase', 'SeqScr' => '15', 'SeqRpt' => '15', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['SGPT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['SGPT'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'U/L', 'Factor' => '0.017', 'Unit2' => 'ukat/L', 'Decimal' => '0', 'Method' => 'IFCC', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['SGPT'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'U/L', 'Factor' => '0.017', 'Unit2' => 'ukat/L', 'Decimal' => '0', 'Method' => 'IFCC', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'CHOL', 'TestSiteName' => 'Total Cholesterol', 'TestType' => $vs[27]['TEST'], 'Description' => 'Kolesterol Total', 'SeqScr' => '16', 'SeqRpt' => '16', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['CHOL'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['CHOL'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['THOLD'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'Enzymatic', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['CHOL'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'Enzymatic', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'TG', 'TestSiteName' => 'Triglycerides', 'TestType' => $vs[27]['TEST'], 'Description' => 'Trigliserida', 'SeqScr' => '17', 'SeqRpt' => '17', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['TG'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['TG'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['THOLD'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'GPO-PAP', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['TG'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'GPO-PAP', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'HDL', 'TestSiteName' => 'HDL Cholesterol', 'TestType' => $vs[27]['TEST'], 'Description' => 'Kolesterol HDL', 'SeqScr' => '18', 'SeqRpt' => '18', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['HDL'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['HDL'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['THOLD'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'Direct', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['HDL'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'Direct', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'LDL', 'TestSiteName' => 'LDL Cholesterol', 'TestType' => $vs[27]['TEST'], 'Description' => 'Kolesterol LDL', 'SeqScr' => '19', 'SeqRpt' => '19', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['LDL'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['LDL'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['THOLD'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'Direct', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['LDL'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['SER'], 'ReqQty' => '300', 'ReqQtyUnit' => 'uL', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => 'Direct', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); // ======================================== @@ -131,31 +131,31 @@ class TestSeeder extends Seeder { $data = ['SiteID' => '1', 'TestSiteCode' => 'HEIGHT', 'TestSiteName' => 'Height', 'TestType' => $vs[27]['PARAM'], 'Description' => 'Tinggi Badan', 'SeqScr' => '40', 'SeqRpt' => '40', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][0], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['HEIGHT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['HEIGHT'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'cm', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['HEIGHT'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'cm', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'WEIGHT', 'TestSiteName' => 'Weight', 'TestType' => $vs[27]['PARAM'], 'Description' => 'Berat Badan', 'SeqScr' => '41', 'SeqRpt' => '41', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][0], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['WEIGHT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['WEIGHT'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'kg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => '', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['WEIGHT'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'kg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => '', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'AGE', 'TestSiteName' => 'Age', 'TestType' => $vs[27]['PARAM'], 'Description' => 'Usia', 'SeqScr' => '42', 'SeqRpt' => '42', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][0], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['AGE'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['AGE'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'years', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['AGE'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'years', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'SYSTL', 'TestSiteName' => 'Systolic BP', 'TestType' => $vs[27]['PARAM'], 'Description' => 'Tekanan Darah Sistolik', 'SeqScr' => '43', 'SeqRpt' => '43', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][0], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['SYSTL'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['SYSTL'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'mmHg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['SYSTL'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'mmHg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'DIASTL', 'TestSiteName' => 'Diastolic BP', 'TestType' => $vs[27]['PARAM'], 'Description' => 'Tekanan Darah Diastolik', 'SeqScr' => '44', 'SeqRpt' => '44', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][0], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['DIASTL'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['DIASTL'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'mmHg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['DIASTL'], 'DisciplineID' => '10', 'DepartmentID' => '', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => '', 'VSet' => '', 'SpcType' => '', 'ReqQty' => '', 'ReqQtyUnit' => '', 'Unit1' => 'mmHg', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'Method' => '', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); // ======================================== @@ -164,19 +164,19 @@ class TestSeeder extends Seeder { $data = ['SiteID' => '1', 'TestSiteCode' => 'BMI', 'TestSiteName' => 'Body Mass Index', 'TestType' => $vs[27]['CALC'], 'Description' => 'Indeks Massa Tubuh - weight/(height^2)', 'SeqScr' => '45', 'SeqRpt' => '45', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['BMI'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['BMI'], 'DisciplineID' => '10', 'DepartmentID' => '', 'FormulaInput' => 'WEIGHT,HEIGHT', 'FormulaCode' => 'WEIGHT / ((HEIGHT/100) * (HEIGHT/100))', 'Unit1' => 'kg/m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['BMI'], 'DisciplineID' => '10', 'DepartmentID' => '', 'FormulaInput' => 'WEIGHT,HEIGHT', 'FormulaCode' => 'WEIGHT / ((HEIGHT/100) * (HEIGHT/100))', 'Unit1' => 'kg/m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'CreateDate' => "$now"]; $this->db->table('testdefcal')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'EGFR', 'TestSiteName' => 'eGFR (CKD-EPI)', 'TestType' => $vs[27]['CALC'], 'Description' => 'Estimated Glomerular Filtration Rate', 'SeqScr' => '20', 'SeqRpt' => '20', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['EGFR'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['EGFR'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CREA,AGE,GENDER', 'FormulaCode' => 'CKD_EPI(CREA,AGE,GENDER)', 'Unit1' => 'mL/min/1.73m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['EGFR'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CREA,AGE,GENDER', 'FormulaCode' => 'CKD_EPI(CREA,AGE,GENDER)', 'Unit1' => 'mL/min/1.73m2', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefcal')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'LDLCALC', 'TestSiteName' => 'LDL Cholesterol (Calculated)', 'TestType' => $vs[27]['CALC'], 'Description' => 'Friedewald formula: TC - HDL - (TG/5)', 'SeqScr' => '21', 'SeqRpt' => '21', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][0], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['LDLCALC'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['LDLCALC'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CHOL,HDL,TG', 'FormulaCode' => 'CHOL - HDL - (TG/5)', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['LDLCALC'], 'DisciplineID' => '2', 'DepartmentID' => '2', 'FormulaInput' => 'CHOL,HDL,TG', 'FormulaCode' => 'CHOL - HDL - (TG/5)', 'Unit1' => 'mg/dL', 'Factor' => '', 'Unit2' => '', 'Decimal' => '0', 'CreateDate' => "$now"]; $this->db->table('testdefcal')->insert($data); // ======================================== @@ -186,67 +186,67 @@ class TestSeeder extends Seeder { $this->db->table('testdefsite')->insert($data); $tIDs['CBC'] = $this->db->insertID(); $this->db->table('testdefgrp')->insertBatch([ - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['HB'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['HCT'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['RBC'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['WBC'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['PLT'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['MCV'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['MCH'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['CBC'], 'Member' => $tIDs['MCHC'], 'CreateDate' => "$now"] + ['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"] ]); $data = ['SiteID' => '1', 'TestSiteCode' => 'LIPID', 'TestSiteName' => 'Lipid Profile', 'TestType' => $vs[27]['GROUP'], 'Description' => 'Profil Lipid', 'SeqScr' => '51', 'SeqRpt' => '51', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['LIPID'] = $this->db->insertID(); $this->db->table('testdefgrp')->insertBatch([ - ['SiteID' => '1', 'TestSiteID' => $tIDs['LIPID'], 'Member' => $tIDs['CHOL'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['LIPID'], 'Member' => $tIDs['TG'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['LIPID'], 'Member' => $tIDs['HDL'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['LIPID'], 'Member' => $tIDs['LDL'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['LIPID'], 'Member' => $tIDs['LDLCALC'], 'CreateDate' => "$now"] + ['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"] ]); $data = ['SiteID' => '1', 'TestSiteCode' => 'LFT', 'TestSiteName' => 'Liver Function Test', 'TestType' => $vs[27]['GROUP'], 'Description' => 'Fungsi Hati', 'SeqScr' => '52', 'SeqRpt' => '52', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['LFT'] = $this->db->insertID(); $this->db->table('testdefgrp')->insertBatch([ - ['SiteID' => '1', 'TestSiteID' => $tIDs['LFT'], 'Member' => $tIDs['SGOT'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['LFT'], 'Member' => $tIDs['SGPT'], 'CreateDate' => "$now"] + ['TestSiteID' => $tIDs['LFT'], 'Member' => $tIDs['SGOT'], 'CreateDate' => "$now"], + ['TestSiteID' => $tIDs['LFT'], 'Member' => $tIDs['SGPT'], 'CreateDate' => "$now"] ]); $data = ['SiteID' => '1', 'TestSiteCode' => 'RFT', 'TestSiteName' => 'Renal Function Test', 'TestType' => $vs[27]['GROUP'], 'Description' => 'Fungsi Ginjal', 'SeqScr' => '53', 'SeqRpt' => '53', 'IndentLeft' => '0', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['RFT'] = $this->db->insertID(); $this->db->table('testdefgrp')->insertBatch([ - ['SiteID' => '1', 'TestSiteID' => $tIDs['RFT'], 'Member' => $tIDs['UREA'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['RFT'], 'Member' => $tIDs['CREA'], 'CreateDate' => "$now"], - ['SiteID' => '1', 'TestSiteID' => $tIDs['RFT'], 'Member' => $tIDs['EGFR'], 'CreateDate' => "$now"] + ['TestSiteID' => $tIDs['RFT'], 'Member' => $tIDs['UREA'], 'CreateDate' => "$now"], + ['TestSiteID' => $tIDs['RFT'], 'Member' => $tIDs['CREA'], 'CreateDate' => "$now"], + ['TestSiteID' => $tIDs['RFT'], 'Member' => $tIDs['EGFR'], 'CreateDate' => "$now"] ]); // Urinalysis Tests (with valueset result type) $data = ['SiteID' => '1', 'TestSiteCode' => 'UCOLOR', 'TestSiteName' => 'Urine Color', 'TestType' => $vs[27]['TEST'], 'Description' => 'Warna Urine', 'SeqScr' => '31', 'SeqRpt' => '31', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['UCOLOR'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['UCOLOR'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['VSET'], 'RefType' => $vs[44]['VSET'], 'VSet' => '1001', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '', 'Method' => 'Visual', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['UCOLOR'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['VSET'], 'RefType' => $vs[44]['TEXT'], 'VSet' => '1001', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '', 'Method' => 'Visual', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'UGLUC', 'TestSiteName' => 'Urine Glucose', 'TestType' => $vs[27]['TEST'], 'Description' => 'Glukosa Urine', 'SeqScr' => '32', 'SeqRpt' => '32', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['UGLUC'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['UGLUC'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['VSET'], 'RefType' => $vs[44]['VSET'], 'VSet' => '1002', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['UGLUC'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['VSET'], 'RefType' => $vs[44]['TEXT'], 'VSet' => '1002', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'UPROT', 'TestSiteName' => 'Urine Protein', 'TestType' => $vs[27]['TEST'], 'Description' => 'Protein Urine', 'SeqScr' => '33', 'SeqRpt' => '33', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['UPROT'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['UPROT'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['VSET'], 'RefType' => $vs[44]['VSET'], 'VSet' => '1003', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['UPROT'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['VSET'], 'RefType' => $vs[44]['TEXT'], 'VSet' => '1003', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); $data = ['SiteID' => '1', 'TestSiteCode' => 'PH', 'TestSiteName' => 'Urine pH', 'TestType' => $vs[27]['TEST'], 'Description' => 'pH Urine', 'SeqScr' => '34', 'SeqRpt' => '34', 'IndentLeft' => '1', 'VisibleScr' => $vs[2][1], 'VisibleRpt' => $vs[2][1], 'CountStat' => $vs[2][1], 'CreateDate' => "$now"]; $this->db->table('testdefsite')->insert($data); $tIDs['PH'] = $this->db->insertID(); - $data = ['SiteID' => '1', 'TestSiteID' => $tIDs['PH'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['RANGE'], 'VSet' => '', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; + $data = ['TestSiteID' => $tIDs['PH'], 'DisciplineID' => '4', 'DepartmentID' => '4', 'ResultType' => $vs[43]['NMRIC'], 'RefType' => $vs[44]['NMRC'], 'VSet' => '', 'SpcType' => $vs[15]['UR'], 'ReqQty' => '10', 'ReqQtyUnit' => 'mL', 'Unit1' => '', 'Factor' => '', 'Unit2' => '', 'Decimal' => '1', 'Method' => 'Dipstick', 'CreateDate' => "$now"]; $this->db->table('testdeftech')->insert($data); } diff --git a/app/Database/Seeds/ValueSetSeeder.php b/app/Database/Seeds/ValueSetSeeder.php index e22f77b..548cb77 100644 --- a/app/Database/Seeds/ValueSetSeeder.php +++ b/app/Database/Seeds/ValueSetSeeder.php @@ -99,7 +99,7 @@ class ValueSetSeeder extends Seeder { ['VSetID' => 15,'VOrder' => 2, 'VValue' =>'BLDA', 'VDesc' => "Blood arterial", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 15,'VOrder' => 3, 'VValue' =>'BLDCO', 'VDesc' => "Cord blood", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 15,'VOrder' => 4, 'VValue' =>'FBLOOD', 'VDesc' => "Blood, Fetal", 'VCategory' => 1, 'CreateDate' => "$now"], - ['VSetID' => 15,'VOrder' => 5, 'VValue' =>'FBLOOD', 'VDesc' => "Blood, Fetal", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 15,'VOrder' => 5, 'VValue' =>'CSF', 'VDesc' => "Cerebral spinal fluid", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 15,'VOrder' => 6, 'VValue' =>'WB', 'VDesc' => "Blood, Whole", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 15,'VOrder' => 7, 'VValue' =>'BBL', 'VDesc' => "Blood bag", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 15,'VOrder' => 8, 'VValue' =>'SER', 'VDesc' => "Serum", 'VCategory' => 1, 'CreateDate' => "$now"], @@ -306,33 +306,46 @@ class ValueSetSeeder extends Seeder { ['VSetID' => 43,'VOrder' => 2, 'VValue' =>'RANGE', 'VDesc' => "Range", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 43,'VOrder' => 3, 'VValue' =>'TEXT', 'VDesc' => "Text", 'VCategory' => 1, 'CreateDate' => "$now"], ['VSetID' => 43,'VOrder' => 4, 'VValue' =>'VSET', 'VDesc' => "Value set", 'VCategory' => 1, 'CreateDate' => "$now"], - ['VSetID' => 44,'VOrder' => 1, 'VValue' =>'RANGE', 'VDesc' => "Range", 'VCategory' => 1, 'CreateDate' => "$now"], - ['VSetID' => 44,'VOrder' => 2, 'VValue' =>'THOLD', 'VDesc' => "Threshold", 'VCategory' => 1, 'CreateDate' => "$now"], - ['VSetID' => 44,'VOrder' => 3, 'VValue' =>'VSET', 'VDesc' => "Value Set", 'VCategory' => 1, 'CreateDate' => "$now"], - ['VSetID' => 44,'VOrder' => 4, 'VValue' =>'TEXT', 'VDesc' => "Text.", 'VCategory' => 1, 'CreateDate' => "$now"] + ['VSetID' => 44,'VOrder' => 1, 'VValue' =>'NMRC', 'VDesc' => "Numeric", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 44,'VOrder' => 2, 'VValue' =>'TEXT', 'VDesc' => "Text", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 45,'VOrder' => 1, 'VValue' =>'REF', 'VDesc' => "Reference Range", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 45,'VOrder' => 2, 'VValue' =>'CRTC', 'VDesc' => "Critical Range", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 45,'VOrder' => 3, 'VValue' =>'VAL', 'VDesc' => "Validation Range", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 45,'VOrder' => 4, 'VValue' =>'RERUN', 'VDesc' => "Rerun Range", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 46,'VOrder' => 1, 'VValue' =>'RANGE', 'VDesc' => "Range", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 46,'VOrder' => 2, 'VValue' =>'THOLD', 'VDesc' => "Threshold", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 47,'VOrder' => 1, 'VValue' =>'VSET', 'VDesc' => "Value Set", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 47,'VOrder' => 2, 'VValue' =>'TEXT', 'VDesc' => "Text.", 'VCategory' => 1, 'CreateDate' => "$now"], + ['VSetID' => 1001,'VOrder' => 1, 'VValue' =>'NEG', 'VDesc' => "Negative", 'VCategory' => 2, 'CreateDate' => "$now"], + ['VSetID' => 1001,'VOrder' => 2, 'VValue' =>'POS', 'VDesc' => "Positive", 'VCategory' => 2, 'CreateDate' => "$now"], + ['VSetID' => 1001,'VOrder' => 3, 'VValue' =>'GZ', 'VDesc' => "Grayzone", 'VCategory' => 2, 'CreateDate' => "$now"], + ['VSetID' => 1002,'VOrder' => 1, 'VValue' =>'KNG', 'VDesc' => "Kuning", 'VCategory' => 2, 'CreateDate' => "$now"], + ['VSetID' => 1002,'VOrder' => 2, 'VValue' =>'JNG', 'VDesc' => "Jingga", 'VCategory' => 2, 'CreateDate' => "$now"], + ['VSetID' => 1002,'VOrder' => 3, 'VValue' =>'MRH', 'VDesc' => "Merah", 'VCategory' => 2, 'CreateDate' => "$now"], + ['VSetID' => 1002,'VOrder' => 4, 'VValue' =>'CKLT', 'VDesc' => "Coklat tua", 'VCategory' => 2, 'CreateDate' => "$now"] ]; $this->db->table('valueset')->insertBatch($data); $data = [ ['VSName' => 'WSType','VSDesc' =>'workstation.Type', 'VSetID' => '1', 'CreateDate' => "$now"], - ['VSName' => 'Enable/Disable','VSDesc' =>'workstation.Enable equipmentlist.Enable testdef.CountStat testdefsite.CountStat testdefsite.VisibleScr testdefsite.VisibleRpt', 'VSetID' => '2', 'CreateDate' => "$now"], - ['VSName' => 'Gender','VSDesc' =>'patient.Gender', 'VSetID' => '3', 'CreateDate' => "$now"], + ['VSName' => 'Enable/Disable','VSDesc' =>'workstation.Enable, equipmentlist.Enable, testdef.CountStat, testdefsite.CountStat, testdefsite.VisibleScr, testdefsite.VisibleRpt', 'VSetID' => '2', 'CreateDate' => "$now"], + ['VSName' => 'Gender','VSDesc' =>'patient.Gender, refnum.Sex', 'VSetID' => '3', 'CreateDate' => "$now"], ['VSName' => 'Marital Status','VSDesc' =>'patient.MaritalStatus', 'VSetID' => '4', 'CreateDate' => "$now"], - ['VSName' => 'Deceased','VSDesc' =>'patient.Deceased', 'VSetID' => '5', 'CreateDate' => "$now"], + ['VSName' => 'Death Indicator','VSDesc' =>'patient.DeathIndicator', 'VSetID' => '5', 'CreateDate' => "$now"], ['VSName' => 'Identifier Type','VSDesc' =>'patidt.IdentifierType', 'VSetID' => '6', 'CreateDate' => "$now"], - ['VSName' => 'Operation','VSDesc' =>'patreglog.Operation patvisitlog.Operation orderlog.Operation', 'VSetID' => '7', 'CreateDate' => "$now"], - ['VSName' => 'DID Type','VSDesc' =>'patreglog.DIDType patvisitlog.DIDType', 'VSetID' => '8', 'CreateDate' => "$now"], + ['VSName' => 'Operation','VSDesc' =>'patreglog.Operation, patvisitlog.Operation, orderlog.Operation', 'VSetID' => '7', 'CreateDate' => "$now"], + ['VSName' => 'DID Type','VSDesc' =>'patreglog.DIDType, patvisitlog.DIDType', 'VSetID' => '8', 'CreateDate' => "$now"], ['VSName' => 'Requested Entity','VSDesc' =>'order.ReqEntity', 'VSetID' => '9', 'CreateDate' => "$now"], ['VSName' => 'Order Priority','VSDesc' =>'order.Priority', 'VSetID' => '10', 'CreateDate' => "$now"], ['VSName' => 'Order Status','VSDesc' =>'orderststatus.OrderStatus', 'VSetID' => '11', 'CreateDate' => "$now"], - ['VSName' => 'Location Type','VSDesc' =>'location.LocationType', 'VSetID' => '12', 'CreateDate' => "$now"], - ['VSName' => 'Additive','VSDesc' =>'containertype.Additive specimenprep.Additive', 'VSetID' => '13', 'CreateDate' => "$now"], + ['VSName' => 'Location TypeTable 34 location','VSDesc' =>'location.LocationType', 'VSetID' => '12', 'CreateDate' => "$now"], + ['VSName' => 'Additive','VSDesc' =>'containertype.Additive, specimenprep.Additive', 'VSetID' => '13', 'CreateDate' => "$now"], ['VSName' => 'Container Class','VSDesc' =>'containertype.ConClass', 'VSetID' => '14', 'CreateDate' => "$now"], - ['VSName' => 'Specimen Type','VSDesc' =>'testdeftech.SpcType refnum. SpcType refthold.SpcType', 'VSetID' => '15', 'CreateDate' => "$now"], - ['VSName' => 'Unit','VSDesc' =>'spcdef.Unit specimens.Unit specimenstatus.Unit specimenprep.AddUnit', 'VSetID' => '16', 'CreateDate' => "$now"], + ['VSName' => 'Specimen Type','VSDesc' =>'testdeftech.SpcType, refnum.SpcType, reftxt.SpcType', 'VSetID' => '15', 'CreateDate' => "$now"], + ['VSName' => 'Unit','VSDesc' =>'spcdef.Unit, specimens.Unit, specimenstatus.Unit, specimenprep.AddUnit', 'VSetID' => '16', 'CreateDate' => "$now"], ['VSName' => 'GenerateBy','VSDesc' =>'specimens. GenerateBy', 'VSetID' => '17', 'CreateDate' => "$now"], ['VSName' => 'Specimen Activity','VSDesc' =>'specimenstatus.SpcAct', 'VSetID' => '18', 'CreateDate' => "$now"], - ['VSName' => 'Activity Result','VSDesc' =>'specimenstatus.ActRes patrestatus.ActRes', 'VSetID' => '19', 'CreateDate' => "$now"], + ['VSName' => 'Activity Result','VSDesc' =>'specimenstatus.ActRes, patrestatus.ActRes', 'VSetID' => '19', 'CreateDate' => "$now"], ['VSName' => 'Specimen Status','VSDesc' =>'specimenstatus.SpcStatus', 'VSetID' => '20', 'CreateDate' => "$now"], ['VSName' => 'Specimen Condition','VSDesc' =>'specimenstatus.SpcCon', 'VSetID' => '21', 'CreateDate' => "$now"], ['VSName' => 'Specimen Role','VSDesc' =>'specimencollection.SpcRole', 'VSetID' => '22', 'CreateDate' => "$now"], @@ -340,8 +353,8 @@ class ValueSetSeeder extends Seeder { ['VSName' => 'Body Site','VSDesc' =>'specimencollection.BodySite', 'VSetID' => '24', 'CreateDate' => "$now"], ['VSName' => 'Container Size','VSDesc' =>'specimencollection.CntSize', 'VSetID' => '25', 'CreateDate' => "$now"], ['VSName' => 'Fasting Status','VSDesc' =>'specimencollection.Fasting', 'VSetID' => '26', 'CreateDate' => "$now"], - ['VSName' => 'Test Type','VSDesc' =>'testdefsite.Type', 'VSetID' => '27', 'CreateDate' => "$now"], - ['VSName' => 'Result Unit','VSDesc' =>'testdefsite.Unit1 testdefsite.Unit2', 'VSetID' => '28', 'CreateDate' => "$now"], + ['VSName' => 'Test Type','VSDesc' =>'testdefsite.TestType', 'VSetID' => '27', 'CreateDate' => "$now"], + ['VSName' => 'Result Unit','VSDesc' =>'testdefsite.Unit1, testdefsite.Unit2', 'VSetID' => '28', 'CreateDate' => "$now"], ['VSName' => 'Formula Languange','VSDesc' =>'testdefcal.FormulaLang', 'VSetID' => '29', 'CreateDate' => "$now"], ['VSName' => 'Race','VSDesc' =>'patient.Race', 'VSetID' => '30', 'CreateDate' => "$now"], ['VSName' => 'Religion','VSDesc' =>'patient.Religion', 'VSetID' => '31', 'CreateDate' => "$now"], @@ -352,12 +365,17 @@ class ValueSetSeeder extends Seeder { ['VSName' => 'ADT Event','VSDesc' =>'patvisitadt.Code', 'VSetID' => '36', 'CreateDate' => "$now"], ['VSName' => 'Site Type','VSDesc' =>'Site.SiteType', 'VSetID' => '37', 'CreateDate' => "$now"], ['VSName' => 'Site Class','VSDesc' =>'Site.SiteClass', 'VSetID' => '38', 'CreateDate' => "$now"], - ['VSName' => 'Entity Type','VSDesc' =>'testmap.HostType testmap.ClientType', 'VSetID' => '39', 'CreateDate' => "$now"], + ['VSName' => 'Entity Type','VSDesc' =>'testmap.HostType, testmap.ClientType', 'VSetID' => '39', 'CreateDate' => "$now"], ['VSName' => 'Area Class','VSDesc' =>'AreaGeo', 'VSetID' => '40', 'CreateDate' => "$now"], - ['VSName' => 'Math Sign','VSDesc' =>'refthold.TholdSign', 'VSetID' => '41', 'CreateDate' => "$now"], + ['VSName' => 'Math Sign','VSDesc' =>'refnum.LowSign, refnum.HighSign', 'VSetID' => '41', 'CreateDate' => "$now"], ['VSName' => 'VCategory','VSDesc' =>'valueset. VCategory', 'VSetID' => '42', 'CreateDate' => "$now"], ['VSName' => 'Result Type','VSDesc' =>'testdeftech.ResultType', 'VSetID' => '43', 'CreateDate' => "$now"], ['VSName' => 'Reference Type','VSDesc' =>'testdeftech.RefType', 'VSetID' => '44', 'CreateDate' => "$now"], + ['VSName' => 'Range Type','VSDesc' =>'refnum.RangeType', 'VSetID' => '45', 'CreateDate' => "$now"], + ['VSName' => 'Numeric Reference Type','VSDesc' =>'refnum.NumRefType', 'VSetID' => '46', 'CreateDate' => "$now"], + ['VSName' => 'Text Reference Type','VSDesc' =>'reftxt. TxtRefType', 'VSetID' => '47', 'CreateDate' => "$now"], + ['VSName' => 'HIV','VSDesc' =>'Value set untuk hasil HIV', 'VSetID' => '1001', 'CreateDate' => "$now"], + ]; $this->db->table('valuesetdef')->insertBatch($data); } diff --git a/app/Models/Location/LocationModel.php b/app/Models/Location/LocationModel.php index 6f7f729..f2696c0 100644 --- a/app/Models/Location/LocationModel.php +++ b/app/Models/Location/LocationModel.php @@ -24,15 +24,15 @@ class LocationModel extends BaseModel { public function getLocation($LocationID) { //'Street1', 'Street2', 'City', 'Province', 'PostCode', 'GeoLocationSystem', 'GeoLocationData', - $rows = $this->select("location.*, la.Street1, la.Street2, la.PostCode, la.GeoLocationSystem, la.GeoLocationData, + $row = $this->select("location.*, la.Street1, la.Street2, la.PostCode, la.GeoLocationSystem, la.GeoLocationData, v.VDesc as LocTypeText, prop.AreaGeoID as ProvinceID, prop.AreaName as Province, city.AreaGeoID as CityID, city.AreaName as City, site.SiteID, site.SiteName") ->join("locationaddress la", "location.LocationID=la.LocationID", "left") ->join("valueset v", "v.VID=location.loctype", "left") ->join("areageo prop", "la.Province=prop.AreaGeoID", "left") ->join("areageo city", "la.City=city.AreaGeoID", "left") ->join("site", "site.SiteID=location.SiteID", "left") - ->where('location.LocationID', (int) $LocationID)->findAll(); - return $rows; + ->where('location.LocationID', (int) $LocationID)->first(); + return $row; } public function saveLocation(array $data): array { diff --git a/app/Models/Organization/AccountModel.php b/app/Models/Organization/AccountModel.php index 4127c8b..6d8023f 100644 --- a/app/Models/Organization/AccountModel.php +++ b/app/Models/Organization/AccountModel.php @@ -31,7 +31,7 @@ class AccountModel extends BaseModel { } public function getAccount($AccountID) { - $rows = $this->select('account.*, pa.AccountName as ParentName, areageo.AreaName, areageo.AreaGeoID, + $row = $this->select('account.*, pa.AccountName as ParentName, areageo.AreaName, areageo.AreaGeoID, city.AreaName as CityName, city.AreaGeoID as City, prov.AreaName as ProvName, prov.AreaGeoID as Prov, country.VValue as CountryName, country.VID as country') ->join('account pa', 'pa.AccountID=account.Parent', 'left') @@ -40,7 +40,7 @@ class AccountModel extends BaseModel { ->join('areageo prov', 'prov.AreaGeoID=account.Province', 'left') ->join('valueset country', 'country.VID=account.Country', 'left') ->where('account.AccountID', $AccountID) - ->findAll(); - return $rows; + ->first(); + return $row; } } diff --git a/app/Models/Organization/DepartmentModel.php b/app/Models/Organization/DepartmentModel.php index b51218b..1def9c8 100644 --- a/app/Models/Organization/DepartmentModel.php +++ b/app/Models/Organization/DepartmentModel.php @@ -30,11 +30,11 @@ class DepartmentModel extends BaseModel { } public function getDepartment($DepartmentID) { - $rows = $this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName') + $row = $this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName') ->join('discipline', 'discipline.DisciplineID=department.DisciplineID', 'left') ->join('site', 'site.SiteID=department.SiteID', 'left') ->where('department.DepartmentID', $DepartmentID) - ->findAll(); - return $rows; + ->first(); + return $row; } } diff --git a/app/Models/Organization/SiteModel.php b/app/Models/Organization/SiteModel.php index f2d4797..7f9ef3a 100644 --- a/app/Models/Organization/SiteModel.php +++ b/app/Models/Organization/SiteModel.php @@ -32,13 +32,13 @@ class SiteModel extends BaseModel { } public function getSite($SiteID) { - $rows = $this->select('site.*, account.AccountName, s1.SiteName as ParentName, sitetype.VValue as SiteType, siteclass.VValue as SiteClass') + $row = $this->select('site.*, account.AccountName, s1.SiteName as ParentName, sitetype.VValue as SiteType, siteclass.VValue as SiteClass') ->join('account', 'account.AccountID=site.AccountID', 'left') ->join('site s1', 's1.SiteID=site.Parent', 'left') ->join('valueset sitetype', 'site.SiteTypeID=sitetype.VID', 'left') ->join('valueset siteclass', 'site.SiteClassID=siteclass.VID', 'left') ->where('site.SiteID', $SiteID) - ->findAll(); - return $rows; + ->first(); + return $row; } } diff --git a/app/Models/Organization/WorkstationModel.php b/app/Models/Organization/WorkstationModel.php index ea4d701..626e088 100644 --- a/app/Models/Organization/WorkstationModel.php +++ b/app/Models/Organization/WorkstationModel.php @@ -30,13 +30,13 @@ class WorkstationModel extends BaseModel { } public function getWorkstation($WorkstationID) { - $rows = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,enable.VDesc as EnableName, wstype.VDesc as TypeName") + $row = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,enable.VDesc as EnableName, wstype.VDesc as TypeName") ->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left') ->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left') ->join('valueset wstype', 'wstype.VID=workstation.Type', 'left') ->join('valueset enable', 'enable.VID=workstation.Enable', 'left') ->where('workstation.WorkstationID', $WorkstationID) - ->findAll(); - return $rows; + ->first(); + return $row; } } diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index dae06b0..dfb462b 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -20,11 +20,11 @@ class PatVisitModel extends BaseModel { protected $visnum_prefix = "DV"; public function show($PVID) { - $rows = $this->select("*, patvisit.InternalPID, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") + $row = $this->select("*, patvisit.InternalPID, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") ->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID and patdiag.DelDate is null', 'left') ->join('patvisitadt', 'patvisitadt.InternalPVID=patvisit.InternalPVID', 'left') - ->where('patvisit.PVID',$PVID)->findAll(); - return $rows; + ->where('patvisit.PVID',$PVID)->first(); + return $row; } public function showByPatient($InternalPID) { diff --git a/app/Models/Specimen/ContainerDefModel.php b/app/Models/Specimen/ContainerDefModel.php index b20b1ec..524ee79 100644 --- a/app/Models/Specimen/ContainerDefModel.php +++ b/app/Models/Specimen/ContainerDefModel.php @@ -33,11 +33,11 @@ class ContainerDefModel extends BaseModel { } public function getContainer($ConDefID) { - $rows = $this->select('containerdef.*, vscol.VValue as ColorTxt, vscla.VValue as ConClassTxt, vsadd.VValue as AdditiveTxt') + $row = $this->select('containerdef.*, vscol.VValue as ColorTxt, vscla.VValue as ConClassTxt, vsadd.VValue as AdditiveTxt') ->join('valueset vscol', 'vscol.VID=containerdef.Color', 'left') ->join('valueset vscla', 'vscla.VID=containerdef.ConClass', 'left') ->join('valueset vsadd', 'vsadd.VID=containerdef.Additive', 'left') - ->where('ConDefID', $ConDefID)->findAll(); - return $rows; + ->where('ConDefID', $ConDefID)->first(); + return $row; } } \ No newline at end of file diff --git a/check_db.php b/check_db.php new file mode 100644 index 0000000..fb237f8 --- /dev/null +++ b/check_db.php @@ -0,0 +1,18 @@ +table($table)->countAllResults(); + echo "$table count: $count\n"; + if ($count > 0) { + $row = $db->table($table)->get(1)->getRow(); + echo "$table first row ID: " . (isset($row->{$table.'ID'}) ? $row->{$table.'ID'} : 'unknown') . "\n"; + } + } catch (\Exception $e) { + echo "$table error: " . $e->getMessage() . "\n"; + } +} diff --git a/sanity.php b/sanity.php new file mode 100644 index 0000000..237c4d7 --- /dev/null +++ b/sanity.php @@ -0,0 +1,3 @@ + vendor\bin\phpunit tests/feature/UniformShowTest.php +``` + +This test verifies: +1. **Uniformity**: All `/api/.../{id}` endpoints return a single associative array (object) in the `data` field when found. +2. **Null State**: All endpoints return `null` in the `data` field when the record is not found, rather than an empty array or missing key. diff --git a/tests/UniformShowTest_README.md b/tests/UniformShowTest_README.md new file mode 100644 index 0000000..97ed7c0 --- /dev/null +++ b/tests/UniformShowTest_README.md @@ -0,0 +1,33 @@ +# Uniform Show Endpoints Testing + +This document describes the testing strategy and execution for ensuring all API `show` endpoints follow a uniform response structure. + +## Requirement + +All `show` endpoints (e.g., `/api/location/1`, `/api/patient/1`, etc.) must return: +1. **A single Object** (associative array) in the `data` field when a record is found. +2. **Null** in the `data` field when a record is not found. + +Previously, some endpoints returned a sequential array with one item, which was inconsistent for frontend development. + +## Test Suite + +The test suite is located at: `tests/feature/UniformShowTest.php` + +### What it tests: +- **`testShowEndpointsReturnObjectWhenFound`**: Iterates through a list of known endpoints and verifies that if data is returned, it is an associative array (object) and not a sequential array. +- **`testShowEndpointsReturnNullWhenNotFound`**: Iterates through endpoints with non-existent IDs and verifies that the `data` field is strictly `null`. + +## How to Run + +Ensure your test database is configured in `phpunit.xml` or `.env`. + +Run the following command from the project root: + +```bash +vendor/bin/phpunit tests/feature/UniformShowTest.php +``` + +## Maintenance + +If you add a new resource with a `show` method, add its endpoint to the `$endpoints` array in `tests/feature/UniformShowTest.php` to ensure it remains compliant with the uniformity requirement. diff --git a/tests/feature/SimpleTest.php b/tests/feature/SimpleTest.php new file mode 100644 index 0000000..e45c606 --- /dev/null +++ b/tests/feature/SimpleTest.php @@ -0,0 +1,16 @@ +assertTrue(true); + } +} diff --git a/tests/feature/UniformShowTest.php b/tests/feature/UniformShowTest.php new file mode 100644 index 0000000..4016199 --- /dev/null +++ b/tests/feature/UniformShowTest.php @@ -0,0 +1,111 @@ + 'localhost', + 'aud' => 'localhost', + 'iat' => time(), + 'nbf' => time(), + 'exp' => time() + 3600, + 'uid' => 1, + 'email' => 'admin@admin.com' + ]; + $this->token = \Firebase\JWT\JWT::encode($payload, $key, 'HS256'); + } + + // Override get to inject cookie header + public function get(string $path, array $options = []) { + $this->withHeaders(['Cookie' => 'token=' . $this->token]); + return $this->call('get', $path, $options); + } + + /** + * Test that show endpoints return a single object (associative array) in 'data' when found. + */ + public function testShowEndpointsReturnObjectWhenFound() + { + // representative endpoints. + $endpoints = [ + 'api/location', + 'api/organization/site', + 'api/organization/account', + 'api/patient', + 'api/tests', + 'api/specimen/containerdef', + 'api/contact', + ]; + + foreach ($endpoints as $url) { + // We first check index to get a valid ID if possible + $indexResult = $this->get($url); + $indexBody = json_decode($indexResult->response()->getBody(), true); + + $id = 1; // logical default + if (isset($indexBody['data']) && is_array($indexBody['data']) && !empty($indexBody['data'])) { + $firstItem = $indexBody['data'][0]; + // Try to guess ID key + $idKeys = ['LocationID', 'SiteID', 'AccountID', 'InternalPID', 'TestSiteID', 'ConDefID', 'ContactID', 'VID', 'id']; + foreach ($idKeys as $key) { + if (isset($firstItem[$key])) { + $id = $firstItem[$key]; + break; + } + } + } + + $showUrl = $url . '/' . $id; + $result = $this->get($showUrl); + $body = json_decode($result->response()->getBody(), true); + + if ($result->response()->getStatusCode() === 200 && isset($body['data']) && $body['data'] !== null) { + $this->assertTrue( + $this->is_assoc($body['data']), + "Endpoint $showUrl should return an object in 'data', but got a sequential array or empty array. Body: " . $result->response()->getBody() + ); + } + } + } + + public function testShowEndpointsReturnNullWhenNotFound() + { + $endpoints = [ + 'api/location/9999999', + 'api/organization/site/9999999', + 'api/patient/9999999', + ]; + + foreach ($endpoints as $url) { + $result = $this->get($url); + $result->assertStatus(200); + $body = json_decode($result->response()->getBody(), true); + + $this->assertArrayHasKey('data', $body, "Endpoint $url missing 'data' key. Body: " . $result->response()->getBody()); + $this->assertNull($body['data'], "Endpoint $url should return null in 'data' when not found. Body: " . $result->response()->getBody()); + } + } + + /** + * Helper to check if array is associative. + */ + private function is_assoc(array $arr) + { + if (array() === $arr) return false; + return array_keys($arr) !== range(0, count($arr) - 1); + } +}