From 2df524c890a80c9e4c971ccf5ef722a4a17cea54 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Thu, 23 Oct 2025 11:05:20 +0700 Subject: [PATCH 1/8] fix patvisit --- app/Models/PatVisit/PatDiagModel.php | 2 +- app/Models/PatVisit/PatVisitModel.php | 94 +++++++++++++++++---------- 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/app/Models/PatVisit/PatDiagModel.php b/app/Models/PatVisit/PatDiagModel.php index f9275f8..f050603 100644 --- a/app/Models/PatVisit/PatDiagModel.php +++ b/app/Models/PatVisit/PatDiagModel.php @@ -6,7 +6,7 @@ use App\Models\BaseModel; class PatDiagModel extends BaseModel { protected $table = 'patdiag'; protected $primaryKey = 'InternalPVID'; - protected $allowedFields = ['InternalPID', 'DiagCode', 'Diagnosis', 'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate']; + protected $allowedFields = ['InternalPVID','InternalPID', 'DiagCode', 'Diagnosis', 'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate']; protected $visnum_prefix; protected $useTimestamps = true; diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 6bdde49..3335ddb 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -21,7 +21,7 @@ class PatVisitModel extends BaseModel { public function show($PVID) { $rows = $this->select("*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") - ->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID', 'left') + ->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; @@ -29,7 +29,7 @@ class PatVisitModel extends BaseModel { public function showByPatient($InternalPID) { $rows = $this->select("*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") - ->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID', 'left') + ->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID and patdiag.DelDate is null', 'left') ->join('patvisitadt', 'patvisitadt.InternalPVID=patvisit.InternalPVID', 'left') ->join('location', 'location.LocationID=patvisitadt.LocationID', 'left') ->where('patvisit.InternalPID',$InternalPID)->findAll(); @@ -37,75 +37,99 @@ class PatVisitModel extends BaseModel { } public function createPatVisit($input) { - $db = \Config\Database::connect(); + $db = $this->db; $modelPD = new PatDiagModel(); $modelPVA = new PatVisitADTModel(); + $db->transBegin(); try{ - $db->transStart(); + if (!isset($input['PVID']) || $input['PVID']=='') { $modelCounter = new CounterModel(); $input['PVID'] = $this->visnum_prefix .$modelCounter->use(2); } $InternalPVID = $this->insert($input, true); - - if(!empty($input['PatDiag'])) { + if($InternalPVID === false) { throw new \Exception("Failed to insert main PatVisit record."); } + if( !empty($input['PatDiag']) && ( !empty($input['PatDiag']['DiagCode']) || !empty($input['PatDiag']['Diagnosis']) ) ) { $input['PatDiag']['InternalPVID'] = $InternalPVID; - //$db->table('patdiag')->insert($input['PatDiag']); - $modelPD->insert($input['PatDiag']); + $tmp = $modelPD->insert($input['PatDiag']); + if ($tmp === false) { throw new \Exception("Failed to insert PatDiag record."); } } - if(!empty($input['PatVisitADT'])) { + if( !empty($input['PatVisitADT']) ) { $input['PatVisitADT']['InternalPVID'] = $InternalPVID; - //$db->table('patvisitadt')->insert($input['PatVisitADT']); - $modelPVA->insert($input['PatVisitADT']); + $tmp = $modelPVA->insert($input['PatVisitADT']); + if ($tmp === false) { + throw new \Exception("Failed to insert PatVisitADT record."); + } } - $db->transComplete(); - $data = [ "PVID"=>$input['PVID'], "InternalPVID"=>$InternalPVID ]; - return $data; - - } catch (\Exception $e) { - $db->transRollback(); + if ($db->transStatus() === FALSE) { + $db->transRollback(); + return false; + } else { + $db->transCommit(); + $data = [ "PVID" => $input['PVID'], "InternalPVID" => $InternalPVID ]; + return $data; + } + } catch (\Exception $e) { + $db->transRollback(); throw $e; - } + } } public function updatePatVisit($input) { $InternalPVID = $input['InternalPVID']; + $modelPD = new PatDiagModel(); + $modelPVA = new PatVisitADTModel(); + + $db = $this->db; + $db->transBegin(); try{ - $this->db->transStart(); $this->where('InternalPVID',$InternalPVID)->set($input)->update(); // patdiag - $exist = $this->db->table('patdiag')->where('InternalPVID',$InternalPVID)->get()->getRow(); + $exist = $modelPD->where('InternalPVID',$InternalPVID)->find(); + $tmp = ''; if($exist) { - if(!empty($input['PatDiag'])) { - $input['PatDiag']['InternalPVID'] = $InternalPVID; - $this->db->table('patdiag')->where('InternalPVID',$InternalPVID)->set($input['PatDiag'])->update(); - } else { $this->db->table('patdiag')->where('InternalPVID',$InternalPVID)->delete(); } + if( !empty($input['PatDiag']) && ( !empty($input['PatDiag']['DiagCode']) || !empty($input['PatDiag']['Diagnosis']) ) ) { + $tmp = $modelPD->where('InternalPVID',$InternalPVID)->set($input['PatDiag'])->update(); + } else { $tmp = $modelPD->delete($InternalPVID); } } else { - if(!empty($input['PatDiag'])) { + if( !empty($input['PatDiag']) && ( !empty($input['PatDiag']['DiagCode']) || !empty($input['PatDiag']['Diagnosis']) ) ) { $input['PatDiag']['InternalPVID'] = $InternalPVID; - $this->db->table('patdiag')->insert($input['PatDiag']); - } + $tmp = $modelPD->insert($input['PatDiag']); + } + } + if ($tmp === false) { + $error = $db->error(); + throw new \Exception("Failed to update PatDiag record. ". $error['message']); } // patvisitadt - $exist = $this->db->table('patvisitadt')->where('InternalPVID',$InternalPVID)->get()->getRow(); + $exist = $modelPVA->where('InternalPVID',$InternalPVID)->find(); if($exist) { if(!empty($input['PatVisitADT'])) { - $input['PatVisitADT']['InternalPVID'] = $InternalPVID; - $this->db->table('patvisitadt')->where('InternalPVID',$InternalPVID)->set($input['PatVisitADT'])->update(); - } else { $this->db->table('patvisitadt')->where('InternalPVID',$InternalPVID)->delete(); } + $tmp = $modelPVA->where('InternalPVID',$InternalPVID)->set($input['PatVisitADT'])->update(); + } else { $tmp = $modelPVA->where('InternalPVID',$InternalPVID)->delete(); } } else { if(!empty($input['PatVisitADT'])) { $input['PatVisitADT']['InternalPVID'] = $InternalPVID; - $this->db->table('patvisitadt')->insert($input['PatVisitADT']); - } + $tmp = $modelPVA->insert($input['PatVisitADT']); + } + } + if ($tmp === false) { + $error = $db->error(); + throw new \Exception("Failed to update PatVisitADT record. ". $error['message']); } - $this->db->transComplete(); - return $input['PVID']; + if ($db->transStatus() === FALSE) { + $db->transRollback(); + return false; + } else { + $db->transCommit(); + $data = [ "PVID" => $input['PVID'], "InternalPVID" => $InternalPVID ]; + return $data; + } } catch (\Exception $e) { $this->db->transRollback(); From a71a587573934519632eb7c39a024580aea30332 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Thu, 23 Oct 2025 12:16:52 +0700 Subject: [PATCH 2/8] add pva cr --- app/Config/Routes.php | 2 ++ app/Controllers/PatVisit.php | 33 +++++++++++++++++++++------ app/Models/PatVisit/PatVisitModel.php | 1 - 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a9e8df8..6437007 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -36,6 +36,8 @@ $routes->get('/api/patvisit/patient/(:num)', 'PatVisit::showByPatient/$1'); $routes->get('/api/patvisit/(:any)', 'PatVisit::show/$1'); $routes->delete('/api/patvisit', 'PatVisit::delete'); $routes->patch('/api/patvisit', 'PatVisit::update'); +$routes->post('/api/patvisitadt', 'PatVisit::createADT'); +$routes->patch('/api/patvisitadt', 'PatVisit::updateADT'); $routes->get('/api/race', 'Race::index'); $routes->get('/api/race/(:num)', 'Race::show/$1'); diff --git a/app/Controllers/PatVisit.php b/app/Controllers/PatVisit.php index ccb813f..f0916da 100644 --- a/app/Controllers/PatVisit.php +++ b/app/Controllers/PatVisit.php @@ -4,6 +4,7 @@ namespace App\Controllers; use CodeIgniter\API\ResponseTrait; use App\Controllers\BaseController; use App\Models\PatVisit\PatVisitModel; +use App\Models\PatVisit\PatVisitADTModel; class PatVisit extends BaseController { use ResponseTrait; @@ -17,11 +18,8 @@ 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"; - } + if($row == []) { $message = "data not found"; } + else { $message = "data found"; } return $this->respond([ 'status' => 'success', 'message'=> $message, 'data' => $row ], 200); } catch (\Exception $e) { return $this->failServerError('Something went wrong '.$e->getMessage()); @@ -42,7 +40,6 @@ class PatVisit extends BaseController { public function update() { $input = $this->request->getJSON(true); try { - // if(empty($input)){throw new \Exception('Input data is empty or invalid');} if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); } $data = $this->model->updatePatVisit($input); return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 201); @@ -54,7 +51,6 @@ class PatVisit extends BaseController { public function create() { $input = $this->request->getJSON(true); try { - // if(empty($input)){throw new \Exception('Input data is empty or invalid');} $data = $this->model->createPatVisit($input); return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201); } catch (\Exception $e) { @@ -62,4 +58,27 @@ class PatVisit extends BaseController { } } + public function createADT() { + $input = $this->request->getJSON(true); + if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); } + $modelPVA = new PatVisitADTModel(); + try { + $data = $modelPVA->insert($input, true); + return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function updateADT() { + $input = $this->request->getJSON(true); + if (!$input["PVADTID"] || !is_numeric($input["PVADTID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); } + $modelPVA = new PatVisitADTModel(); + try { + $data = $modelPVA->update($input['PVADTID'], $input); + return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 201); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 3335ddb..1f57dfc 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -89,7 +89,6 @@ class PatVisitModel extends BaseModel { // patdiag $exist = $modelPD->where('InternalPVID',$InternalPVID)->find(); - $tmp = ''; if($exist) { if( !empty($input['PatDiag']) && ( !empty($input['PatDiag']['DiagCode']) || !empty($input['PatDiag']['Diagnosis']) ) ) { $tmp = $modelPD->where('InternalPVID',$InternalPVID)->set($input['PatDiag'])->update(); From bc8653d89f5b0876054e1c26f1d4ec96ffe5d79b Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Fri, 24 Oct 2025 11:19:58 +0700 Subject: [PATCH 3/8] add CRM Zones Org --- ...RM.php => 2025-10-22-100001_CRM_Zones.php} | 2 +- .../2025-10-23-100001_CRM_Organizations.php | 37 +++++++++++ .../2025-10-23-110105_Organization.php | 64 +++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) rename app/Database/Migrations/{2025-10-22-100001_Zones_CRM.php => 2025-10-22-100001_CRM_Zones.php} (94%) create mode 100644 app/Database/Migrations/2025-10-23-100001_CRM_Organizations.php create mode 100644 app/Database/Migrations/2025-10-23-110105_Organization.php diff --git a/app/Database/Migrations/2025-10-22-100001_Zones_CRM.php b/app/Database/Migrations/2025-10-22-100001_CRM_Zones.php similarity index 94% rename from app/Database/Migrations/2025-10-22-100001_Zones_CRM.php rename to app/Database/Migrations/2025-10-22-100001_CRM_Zones.php index 051d1f3..7029497 100644 --- a/app/Database/Migrations/2025-10-22-100001_Zones_CRM.php +++ b/app/Database/Migrations/2025-10-22-100001_CRM_Zones.php @@ -4,7 +4,7 @@ namespace App\Database\Migrations; use CodeIgniter\Database\Migration; -class CreateZonessTable extends Migration { +class CreateZonesTable extends Migration { public function up() { $this->forge->addField([ diff --git a/app/Database/Migrations/2025-10-23-100001_CRM_Organizations.php b/app/Database/Migrations/2025-10-23-100001_CRM_Organizations.php new file mode 100644 index 0000000..a0d167e --- /dev/null +++ b/app/Database/Migrations/2025-10-23-100001_CRM_Organizations.php @@ -0,0 +1,37 @@ +forge->addField([ + 'accountid' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'parrentaccount' => ['type' => 'INT', 'null' => true], + 'accountname' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false], + 'accountnpwp' => ['type' => 'VARCHAR', 'constraint' => 5, 'null' => false], + 'inital' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false], + 'street_1' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true], + 'street_2' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true], + 'street_3' => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true], + 'zoneid' => ['type' => 'int', 'null' => true], + 'zip' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true], + 'country' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'email_1' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'email_2' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'phone' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'fax' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], + 'createdate' => ['type' => 'datetime', 'null'=> true], + 'enddate' => ['type' => 'datetime', 'null'=> true] + ]); + + $this->forge->addKey('accountid', true); + $this->forge->createTable('accounts'); + } + + public function down() { + $this->forge->dropTable('accounts'); + } +} \ No newline at end of file diff --git a/app/Database/Migrations/2025-10-23-110105_Organization.php b/app/Database/Migrations/2025-10-23-110105_Organization.php new file mode 100644 index 0000000..9ed53e0 --- /dev/null +++ b/app/Database/Migrations/2025-10-23-110105_Organization.php @@ -0,0 +1,64 @@ +forge->addField([ + 'DisciplineID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'DisciplineCode' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> false], + 'DisciplineName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('DiciplineID', true); + $this->forge->createTable('discipline'); + + $this->forge->addField([ + 'DepartmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'DisciplineID' => ['type' => 'int', 'null'=> false], + 'SiteID' => ['type' => 'int', 'null'=> false], + 'DepartmentCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false], + 'DepartmentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('DepartmentID', true); + $this->forge->createTable('department'); + + $this->forge->addField([ + 'WorkstationID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'DepartmentID' => ['type' => 'int', 'null'=> false], + 'WorkstationCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false], + 'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'Type' => ['type' => 'tinyint', 'null'=> true], + 'LinkTo' => ['type' => 'int', 'null'=> true], + 'Enable' => ['type' => 'bit', 'null'=> true], + 'EquipmentID' => ['type' => 'varchar', 'constraint'=>'10', 'null'=> true], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('WorkstationID', true); + $this->forge->createTable('workstation'); + + $this->forge->addField([ + 'WorkbenchID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'DepartmentID' => ['type' => 'int', 'null'=> false], + 'WorkbenchCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false], + 'WorkbenchName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('WorkbenchID', true); + $this->forge->createTable('workbench'); + } + + public function down() { + $this->forge->dropTable('discipline', true); + $this->forge->dropTable('department', true); + $this->forge->dropTable('workstation', true); + $this->forge->dropTable('workbench', true); + } +} From d5c8cac5ec0ef742649176f74be18b11137084c7 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Fri, 24 Oct 2025 16:41:31 +0700 Subject: [PATCH 4/8] prework --- app/Controllers/Test/ValueSetDef.php | 69 +++++++++++++++++++ ...nt copy.php => 2025-10-11-100001_Test.php} | 0 app/Models/RefRange/RefNumModel.php | 20 ++++++ app/Models/RefRange/RefTHoldModel.php | 20 ++++++ app/Models/RefRange/RefVSetModel.php | 19 +++++ app/Models/Test/TestDefCalModel.php | 19 +++++ app/Models/Test/TestDefModel.php | 19 +++++ app/Models/Test/TestDefSiteModel.php | 19 +++++ app/Models/Test/TestDefTechModel.php | 20 ++++++ app/Models/Test/TestGrpModel.php | 18 +++++ 10 files changed, 223 insertions(+) create mode 100644 app/Controllers/Test/ValueSetDef.php rename app/Database/Migrations/{2025-10-11-100001_Test_Management copy.php => 2025-10-11-100001_Test.php} (100%) create mode 100644 app/Models/RefRange/RefNumModel.php create mode 100644 app/Models/RefRange/RefTHoldModel.php create mode 100644 app/Models/RefRange/RefVSetModel.php create mode 100644 app/Models/Test/TestDefCalModel.php create mode 100644 app/Models/Test/TestDefModel.php create mode 100644 app/Models/Test/TestDefSiteModel.php create mode 100644 app/Models/Test/TestDefTechModel.php create mode 100644 app/Models/Test/TestGrpModel.php diff --git a/app/Controllers/Test/ValueSetDef.php b/app/Controllers/Test/ValueSetDef.php new file mode 100644 index 0000000..bea445c --- /dev/null +++ b/app/Controllers/Test/ValueSetDef.php @@ -0,0 +1,69 @@ +db = \Config\Database::connect(); + $this->model = new TestDefModel; + } + + public function index() { + $param = $this->request->getVar('param'); + $rows = $this->model->getValueSetDefs($param); + 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); + } + + 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); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $VSetID = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $VSetID created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $VSetID = $input["VID"]; + if (!$VSetID) { return $this->failValidationErrors('VSetID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($VSetID,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $VSetID updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function delete() { + $input = $this->request->getJSON(true); + $VSetID = $input['VSetID']; + if (!$VSetID) { return $this->failValidationErrors('VSetID is required.'); } + try { + $this->model->delete($VSetID); + return $this->respondDeleted(['status' => 'success', 'message' => "Data $VSetID deleted successfully."]); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Database/Migrations/2025-10-11-100001_Test_Management copy.php b/app/Database/Migrations/2025-10-11-100001_Test.php similarity index 100% rename from app/Database/Migrations/2025-10-11-100001_Test_Management copy.php rename to app/Database/Migrations/2025-10-11-100001_Test.php diff --git a/app/Models/RefRange/RefNumModel.php b/app/Models/RefRange/RefNumModel.php new file mode 100644 index 0000000..6bc1e82 --- /dev/null +++ b/app/Models/RefRange/RefNumModel.php @@ -0,0 +1,20 @@ + Date: Mon, 27 Oct 2025 10:37:44 +0700 Subject: [PATCH 5/8] fix pvadt --- app/Models/PatVisit/PatVisitModel.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 1f57dfc..90d0ec8 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -104,21 +104,17 @@ class PatVisitModel extends BaseModel { throw new \Exception("Failed to update PatDiag record. ". $error['message']); } - // patvisitadt - $exist = $modelPVA->where('InternalPVID',$InternalPVID)->find(); - if($exist) { - if(!empty($input['PatVisitADT'])) { - $tmp = $modelPVA->where('InternalPVID',$InternalPVID)->set($input['PatVisitADT'])->update(); - } else { $tmp = $modelPVA->where('InternalPVID',$InternalPVID)->delete(); } - } else { - if(!empty($input['PatVisitADT'])) { - $input['PatVisitADT']['InternalPVID'] = $InternalPVID; - $tmp = $modelPVA->insert($input['PatVisitADT']); - } - } - if ($tmp === false) { - $error = $db->error(); - throw new \Exception("Failed to update PatVisitADT record. ". $error['message']); + if(!empty($input['PatVisitADT'])) { + $adtList = $input['PatVisitADT']; + usort($adtList, fn($a, $b) => $a['sequence'] <=> $b['sequence']); + foreach ($adtList as $adt) { + $adt['InternalPVID'] = $InternalPVID; + $tmp = $modelPVA->insert($adt); + if ($tmp === false) { + $error = $db->error(); + throw new \Exception("Failed to update PatVisitADT record. ". $error['message']); + } + } } if ($db->transStatus() === FALSE) { From 4fea4e1385c4d306c625f5fac5351c44cc36780f Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Mon, 27 Oct 2025 11:13:12 +0700 Subject: [PATCH 6/8] fix pv showByPatient show latest id --- app/Models/PatVisit/PatVisitModel.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 90d0ec8..714f282 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -30,7 +30,16 @@ class PatVisitModel extends BaseModel { public function showByPatient($InternalPID) { $rows = $this->select("*, 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') + ->join('(SELECT a1.* + FROM patvisitadt a1 + INNER JOIN ( + SELECT InternalPVID, MAX(PVADTID) AS MaxID + FROM patvisitadt + GROUP BY InternalPVID + ) a2 ON a1.InternalPVID = a2.InternalPVID AND a1.PVADTID = a2.MaxID + ) AS patvisitadt', + 'patvisitadt.InternalPVID = patvisit.InternalPVID', + 'left') ->join('location', 'location.LocationID=patvisitadt.LocationID', 'left') ->where('patvisit.InternalPID',$InternalPID)->findAll(); return $rows; From 112e6ec3118e44941f103d311a4f8913ed57342f Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Wed, 29 Oct 2025 11:08:38 +0700 Subject: [PATCH 7/8] add organization endpoint --- app/Config/Routes.php | 26 +++++++ app/Controllers/Organization/Department.php | 72 +++++++++++++++++++ app/Controllers/Organization/Discipline.php | 72 +++++++++++++++++++ app/Controllers/Organization/Workbench.php | 72 +++++++++++++++++++ app/Controllers/Organization/Workstation.php | 72 +++++++++++++++++++ .../2025-10-12-100001_Ref_Range.php | 2 +- .../2025-10-23-110105_Organization.php | 2 +- .../2025-10-29-100201_Equipment.php | 65 +++++++++++++++++ app/Models/Organization/DepartmentModel.php | 16 +++++ app/Models/Organization/DisciplineModel.php | 16 +++++ app/Models/Organization/WorkbenchModel.php | 16 +++++ app/Models/Organization/WorkstationModel.php | 17 +++++ 12 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 app/Controllers/Organization/Department.php create mode 100644 app/Controllers/Organization/Discipline.php create mode 100644 app/Controllers/Organization/Workbench.php create mode 100644 app/Controllers/Organization/Workstation.php create mode 100644 app/Database/Migrations/2025-10-29-100201_Equipment.php create mode 100644 app/Models/Organization/DepartmentModel.php create mode 100644 app/Models/Organization/DisciplineModel.php create mode 100644 app/Models/Organization/WorkbenchModel.php create mode 100644 app/Models/Organization/WorkstationModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6437007..bc30f0b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -94,6 +94,32 @@ $routes->post('/api/containerdef', 'Specimen\ContainerDef::create'); $routes->patch('/api/containerdef', 'Specimen\ContainerDef::update'); $routes->delete('/api/containerdef', 'Specimen\ContainerDef::delete'); +//organization +// discipline +$routes->get('/api/organization/discipline/', 'Organization\Discipline::index'); +$routes->get('/api/organization/discipline/(:num)', 'Organization\Discipline::show/$1'); +$routes->post('/api/organization/discipline', 'Organization\Discipline::create'); +$routes->patch('/api/organization/discipline', 'Organization\Discipline::update'); +$routes->delete('/api/organization/discipline', 'Organization\Discipline::delete'); +// department +$routes->get('/api/organization/department/', 'Organization\Department::index'); +$routes->get('/api/organization/department/(:num)', 'Organization\Department::show/$1'); +$routes->post('/api/organization/department', 'Organization\Department::create'); +$routes->patch('/api/organization/department', 'Organization\Department::update'); +$routes->delete('/api/organization/department', 'Organization\Department::delete'); +// workstation +$routes->get('/api/organization/workstation/', 'Organization\Workstation::index'); +$routes->get('/api/organization/workstation/(:num)', 'Organization\Workstation::show/$1'); +$routes->post('/api/organization/workstation', 'Organization\Workstation::create'); +$routes->patch('/api/organization/workstation', 'Organization\Workstation::update'); +$routes->delete('/api/organization/workstation', 'Organization\Workstation::delete'); +// workbench +$routes->get('/api/organization/workbench/', 'Organization\Workbench::index'); +$routes->get('/api/organization/workbench/(:num)', 'Organization\Workbench::show/$1'); +$routes->post('/api/organization/workbench', 'Organization\Workbench::create'); +$routes->patch('/api/organization/workbench', 'Organization\Workbench::update'); +$routes->delete('/api/organization/workbench', 'Organization\Workbench::delete'); + // Khusus $routes->get('/api/zones', 'Zones::index'); $routes->get('/api/zones/synchronize', 'Zones::synchronize'); diff --git a/app/Controllers/Organization/Department.php b/app/Controllers/Organization/Department.php new file mode 100644 index 0000000..e929f61 --- /dev/null +++ b/app/Controllers/Organization/Department.php @@ -0,0 +1,72 @@ +db = \Config\Database::connect(); + $this->model = new DepartmentModel(); + } + + public function index() { + $rows = $this->model->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function show($DepartmentID = null) { + $rows = $this->model->where('DepartmentID', $DepartmentID)->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function delete() { + try { + $input = $this->request->getJSON(true); + $id = $input["DepartmentID"]; + if (!$id) { return $this->failValidationErrors('ID is required.'); } + $this->model->delete($id); + return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + try { + $id = $this->model->insert($input,true); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + try { + $id = $input['DepartmentID']; + $this->model->where('DepartmentID', $id)->update(); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/Controllers/Organization/Discipline.php b/app/Controllers/Organization/Discipline.php new file mode 100644 index 0000000..72c47cc --- /dev/null +++ b/app/Controllers/Organization/Discipline.php @@ -0,0 +1,72 @@ +db = \Config\Database::connect(); + $this->model = new DisciplineModel(); + } + + public function index() { + $rows = $this->model->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function show($DisciplineID = null) { + $rows = $this->model->where('DisciplineID', $DisciplineID)->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function delete() { + try { + $input = $this->request->getJSON(true); + $id = $input["DisciplineID"]; + if (!$id) { return $this->failValidationErrors('ID is required.'); } + $this->model->delete($id); + return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + try { + $id = $this->model->insert($input,true); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + try { + $id = $input['DisciplineID']; + $this->model->where('DisciplineID', $id)->update(); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/Controllers/Organization/Workbench.php b/app/Controllers/Organization/Workbench.php new file mode 100644 index 0000000..ed227e9 --- /dev/null +++ b/app/Controllers/Organization/Workbench.php @@ -0,0 +1,72 @@ +db = \Config\Database::connect(); + $this->model = new WorkbenchModel(); + } + + public function index() { + $rows = $this->model->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function show($WorkbenchID = null) { + $rows = $this->model->where('WorkbenchID', $WorkbenchID)->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function delete() { + try { + $input = $this->request->getJSON(true); + $id = $input["WorkbenchID"]; + if (!$id) { return $this->failValidationErrors('ID is required.'); } + $this->model->delete($id); + return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + try { + $id = $this->model->insert($input,true); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + try { + $id = $input['WorkbenchID']; + $this->model->where('WorkbenchID', $id)->update(); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/Controllers/Organization/Workstation.php b/app/Controllers/Organization/Workstation.php new file mode 100644 index 0000000..8c5df3d --- /dev/null +++ b/app/Controllers/Organization/Workstation.php @@ -0,0 +1,72 @@ +db = \Config\Database::connect(); + $this->model = new WorkstationModel(); + } + + public function index() { + $rows = $this->model->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function show($WorkstationID = null) { + $rows = $this->model->where('WorkstationID', $WorkstationID)->findAll(); + + if (empty($rows)) { + return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); + } + + return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200); + } + + public function delete() { + try { + $input = $this->request->getJSON(true); + $id = $input["WorkstationID"]; + if (!$id) { return $this->failValidationErrors('ID is required.'); } + $this->model->delete($id); + return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + try { + $id = $this->model->insert($input,true); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + try { + $id = $input['WorkstationID']; + $this->model->where('WorkstationID', $id)->update(); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/Database/Migrations/2025-10-12-100001_Ref_Range.php b/app/Database/Migrations/2025-10-12-100001_Ref_Range.php index 6818568..9c98e6d 100644 --- a/app/Database/Migrations/2025-10-12-100001_Ref_Range.php +++ b/app/Database/Migrations/2025-10-12-100001_Ref_Range.php @@ -4,7 +4,7 @@ namespace App\Database\Migrations; use CodeIgniter\Database\Migration; -class CreateTestsTable extends Migration { +class CreateRefRangesTable extends Migration { public function up() { $this->forge->addField([ diff --git a/app/Database/Migrations/2025-10-23-110105_Organization.php b/app/Database/Migrations/2025-10-23-110105_Organization.php index 9ed53e0..34fe3ba 100644 --- a/app/Database/Migrations/2025-10-23-110105_Organization.php +++ b/app/Database/Migrations/2025-10-23-110105_Organization.php @@ -13,7 +13,7 @@ class Organization extends Migration { 'CreateDate' => ['type'=>'DATETIME', 'null' => true], 'EndDate' => ['type'=>'DATETIME', 'null' => true] ]); - $this->forge->addKey('DiciplineID', true); + $this->forge->addKey('DisciplineID', true); $this->forge->createTable('discipline'); $this->forge->addField([ diff --git a/app/Database/Migrations/2025-10-29-100201_Equipment.php b/app/Database/Migrations/2025-10-29-100201_Equipment.php new file mode 100644 index 0000000..1ff7bd1 --- /dev/null +++ b/app/Database/Migrations/2025-10-29-100201_Equipment.php @@ -0,0 +1,65 @@ +forge->addField([ + 'EquipmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'DepartmentID' => ['type' => 'int', 'constraint'=> 10, 'null'=> false], + 'InstrumentID' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'InstrumentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'Enable' => ['type' => 'bit', 'null'=> false], + 'EquipmentRole' => ['type' => 'varchar', 'constraint' => 1, 'null'=> false], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('EquipmentID', true); + $this->forge->createTable('equipmentlist'); + + $this->forge->addField([ + 'InterfaceID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'InstrumentID' => ['type' => 'int', 'null'=> false], + 'SiteID' => ['type' => 'int', 'null'=> true], + 'InterfaceName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'InterfaceDesc' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true], + 'Protocol' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true], + 'IPAddress' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true], + 'Port' => ['type' => 'varchar', 'constraint'=> 25, 'null'=> true], + 'COM' => ['type' => 'varchar', 'constraint'=> 5, 'null'=> true], + 'Baud' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true], + 'Data' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true], + 'Parity' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true], + 'Stop' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('InterfaceID', true); + $this->forge->createTable('comparameters'); + + $this->forge->addField([ + 'EquipmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true], + 'DeviceName' => ['type' => 'varchar', 'constraint' => 50,'null'=> false], + 'Description' => ['type' => 'varchar', 'constraint' => 50,'null'=> false], + 'SiteID' => ['type' => 'int', 'null'=> true], + 'LocationID' => ['type' => 'int', 'null'=> true], + 'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null'=> true], + 'DID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true], + 'MachineID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true], + 'IPAddress' => ['type' => 'varchar', 'constraint'=>25, 'null'=> true], + 'CreateDate' => ['type'=>'DATETIME', 'null' => true], + 'EndDate' => ['type'=>'DATETIME', 'null' => true] + ]); + $this->forge->addKey('EquipmentID', true); + $this->forge->createTable('devicelist'); + + } + + public function down() { + $this->forge->dropTable('equipmentlist', true); + $this->forge->dropTable('comparameters', true); + $this->forge->dropTable('devicelist', true); + } +} diff --git a/app/Models/Organization/DepartmentModel.php b/app/Models/Organization/DepartmentModel.php new file mode 100644 index 0000000..30cb2fb --- /dev/null +++ b/app/Models/Organization/DepartmentModel.php @@ -0,0 +1,16 @@ + Date: Fri, 31 Oct 2025 11:11:45 +0700 Subject: [PATCH 8/8] fix update organization controller --- app/Controllers/Organization/Department.php | 2 +- app/Controllers/Organization/Discipline.php | 8 +++++++- app/Controllers/Organization/Workbench.php | 2 +- app/Controllers/Organization/Workstation.php | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Controllers/Organization/Department.php b/app/Controllers/Organization/Department.php index e929f61..178da36 100644 --- a/app/Controllers/Organization/Department.php +++ b/app/Controllers/Organization/Department.php @@ -63,7 +63,7 @@ class Department extends BaseController { $input = $this->request->getJSON(true); try { $id = $input['DepartmentID']; - $this->model->where('DepartmentID', $id)->update(); + $this->model->update($id, $input); return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); } catch (\Throwable $e) { return $this->failServerError('Something went wrong: ' . $e->getMessage()); diff --git a/app/Controllers/Organization/Discipline.php b/app/Controllers/Organization/Discipline.php index 72c47cc..56a429a 100644 --- a/app/Controllers/Organization/Discipline.php +++ b/app/Controllers/Organization/Discipline.php @@ -61,12 +61,18 @@ class Discipline extends BaseController { public function update() { $input = $this->request->getJSON(true); + $id = $input['DisciplineID']; + $this->model->update($id, $input); + return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); + /* try { $id = $input['DisciplineID']; $this->model->where('DisciplineID', $id)->update(); + echo $this->model->getLastQuery(); return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); } catch (\Throwable $e) { - return $this->failServerError('Something went wrong: ' . $e->getMessage()); + return $this->failServerError('Something went wrong: ' . $e->getMessage() ); } + */ } } \ No newline at end of file diff --git a/app/Controllers/Organization/Workbench.php b/app/Controllers/Organization/Workbench.php index ed227e9..60b05d4 100644 --- a/app/Controllers/Organization/Workbench.php +++ b/app/Controllers/Organization/Workbench.php @@ -63,7 +63,7 @@ class Workbench extends BaseController { $input = $this->request->getJSON(true); try { $id = $input['WorkbenchID']; - $this->model->where('WorkbenchID', $id)->update(); + $this->model->update($id, $input); return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); } catch (\Throwable $e) { return $this->failServerError('Something went wrong: ' . $e->getMessage()); diff --git a/app/Controllers/Organization/Workstation.php b/app/Controllers/Organization/Workstation.php index 8c5df3d..2b5aaaf 100644 --- a/app/Controllers/Organization/Workstation.php +++ b/app/Controllers/Organization/Workstation.php @@ -63,7 +63,7 @@ class Workstation extends BaseController { $input = $this->request->getJSON(true); try { $id = $input['WorkstationID']; - $this->model->where('WorkstationID', $id)->update(); + $this->model->update($id, $input); return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201); } catch (\Throwable $e) { return $this->failServerError('Something went wrong: ' . $e->getMessage());