From a450392cfc9b54614657a7de924bac0399b5ff7a Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Mon, 10 Nov 2025 16:02:52 +0700 Subject: [PATCH 1/5] standard crud for specimen and test --- app/Config/Routes.php | 59 ++++++++++++++++++ app/Controllers/Specimen/Specimen.php | 62 +++++++++++++++++++ .../Specimen/SpecimenCollection.php | 62 +++++++++++++++++++ app/Controllers/Specimen/SpecimenPrep.php | 62 +++++++++++++++++++ app/Controllers/Specimen/SpecimenStatus.php | 62 +++++++++++++++++++ .../Test/{ValueSetDef.php => TestDef.php} | 33 +++------- app/Controllers/Test/TestDefCal.php | 56 +++++++++++++++++ app/Controllers/Test/TestDefSite.php | 56 +++++++++++++++++ app/Controllers/Test/TestDefTech.php | 56 +++++++++++++++++ app/Controllers/Test/TestGrp.php | 56 +++++++++++++++++ app/Controllers/Test/TestMap.php | 56 +++++++++++++++++ .../Migrations/2025-10-07-132705_Specimen.php | 18 +++--- .../Migrations/2025-10-11-100001_Test.php | 30 ++++++--- app/Models/Specimen/ContainerDefModel.php | 5 -- .../Specimen/SpecimenCollectionModel.php | 18 ++++++ app/Models/Specimen/SpecimenLogModel.php | 16 +++++ app/Models/Specimen/SpecimenModel.php | 18 ++++++ app/Models/Specimen/SpecimenPrepModel.php | 17 +++++ app/Models/Specimen/SpecimenStatusModel.php | 18 ++++++ app/Models/Test/TestDefCalModel.php | 2 +- app/Models/Test/TestDefModel.php | 2 +- app/Models/Test/TestDefTechModel.php | 3 +- app/Models/Test/TestMapModel.php | 19 ++++++ 23 files changed, 738 insertions(+), 48 deletions(-) create mode 100644 app/Controllers/Specimen/Specimen.php create mode 100644 app/Controllers/Specimen/SpecimenCollection.php create mode 100644 app/Controllers/Specimen/SpecimenPrep.php create mode 100644 app/Controllers/Specimen/SpecimenStatus.php rename app/Controllers/Test/{ValueSetDef.php => TestDef.php} (62%) create mode 100644 app/Controllers/Test/TestDefCal.php create mode 100644 app/Controllers/Test/TestDefSite.php create mode 100644 app/Controllers/Test/TestDefTech.php create mode 100644 app/Controllers/Test/TestGrp.php create mode 100644 app/Controllers/Test/TestMap.php create mode 100644 app/Models/Specimen/SpecimenCollectionModel.php create mode 100644 app/Models/Specimen/SpecimenLogModel.php create mode 100644 app/Models/Specimen/SpecimenModel.php create mode 100644 app/Models/Specimen/SpecimenPrepModel.php create mode 100644 app/Models/Specimen/SpecimenStatusModel.php create mode 100644 app/Models/Test/TestMapModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 398871f..4323717 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -126,6 +126,65 @@ $routes->post('/api/organization/workstation', 'Organization\Workstation::create $routes->patch('/api/organization/workstation', 'Organization\Workstation::update'); $routes->delete('/api/organization/workstation', 'Organization\Workstation::delete'); +$routes->group('api/specimen', function($routes) { + $routes->get('/containerdef/(:num)', 'Specimen\ContainerDef::show/$1'); + $routes->post('/containerdef', 'Specimen\ContainerDef::create'); + $routes->patch('/containerdef', 'Specimen\ContainerDef::update'); + $routes->get('/containerdef', 'Specimen\ContainerDef::index'); + + $routes->get('/prep/(:num)', 'Specimen\Prep::show/$1'); + $routes->post('/prep', 'Specimen\Prep::create'); + $routes->patch('/prep', 'Specimen\Prep::update'); + $routes->get('/prep', 'Specimen\Prep::index'); + + $routes->get('/status/(:num)', 'Specimen\Status::show/$1'); + $routes->post('/status', 'Specimen\Status::create'); + $routes->patch('/status', 'Specimen\Status::update'); + $routes->get('/status', 'Specimen\Status::index'); + + $routes->get('/collection/(:num)', 'Specimen\Collection::show/$1'); + $routes->post('/collection', 'Specimen\Collection::create'); + $routes->patch('/collection', 'Specimen\Collection::update'); + $routes->get('/collection', 'Specimen\Collection::index'); + + $routes->get('(:num)', 'Specimen\Specimen::show/$1'); + $routes->post('', 'Specimen\Specimen::create'); + $routes->patch('', 'Specimen\Specimen::update'); + $routes->get('', 'Specimen\Specimen::index'); +}); + +$routes->group('api/test', function($routes) { + $routes->get('testdeftech/(:num)', 'Test\TestDefTech::show/$1'); + $routes->post('testdeftech', 'Test\TestDefTech::create'); + $routes->patch('testdeftech', 'Test\TestDefTech::update'); + $routes->get('testdeftech/', 'Test\TestDefTech::index'); + + $routes->get('testdefcal/(:num)', 'Test\TestDefCal::show/$1'); + $routes->post('testdefcal', 'Test\TestDefCal::create'); + $routes->patch('testdefcal', 'Test\TestDefCal::update'); + $routes->get('testdefcal/', 'Test\TestDefCal::index'); + + $routes->get('testgrp/(:num)', 'Test\TestGrp::show/$1'); + $routes->post('testgrp', 'Test\TestGrp::create'); + $routes->patch('testgrp', 'Test\TestGrp::update'); + $routes->get('testgrp/', 'Test\TestGrp::index'); + + $routes->get('testdefsite/(:num)', 'Test\TestDefSite::show/$1'); + $routes->post('testdefsite', 'Test\TestDefSite::create'); + $routes->patch('testdefsite', 'Test\TestDefSite::update'); + $routes->get('testdefsite/', 'Test\TestDefSite::index'); + + $routes->get('testmap/(:num)', 'Test\TestMap::show/$1'); + $routes->post('testmap', 'Test\TestMap::create'); + $routes->patch('testmap', 'Test\TestMap::update'); + $routes->get('testmap/', 'Test\TestMap::index'); + + $routes->get('testdef/(:num)', 'Test\TestDef::show/$1'); + $routes->post('testdef', 'Test\TestDef::create'); + $routes->patch('testdef', 'Test\TestDef::update'); + $routes->get('testdef', 'Test\TestDef::index'); +}); + // Khusus $routes->get('/api/zones', 'Zones::index'); $routes->get('/api/zones/synchronize', 'Zones::synchronize'); diff --git a/app/Controllers/Specimen/Specimen.php b/app/Controllers/Specimen/Specimen.php new file mode 100644 index 0000000..b7ff7ee --- /dev/null +++ b/app/Controllers/Specimen/Specimen.php @@ -0,0 +1,62 @@ +db = \Config\Database::connect(); + $this->model = new SpecimenModel(); + $this->rules = []; + } + + public function index() { + try { + $rows = $this->model->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function show($id) { + try { + $rows = $this->model->where('SID',$id)->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->update($input['SID'], $input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Specimen/SpecimenCollection.php b/app/Controllers/Specimen/SpecimenCollection.php new file mode 100644 index 0000000..edcf5af --- /dev/null +++ b/app/Controllers/Specimen/SpecimenCollection.php @@ -0,0 +1,62 @@ +db = \Config\Database::connect(); + $this->model = new SpecimenCollectionModel(); + $this->rules = []; + } + + public function index() { + try { + $rows = $this->model->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function show($id) { + try { + $rows = $this->model->where('SpcColID', $id)->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->update($input['SpcColID'], $input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Specimen/SpecimenPrep.php b/app/Controllers/Specimen/SpecimenPrep.php new file mode 100644 index 0000000..ac9608c --- /dev/null +++ b/app/Controllers/Specimen/SpecimenPrep.php @@ -0,0 +1,62 @@ +db = \Config\Database::connect(); + $this->model = new SpecimenPrepModel(); + $this->rules = []; + } + + public function index() { + try { + $rows = $this->model->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function show($id) { + try { + $rows = $this->model->where('SpcPrpID', $id)->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->update($input['SpcPrpID'], $input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Specimen/SpecimenStatus.php b/app/Controllers/Specimen/SpecimenStatus.php new file mode 100644 index 0000000..f94f263 --- /dev/null +++ b/app/Controllers/Specimen/SpecimenStatus.php @@ -0,0 +1,62 @@ +db = \Config\Database::connect(); + $this->model = new SpecimenStatusModel(); + $this->rules = []; + } + + public function index() { + try { + $rows = $this->model->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function show($id) { + try { + $rows = $this->model->where('SpcStaID', $id)->findAll(); + return $this->respond([ 'status' => 'success', 'message'=> "data fetched successfully", 'data' => $rows ], 200); + } catch (\Exception $e) { + return $this->failServerError('Exception : '.$e->getMessage()); + } + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->update($input['SpcStaID'], $input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Test/ValueSetDef.php b/app/Controllers/Test/TestDef.php similarity index 62% rename from app/Controllers/Test/ValueSetDef.php rename to app/Controllers/Test/TestDef.php index bea445c..477660f 100644 --- a/app/Controllers/Test/ValueSetDef.php +++ b/app/Controllers/Test/TestDef.php @@ -1,5 +1,5 @@ request->getVar('param'); - $rows = $this->model->getValueSetDefs($param); + $rows = $this->model->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); } - public function show($VSetID = null) { - $rows = $this->model->find($VSetID); + public function show($id = null) { + $rows = $this->model->where('TestID',$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); } @@ -34,8 +33,8 @@ class TestDef extends BaseController { $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" ]); + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); } catch (\Exception $e) { return $this->failServerError('Something went wrong: ' . $e->getMessage()); } @@ -43,27 +42,15 @@ class TestDef extends BaseController { public function update() { $input = $this->request->getJSON(true); - $VSetID = $input["VID"]; - if (!$VSetID) { return $this->failValidationErrors('VSetID is required.'); } + $id = $input["TestID"]; + if (!$id) { return $this->failValidationErrors('TestID 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" ]); + $this->model->update($id,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id 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/Controllers/Test/TestDefCal.php b/app/Controllers/Test/TestDefCal.php new file mode 100644 index 0000000..ffa7451 --- /dev/null +++ b/app/Controllers/Test/TestDefCal.php @@ -0,0 +1,56 @@ +db = \Config\Database::connect(); + $this->model = new TestDefCalModel; + } + + 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'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + public function show($id = null) { + $rows = $this->model->where('TestCalID',$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); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $id = $input["TestCalID"]; + if (!$id) { return $this->failValidationErrors('TestCalID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($id,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Test/TestDefSite.php b/app/Controllers/Test/TestDefSite.php new file mode 100644 index 0000000..7ed6a3a --- /dev/null +++ b/app/Controllers/Test/TestDefSite.php @@ -0,0 +1,56 @@ +db = \Config\Database::connect(); + $this->model = new TestDefSiteModel; + } + + 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'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + public function show($id = null) { + $rows = $this->model->where('TestSiteID',$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); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $id = $input["TestSiteID"]; + if (!$id) { return $this->failValidationErrors('TestSiteID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($id,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Test/TestDefTech.php b/app/Controllers/Test/TestDefTech.php new file mode 100644 index 0000000..d7e0cc4 --- /dev/null +++ b/app/Controllers/Test/TestDefTech.php @@ -0,0 +1,56 @@ +db = \Config\Database::connect(); + $this->model = new TestDefTechModel; + } + + 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'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + public function show($id = null) { + $rows = $this->model->where('TestTechID',$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); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $id = $input["TestTechID"]; + if (!$id) { return $this->failValidationErrors('TestTechID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($id,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Test/TestGrp.php b/app/Controllers/Test/TestGrp.php new file mode 100644 index 0000000..dea1606 --- /dev/null +++ b/app/Controllers/Test/TestGrp.php @@ -0,0 +1,56 @@ +db = \Config\Database::connect(); + $this->model = new TestGrpModel; + } + + 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'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + public function show($id = null) { + $rows = $this->model->where('TestGrpID',$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); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $id = $input["TestGrpID"]; + if (!$id) { return $this->failValidationErrors('TestGrpID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($id,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Controllers/Test/TestMap.php b/app/Controllers/Test/TestMap.php new file mode 100644 index 0000000..bfe90ff --- /dev/null +++ b/app/Controllers/Test/TestMap.php @@ -0,0 +1,56 @@ +db = \Config\Database::connect(); + $this->model = new TestMapModel; + } + + 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'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + 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); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $id = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $id = $input["TestMapID"]; + if (!$id) { return $this->failValidationErrors('TestMapID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($id,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $id updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Database/Migrations/2025-10-07-132705_Specimen.php b/app/Database/Migrations/2025-10-07-132705_Specimen.php index 8035d97..20fe325 100644 --- a/app/Database/Migrations/2025-10-07-132705_Specimen.php +++ b/app/Database/Migrations/2025-10-07-132705_Specimen.php @@ -29,7 +29,7 @@ class CreateSpecimenTable extends Migration { 'SiteID' => ['type' => 'INT', 'null' => true], 'OrderID' => ['type' => 'INT', 'null' => true], 'ConDefID' => ['type' => 'INT', 'null' => true], - 'Parent' => ['type' => 'int', 'null' => true], + 'Parent' => ['type' => 'varchar', 'constraint' => 30, 'null' => true], 'Qty' => ['type' => 'INT', 'null' => true], 'Unit' => ['type' => 'varchar', 'constraint'=> 30, 'null' => true], 'GenerateBy' => ['type' => 'int', 'null' => true], @@ -40,11 +40,12 @@ class CreateSpecimenTable extends Migration { ]); $this->forge->addKey('InternalSID', true); $this->forge->addUniqueKey('SID'); - $this->forge->createTable('specimens'); + $this->forge->createTable('specimen'); $this->forge->addField([ 'SpcStaID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'SID' => ['type' => 'VARCHAR', 'constraint' => 30, 'null' => false], + 'OrderID' => ['type' => 'int', 'null' => false], 'SpcAct' => ['type' => 'varchar', 'constraint' => 15, 'null' => true], 'ActRes' => ['type' => 'INT', 'null' => true], 'SpcStatus' => ['type' => 'int', 'null' => true], @@ -59,6 +60,7 @@ class CreateSpecimenTable extends Migration { 'GeoLocationData' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ], 'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ], 'DID' => ['type' => 'varchar', 'constraint'=>10, 'null' => true ], + 'UserID' => ['type' => 'int', 'null' => true ], 'CreateDate' => ['type' => 'Datetime', 'null' => true], 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchiveDate' => ['type' => 'DATETIME', 'null' => true] @@ -69,9 +71,9 @@ class CreateSpecimenTable extends Migration { $this->forge->addField([ 'SpcColID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'SpcStaID' => ['type' => 'INT', 'unsigned' => true], - 'SpcRole' => ['type' => 'varchar', 'constraint' => 15, 'null' => true], - 'ColMethod' => ['type' => 'varchar', 'constraint' => 15, 'null' => true], - 'BodySite' => ['type' => 'varchar', 'constraint' => 15, 'null' => true], + 'SpcRole' => ['type' => 'int', 'null' => true], + 'ColMethod' => ['type' => 'int', 'null' => true], + 'BodySite' => ['type' => 'int', 'null' => true], 'CntSize' => ['type' => 'INT', 'null' => true], 'FastingVolume' => ['type' => 'varchar', 'constraint'=> 2, 'null' => true], 'ColStart' => ['type' => 'datetime', 'null' => true], @@ -87,10 +89,10 @@ class CreateSpecimenTable extends Migration { 'SpcPrpID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'SpcStaID' => ['type' => 'INT', 'unsigned' => true], 'Description' => ['type' => 'varchar', 'constraint' => 150, 'null' => true], - 'Method' => ['type' => 'varchar', 'constraint' => 15, 'null' => true], - 'Additive' => ['type' => 'varchar', 'constraint' => 15, 'null' => true], + 'Method' => ['type' => 'int', 'null' => true], + 'Additive' => ['type' => 'int', 'null' => true], 'AddQty' => ['type' => 'float', 'null' => true], - 'AddUnit' => ['type' => 'varchar', 'constraint'=> 15, 'null' => true], + 'AddUnit' => ['type' => 'int', 'null' => true], 'PrepStart' => ['type' => 'datetime', 'null' => true], 'PrepEnd' => ['type' => 'datetime', 'null' => true], 'CreateDate' => ['type' => 'Datetime', 'null' => true], diff --git a/app/Database/Migrations/2025-10-11-100001_Test.php b/app/Database/Migrations/2025-10-11-100001_Test.php index eab0ac1..884d8f2 100644 --- a/app/Database/Migrations/2025-10-11-100001_Test.php +++ b/app/Database/Migrations/2025-10-11-100001_Test.php @@ -8,7 +8,7 @@ class CreateTestsTable extends Migration { public function up() { $this->forge->addField([ 'TestID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], - 'ParentTest' => ['type' => 'INT', 'null' => true], + 'Parent' => ['type' => 'INT', 'null' => true], 'TestCode' => ['type' => 'VARCHAR', 'constraint'=> 6, 'null' => false], 'TestName' => ['type' => 'varchar', 'constraint'=> 50, 'null' => false], 'Description' => ['type' => 'VARCHAR', 'constraint'=> 150, 'null' => false], @@ -27,7 +27,7 @@ class CreateTestsTable extends Migration { 'SiteID' => ['type' => 'INT', 'null' => false], 'TestSiteCode' => ['type' => 'varchar', 'constraint'=> 6, 'null' => false], 'TestSiteName' => ['type' => 'varchar', 'constraint'=> 50, 'null' => false], - 'Type' => ['type' => 'int', 'null' => false], + 'Type' => ['type' => 'int', 'null' => false], 'Description' => ['type' => 'varchar', 'constraint'=> 150, 'null' => true], 'SeqScr' => ['type' => 'int', 'null' => false], 'SeqRpt' => ['type' => 'int', 'null' => false], @@ -57,11 +57,7 @@ class CreateTestsTable extends Migration { 'Factor' => ['type' => 'int', 'null' => true], 'Unit2' => ['type' => 'varchar', 'constraint'=>20, 'null' => true], 'Decimal' => ['type' => 'int', 'null' => true], - 'Collreq' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], - 'ConDefID' => ['type' => 'int', 'null' => true], - 'TestTechCode' => ['type' => 'varchar', 'constraint'=>6, 'null' => true], - 'TestTechAbb' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], - 'TestTechName' => ['type' => 'varchar', 'constraint'=>150, 'null' => true], + 'CollReq' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], 'Method' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], 'ExpectedTAT' => ['type' => 'INT', 'null' => true], 'CreateDate' => ['type' => 'Datetime', 'null' => true], @@ -74,8 +70,9 @@ class CreateTestsTable extends Migration { 'TestCalID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], 'SiteID' => ['type' => 'INT', 'null' => true], 'TestSiteID' => ['type' => 'INT', 'null' => true], + 'DisciplineID' => ['type' => 'INT', 'null' => true], + 'DepartmentID' => ['type' => 'INT', 'null' => true], 'FormulaCode' => ['type' => 'varchar', 'constraint'=>150, 'null' => true], - 'FormulaLang' => ['type' => 'varchar', 'constraint'=>20, 'null' => true], 'FormulaInput' => ['type' => 'varchar', 'constraint'=>20, 'null' => true], 'Unit1' => ['type' => 'varchar', 'constraint'=>20, 'null' => true], 'Factor' => ['type' => 'int', 'null' => true], @@ -98,6 +95,22 @@ class CreateTestsTable extends Migration { $this->forge->addKey('TestGrpID', true); $this->forge->createTable('testgrp'); + $this->forge->addField([ + 'TestMapID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true], + 'HostType' => ['type' => 'int', 'null' => true], + 'HostID' => ['type' => 'int', 'null' => true], + 'HostDataSource' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], + 'HostTestCode' => ['type' => 'varchar', 'constraint'=>10, 'null' => true], + 'HostTestName' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], + 'ClientType' => ['type' => 'int', 'null' => true], + 'ClientID' => ['type' => 'int', 'null' => true], + 'ClientTestCode' => ['type' => 'varchar', 'constraint'=>10, 'null' => true], + 'ClientTestName' => ['type' => 'varchar', 'constraint'=>50, 'null' => true], + 'CreateDate' => ['type' => 'Datetime', 'null' => true], + 'EndDate' => ['type' => 'Datetime', 'null' => true] + ]); + $this->forge->addKey('TestMapID', true); + $this->forge->createTable('testmap'); } public function down() { @@ -106,5 +119,6 @@ class CreateTestsTable extends Migration { $this->forge->dropTable('testdeftech'); $this->forge->dropTable('testdefcal'); $this->forge->dropTable('testgrp'); + $this->forge->dropTable('testmap'); } } \ No newline at end of file diff --git a/app/Models/Specimen/ContainerDefModel.php b/app/Models/Specimen/ContainerDefModel.php index df83524..bec4a8f 100644 --- a/app/Models/Specimen/ContainerDefModel.php +++ b/app/Models/Specimen/ContainerDefModel.php @@ -14,11 +14,6 @@ class ContainerDefModel extends BaseModel { protected $useSoftDeletes = true; protected $deletedField = 'EndDate'; - protected $beforeInsert = ['normalizeDatesToUTC']; - protected $beforeUpdate = ['normalizeDatesToUTC']; - protected $afterFind = ['convertDatesToUTCISO']; - protected $afterInsert = ['convertDatesToUTCISO']; - protected $afterUpdate = ['convertDatesToUTCISO']; public function getContainer($ConDefID) { $rows = $this->select('containerdef.*, vscol.VValue as ColorTxt, vscla.VValue as ConClassTxt, vsadd.VValue as AdditiveTxt') diff --git a/app/Models/Specimen/SpecimenCollectionModel.php b/app/Models/Specimen/SpecimenCollectionModel.php new file mode 100644 index 0000000..13a5a4f --- /dev/null +++ b/app/Models/Specimen/SpecimenCollectionModel.php @@ -0,0 +1,18 @@ + Date: Wed, 12 Nov 2025 15:26:18 +0700 Subject: [PATCH 2/5] fix patvisit --- app/Models/PatVisit/PatVisitModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 714f282..556638d 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -20,7 +20,7 @@ class PatVisitModel extends BaseModel { protected $visnum_prefix = "DV"; public function show($PVID) { - $rows = $this->select("*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") + $rows = $this->select("patvisit.*, 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(); @@ -28,7 +28,7 @@ class PatVisitModel extends BaseModel { } public function showByPatient($InternalPID) { - $rows = $this->select("*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") + $rows = $this->select("patvisit.*, 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('(SELECT a1.* FROM patvisitadt a1 From 2096ede1e57cab1da46e43df13e31e0fe56030ba Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Wed, 12 Nov 2025 15:58:01 +0700 Subject: [PATCH 3/5] update patvisit --- app/Models/PatVisit/PatVisitModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 556638d..a8ccf2d 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -20,7 +20,7 @@ class PatVisitModel extends BaseModel { protected $visnum_prefix = "DV"; public function show($PVID) { - $rows = $this->select("patvisit.*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") + $rows = $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(); @@ -28,7 +28,7 @@ class PatVisitModel extends BaseModel { } public function showByPatient($InternalPID) { - $rows = $this->select("patvisit.*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") + $rows = $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('(SELECT a1.* FROM patvisitadt a1 From 21abee18315ee615dc40a73e5bd27e5e2e7a7a2b Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Wed, 12 Nov 2025 16:02:31 +0700 Subject: [PATCH 4/5] fix patvisit InternalPID --- app/Models/PatVisit/PatVisitModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index a8ccf2d..1104e5d 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -20,7 +20,7 @@ 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") + $rows = $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(); @@ -28,7 +28,7 @@ class PatVisitModel extends BaseModel { } public function showByPatient($InternalPID) { - $rows = $this->select("*, patvisit.internalPID, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate") + $rows = $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('(SELECT a1.* FROM patvisitadt a1 From 8af8fea0baab0f3aff3ce9193004a4da19df51e1 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Thu, 13 Nov 2025 13:49:24 +0700 Subject: [PATCH 5/5] preworking pvadt --- .../2025-09-09-155526_Pat_Visit.php | 21 +++++----- app/Database/Seeds/DummySeeder.php | 38 +++++++++++++------ app/Models/PatVisit/PatVisitADTModel.php | 2 +- app/Models/PatVisit/PatVisitModel.php | 2 +- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php b/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php index 167d550..6ca3072 100644 --- a/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php +++ b/app/Database/Migrations/2025-09-09-155526_Pat_Visit.php @@ -39,18 +39,19 @@ class CreatePVTables extends Migration { // patvisitadt $this->forge->addField([ - 'PVADTID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true], - 'InternalPVID'=> ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], - 'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], - 'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'PVADTID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], + 'InternalPVID'=> ['type' => 'INT', 'null' => true], + 'Sequence' => ['type' => 'INT', 'null' => true], + 'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], + 'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], + 'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true], 'CreateDate' => ['type' => 'DATETIME', 'null' => true], - 'EndDate' => ['type' => 'DATETIME', 'null' => true], + 'EndDate' => ['type' => 'DATETIME', 'null' => true], 'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true], - 'DelDate' => ['type' => 'DATETIME', 'null' => true], + 'DelDate' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('PVADTID', true); $this->forge->createTable('patvisitadt'); diff --git a/app/Database/Seeds/DummySeeder.php b/app/Database/Seeds/DummySeeder.php index 73b3242..5ab8d3f 100644 --- a/app/Database/Seeds/DummySeeder.php +++ b/app/Database/Seeds/DummySeeder.php @@ -6,8 +6,11 @@ use CodeIgniter\Database\Seeder; class DummySeeder extends Seeder { + protected array $map = []; + public function run() { $now = date('Y-m-d H:i:s'); + // location $data = [ ['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing', 'CreateDate'=> "$now" ], @@ -52,17 +55,13 @@ class DummySeeder extends Seeder { // patient $data = [ - [ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'Gender'=>'6', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'EmailAddress1'=>'smaj1@5panda.id', - 'Province'=>'1', 'City'=>'37', 'Country'=>'325', 'Race'=>'175', 'Religion'=>'207', 'Ethnic'=>'218', 'DeathIndicator' => '16', 'CreateDate'=> "$now"], - [ 'InternalPID'=>2, 'PatientID'=>'SMAJ2', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient F', 'Gender'=>'6', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj2@5panda.id', - 'Province'=>'2', 'City'=>'60', 'Country'=>'325', 'Race'=>'176', 'Religion'=>'206', 'Ethnic'=>'219', 'DeathIndicator' => '16', 'CreateDate'=> "$now"], - [ 'InternalPID'=>3, 'PatientID'=>'SMAJ3', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient L', 'Gender'=>'6', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj3@5panda.id', - 'Province'=>'3', 'City'=>'103', 'Country'=>'325', 'Race'=>'176', 'Religion'=>'206', 'Ethnic'=>'219', 'DeathIndicator' => '16', 'CreateDate'=> "$now"] + [ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'EmailAddress1'=>'smaj1@5panda.id', 'CreateDate'=> "$now"], + [ 'InternalPID'=>2, 'PatientID'=>'SMAJ2', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient F', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj2@5panda.id', 'CreateDate'=> "$now"], + [ 'InternalPID'=>3, 'PatientID'=>'SMAJ3', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient L', 'BirthDate'=>'1997-02-02', 'Street_1'=>'Manila', 'EmailAddress1'=>'smaj3@5panda.id', 'CreateDate'=> "$now"] ]; $this->db->table('patient')->insertBatch($data); $data = [ [ 'InternalPID'=>1, 'IdentifierType'=>'KTP', 'Identifier'=>'9901', 'CreateDate'=> "$now" ], - // [ 'InternalPID'=>2, 'IdentifierType'=>'KTP', 'Identifier'=>'9902', 'CreateDate'=> "$now" ], [ 'InternalPID'=>3, 'IdentifierType'=>'KTP', 'Identifier'=>'9903', 'CreateDate'=> "$now" ] ]; $this->db->table('patidt')->insertBatch($data); @@ -76,13 +75,30 @@ class DummySeeder extends Seeder { ]; $this->db->table('patatt')->insertBatch($data); - + // patvisit + $data = [ + ['InternalPVID'=>1, "PVID"=>"XLAB0001", "InternalPID"=>1, "EpisodeID"=>1, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "PVID"=>"XLAB0002", "InternalPID"=>1, "EpisodeID"=>1, "CreateDate"=>"$now"], + ]; + $this->db->table('patvisit')->insertBatch($data); + + $data = [ + ['InternalPVID'=>1, "Sequence"=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>1, "Sequence"=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"], + ['InternalPVID'=>1, "Sequence"=>3, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>1, "Sequence"=>4, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>3, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"], + ['InternalPVID'=>2, "Sequence"=>4, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"], + ]; + $this->db->table('patvisitadt')->insertBatch($data); // Organization $data = [ - [ 'AccountID' => 1, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'194', 'Province'=>'11', 'ZIP'=>'505', 'Country'=>'325', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], - [ 'AccountID' => 2, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'189', 'Province'=>'11', 'ZIP'=>'505', 'Country'=>'325', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], - [ 'AccountID' => 3, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'City'=>'194', 'Province'=>'11', 'ZIP'=>'505', 'Country'=>'325', 'AreaCode'=>'', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ] + [ 'AccountID' => 1, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], + [ 'AccountID' => 2, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ], + [ 'AccountID' => 3, 'Parent' => null, 'AccountName' => 'Dummy Account', 'Initial'=>'QAC', 'Street_1'=>'Dummy Address', 'EmailAddress1'=>'dummy@summit.co.id', 'Phone'=>'092029', 'Fax'=>'092029', 'CreateDate' => "$now" ] ]; $this->db->table('account')->insertBatch($data); diff --git a/app/Models/PatVisit/PatVisitADTModel.php b/app/Models/PatVisit/PatVisitADTModel.php index 33c9037..1683fea 100644 --- a/app/Models/PatVisit/PatVisitADTModel.php +++ b/app/Models/PatVisit/PatVisitADTModel.php @@ -6,7 +6,7 @@ use App\Models\BaseModel; class PatVisitADTModel extends BaseModel { protected $table = 'patvisitadt'; protected $primaryKey = 'PVADTID'; - protected $allowedFields = ['InternalPVID', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc', + protected $allowedFields = ['InternalPVID', 'Sequence', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc', 'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate']; protected $visnum_prefix; diff --git a/app/Models/PatVisit/PatVisitModel.php b/app/Models/PatVisit/PatVisitModel.php index 1104e5d..dae06b0 100644 --- a/app/Models/PatVisit/PatVisitModel.php +++ b/app/Models/PatVisit/PatVisitModel.php @@ -108,7 +108,7 @@ class PatVisitModel extends BaseModel { $tmp = $modelPD->insert($input['PatDiag']); } } - if ($tmp === false) { + if (isset($tmp) && $tmp === false) { $error = $db->error(); throw new \Exception("Failed to update PatDiag record. ". $error['message']); }