chore: refresh CLQMS backend baseline

Re-synced controllers, configs, libraries, seeds, and docs with the latest API expectations and response helpers.
This commit is contained in:
OpenCode Bot 2026-04-08 16:07:19 +07:00
parent 02a6a1f883
commit 9946978487
365 changed files with 762 additions and 253 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
AGENTS.md Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
TODO.md Normal file → Executable file
View File

0
app/.htaccess Normal file → Executable file
View File

0
app/Common.php Normal file → Executable file
View File

0
app/Config/App.php Normal file → Executable file
View File

0
app/Config/Autoload.php Normal file → Executable file
View File

0
app/Config/Boot/development.php Normal file → Executable file
View File

0
app/Config/Boot/production.php Normal file → Executable file
View File

0
app/Config/Boot/testing.php Normal file → Executable file
View File

0
app/Config/CURLRequest.php Normal file → Executable file
View File

0
app/Config/Cache.php Normal file → Executable file
View File

0
app/Config/Constants.php Normal file → Executable file
View File

0
app/Config/ContentSecurityPolicy.php Normal file → Executable file
View File

0
app/Config/Cookie.php Normal file → Executable file
View File

0
app/Config/Cors.php Normal file → Executable file
View File

0
app/Config/Database.php Normal file → Executable file
View File

0
app/Config/DocTypes.php Normal file → Executable file
View File

0
app/Config/Email.php Normal file → Executable file
View File

0
app/Config/Encryption.php Normal file → Executable file
View File

0
app/Config/Events.php Normal file → Executable file
View File

0
app/Config/Exceptions.php Normal file → Executable file
View File

0
app/Config/Feature.php Normal file → Executable file
View File

0
app/Config/Filters.php Normal file → Executable file
View File

0
app/Config/ForeignCharacters.php Normal file → Executable file
View File

0
app/Config/Format.php Normal file → Executable file
View File

0
app/Config/Generators.php Normal file → Executable file
View File

0
app/Config/Honeypot.php Normal file → Executable file
View File

0
app/Config/Images.php Normal file → Executable file
View File

0
app/Config/Kint.php Normal file → Executable file
View File

0
app/Config/Logger.php Normal file → Executable file
View File

0
app/Config/Migrations.php Normal file → Executable file
View File

0
app/Config/Mimes.php Normal file → Executable file
View File

0
app/Config/Modules.php Normal file → Executable file
View File

0
app/Config/Optimize.php Normal file → Executable file
View File

0
app/Config/Pager.php Normal file → Executable file
View File

0
app/Config/Paths.php Normal file → Executable file
View File

0
app/Config/Publisher.php Normal file → Executable file
View File

8
app/Config/Routes.php Normal file → Executable file
View File

@ -223,18 +223,18 @@ $routes->group('api', function ($routes) {
// HostApp
$routes->group('hostapp', function ($routes) {
$routes->get('/', 'Organization\HostAppController::index');
$routes->get('(:any)', 'Organization\HostAppController::show/$1');
$routes->get('(:num)', 'Organization\HostAppController::show/$1');
$routes->post('/', 'Organization\HostAppController::create');
$routes->patch('(:any)', 'Organization\HostAppController::update/$1');
$routes->patch('(:num)', 'Organization\HostAppController::update/$1');
$routes->delete('/', 'Organization\HostAppController::delete');
});
// HostComPara
$routes->group('hostcompara', function ($routes) {
$routes->get('/', 'Organization\HostComParaController::index');
$routes->get('(:any)', 'Organization\HostComParaController::show/$1');
$routes->get('(:num)', 'Organization\HostComParaController::show/$1');
$routes->post('/', 'Organization\HostComParaController::create');
$routes->patch('(:any)', 'Organization\HostComParaController::update/$1');
$routes->patch('(:num)', 'Organization\HostComParaController::update/$1');
$routes->delete('/', 'Organization\HostComParaController::delete');
});

0
app/Config/Routing.php Normal file → Executable file
View File

0
app/Config/Security.php Normal file → Executable file
View File

0
app/Config/Services.php Normal file → Executable file
View File

0
app/Config/Session.php Normal file → Executable file
View File

0
app/Config/Toolbar.php Normal file → Executable file
View File

0
app/Config/UserAgents.php Normal file → Executable file
View File

0
app/Config/Validation.php Normal file → Executable file
View File

0
app/Config/View.php Normal file → Executable file
View File

0
app/Controllers/AreaGeoController.php Normal file → Executable file
View File

0
app/Controllers/Audit/AuditLogController.php Normal file → Executable file
View File

0
app/Controllers/AuthController.php Normal file → Executable file
View File

0
app/Controllers/AuthV2Controller.php Normal file → Executable file
View File

0
app/Controllers/BaseController.php Normal file → Executable file
View File

0
app/Controllers/CalculatorController.php Normal file → Executable file
View File

0
app/Controllers/Contact/ContactController.php Normal file → Executable file
View File

0
app/Controllers/Contact/MedicalSpecialtyController.php Normal file → Executable file
View File

0
app/Controllers/Contact/OccupationController.php Normal file → Executable file
View File

0
app/Controllers/CounterController.php Normal file → Executable file
View File

0
app/Controllers/DashboardController.php Normal file → Executable file
View File

0
app/Controllers/EdgeController.php Normal file → Executable file
View File

0
app/Controllers/HomeController.php Normal file → Executable file
View File

View File

0
app/Controllers/LocationController.php Normal file → Executable file
View File

0
app/Controllers/OrderTestController.php Normal file → Executable file
View File

27
app/Controllers/Organization/AccountController.php Normal file → Executable file
View File

@ -48,8 +48,10 @@ class AccountController extends BaseController {
public function delete() {
try {
$input = $this->request->getJSON(true);
$id = $input["AccountID"];
if (!$id) { return $this->failValidationErrors('ID is required.'); }
$id = $this->requirePatchId($input['AccountID'] ?? null, 'AccountID');
if ($id === null) {
return;
}
$this->model->delete($id);
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
} catch (\Throwable $e) {
@ -59,6 +61,17 @@ class AccountController extends BaseController {
public function create() {
$input = $this->request->getJSON(true);
$validation = service('validation');
$validation->setRules([
'AccountName' => 'required|string|max_length[255]',
'Parent' => 'permit_empty|integer',
]);
if (!$validation->run($input)) {
return $this->failValidationErrors($validation->getErrors());
}
try {
$id = $this->model->insert($input,true);
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
@ -83,6 +96,16 @@ class AccountController extends BaseController {
return $this->respond([ 'status' => 'failed', 'message' => 'Account not found', 'data' => [] ], 404);
}
$validation = service('validation');
$validation->setRules([
'AccountName' => 'permit_empty|string|max_length[255]',
'Parent' => 'permit_empty|integer',
]);
if (!$validation->run($input)) {
return $this->failValidationErrors($validation->getErrors());
}
$input['AccountID'] = $id;
try {
$this->model->update($id, $input);

2
app/Controllers/Organization/CodingSysController.php Normal file → Executable file
View File

@ -104,7 +104,7 @@ class CodingSysController extends BaseController {
try {
$this->model->update($id, $input);
return $this->respond(['status' => 'success', 'message' => 'data updated successfully', 'data' => $id], 200);
return $this->respondCreated(['status' => 'success', 'message' => 'data updated successfully', 'data' => $id], 201);
} catch (\Throwable $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}

0
app/Controllers/Organization/DepartmentController.php Normal file → Executable file
View File

41
app/Controllers/Organization/DisciplineController.php Normal file → Executable file
View File

@ -46,8 +46,10 @@ class DisciplineController extends BaseController {
public function delete() {
try {
$input = $this->request->getJSON(true);
$id = $input["DisciplineID"];
if (!$id) { return $this->failValidationErrors('ID is required.'); }
$id = $this->requirePatchId($input['DisciplineID'] ?? null, 'DisciplineID');
if ($id === null) {
return;
}
$this->model->delete($id);
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
} catch (\Throwable $e) {
@ -57,6 +59,20 @@ class DisciplineController extends BaseController {
public function create() {
$input = $this->request->getJSON(true);
$validation = service('validation');
$validation->setRules([
'DisciplineCode' => 'required|string|max_length[50]',
'DisciplineName' => 'required|string|max_length[255]',
'Parent' => 'permit_empty|integer',
'SeqScr' => 'permit_empty|integer',
'SeqRpt' => 'permit_empty|integer',
]);
if (!$validation->run($input)) {
return $this->failValidationErrors($validation->getErrors());
}
try {
$id = $this->model->insert($input,true);
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
@ -81,9 +97,26 @@ class DisciplineController extends BaseController {
return $this->respond([ 'status' => 'failed', 'message' => 'Discipline not found', 'data' => [] ], 404);
}
$validation = service('validation');
$validation->setRules([
'DisciplineCode' => 'permit_empty|string|max_length[50]',
'DisciplineName' => 'permit_empty|string|max_length[255]',
'Parent' => 'permit_empty|integer',
'SeqScr' => 'permit_empty|integer',
'SeqRpt' => 'permit_empty|integer',
]);
if (!$validation->run($input)) {
return $this->failValidationErrors($validation->getErrors());
}
$input['DisciplineID'] = $id;
$this->model->update($id, $input);
return $this->respond([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 200);
try {
$this->model->update($id, $input);
return $this->respond([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 200);
} catch (\Throwable $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}
/*
try {
$id = $input['DisciplineID'];

29
app/Controllers/Organization/HostAppController.php Normal file → Executable file
View File

@ -29,7 +29,10 @@ class HostAppController extends BaseController {
->join('site', 'site.SiteID = hostapp.SiteID', 'left');
if (!empty($filter['HostAppID'])) {
$builder->like('hostapp.HostAppID', $filter['HostAppID'], 'both');
if (!ctype_digit((string) $filter['HostAppID'])) {
return $this->failValidationErrors('HostAppID filter must be a valid integer.');
}
$builder->where('hostapp.HostAppID', (int) $filter['HostAppID']);
}
if (!empty($filter['HostAppName'])) {
$builder->like('hostapp.HostAppName', $filter['HostAppName'], 'both');
@ -45,9 +48,14 @@ class HostAppController extends BaseController {
}
public function show($HostAppID = null) {
$id = $this->requirePatchId($HostAppID, 'HostAppID');
if ($id === null) {
return;
}
$row = $this->model->select('hostapp.*, site.SiteName')
->join('site', 'site.SiteID = hostapp.SiteID', 'left')
->where('hostapp.HostAppID', $HostAppID)
->where('hostapp.HostAppID', $id)
->first();
if (empty($row)) {
@ -60,10 +68,9 @@ class HostAppController extends BaseController {
public function delete() {
try {
$input = $this->request->getJSON(true);
$id = $input['HostAppID'] ?? null;
if (!$id) {
return $this->failValidationErrors('HostAppID is required.');
$id = $this->requirePatchId($input['HostAppID'] ?? null, 'HostAppID');
if ($id === null) {
return;
}
$this->model->delete($id);
@ -77,6 +84,7 @@ class HostAppController extends BaseController {
$input = $this->request->getJSON(true);
try {
unset($input['HostAppID']);
$id = $this->model->insert($input, true);
return $this->respondCreated(['status' => 'success', 'message' => 'data created successfully', 'data' => $id], 201);
} catch (\Throwable $e) {
@ -100,11 +108,12 @@ class HostAppController extends BaseController {
return $this->respond(['status' => 'failed', 'message' => 'HostApp not found', 'data' => []], 404);
}
if (isset($input['HostAppID']) && (string) $input['HostAppID'] !== (string) $id) {
return $this->failValidationErrors('HostAppID in URL does not match body.');
if (isset($input['HostAppID'])) {
if ((string) $input['HostAppID'] !== (string) $id) {
return $this->failValidationErrors('HostAppID in URL does not match body.');
}
unset($input['HostAppID']);
}
$input['HostAppID'] = $id;
try {
$this->model->update($id, $input);
return $this->respond(['status' => 'success', 'message' => 'data updated successfully', 'data' => $id], 200);

39
app/Controllers/Organization/HostComParaController.php Normal file → Executable file
View File

@ -29,7 +29,10 @@ class HostComParaController extends BaseController {
->join('hostapp', 'hostapp.HostAppID = hostcompara.HostAppID', 'left');
if (!empty($filter['HostAppID'])) {
$builder->where('hostcompara.HostAppID', $filter['HostAppID']);
if (!ctype_digit((string) $filter['HostAppID'])) {
return $this->failValidationErrors('HostAppID filter must be a valid integer.');
}
$builder->where('hostcompara.HostAppID', (int) $filter['HostAppID']);
}
if (!empty($filter['HostIP'])) {
$builder->like('hostcompara.HostIP', $filter['HostIP'], 'both');
@ -45,9 +48,14 @@ class HostComParaController extends BaseController {
}
public function show($HostAppID = null) {
$id = $this->requirePatchId($HostAppID, 'HostAppID');
if ($id === null) {
return;
}
$row = $this->model->select('hostcompara.*, hostapp.HostAppName')
->join('hostapp', 'hostapp.HostAppID = hostcompara.HostAppID', 'left')
->where('hostcompara.HostAppID', $HostAppID)
->where('hostcompara.HostAppID', $id)
->first();
if (empty($row)) {
@ -60,10 +68,9 @@ class HostComParaController extends BaseController {
public function delete() {
try {
$input = $this->request->getJSON(true);
$id = $input['HostAppID'] ?? null;
if (!$id) {
return $this->failValidationErrors('HostAppID is required.');
$id = $this->requirePatchId($input['HostAppID'] ?? null, 'HostAppID');
if ($id === null) {
return;
}
$this->model->delete($id);
@ -77,6 +84,17 @@ class HostComParaController extends BaseController {
$input = $this->request->getJSON(true);
try {
$hostAppId = $input['HostAppID'] ?? null;
if ($hostAppId === null) {
return $this->failValidationErrors('HostAppID is required.');
}
if (!ctype_digit((string) $hostAppId)) {
return $this->failValidationErrors('HostAppID must be a valid integer.');
}
$input['HostAppID'] = (int) $hostAppId;
$id = $this->model->insert($input, true);
return $this->respondCreated(['status' => 'success', 'message' => 'data created successfully', 'data' => $id], 201);
} catch (\Throwable $e) {
@ -100,12 +118,13 @@ class HostComParaController extends BaseController {
return $this->respond(['status' => 'failed', 'message' => 'HostComPara not found', 'data' => []], 404);
}
if (isset($input['HostAppID']) && (string) $input['HostAppID'] !== (string) $id) {
return $this->failValidationErrors('HostAppID in URL does not match body.');
if (isset($input['HostAppID'])) {
if ((string) $input['HostAppID'] !== (string) $id) {
return $this->failValidationErrors('HostAppID in URL does not match body.');
}
unset($input['HostAppID']);
}
$input['HostAppID'] = $id;
try {
$this->model->update($id, $input);
return $this->respond(['status' => 'success', 'message' => 'data updated successfully', 'data' => $id], 200);

0
app/Controllers/Organization/SiteController.php Normal file → Executable file
View File

0
app/Controllers/Organization/WorkstationController.php Normal file → Executable file
View File

0
app/Controllers/PagesController.php Normal file → Executable file
View File

0
app/Controllers/PatVisitController.php Normal file → Executable file
View File

0
app/Controllers/Patient/PatientController.php Normal file → Executable file
View File

0
app/Controllers/ReportController.php Normal file → Executable file
View File

0
app/Controllers/Result/ResultValueSetController.php Normal file → Executable file
View File

0
app/Controllers/ResultController.php Normal file → Executable file
View File

0
app/Controllers/Rule/RuleController.php Normal file → Executable file
View File

0
app/Controllers/SampleController.php Normal file → Executable file
View File

2
app/Controllers/Specimen/ContainerDefController.php Normal file → Executable file
View File

@ -104,7 +104,7 @@ class ContainerDefController extends BaseController {
$input['ConDefID'] = $id;
try {
$this->model->update($id, $input);
return $this->respond([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 200);
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}

View File

@ -85,10 +85,12 @@ class SpecimenCollectionController extends BaseController {
}
$input['SpcColID'] = $id;
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
if ($this->rules !== [] && !$this->validateData($input, $this->rules)) {
return $this->failValidationErrors($this->validator->getErrors());
}
try {
$this->model->update($id, $input);
return $this->respond([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 200);
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}

0
app/Controllers/Specimen/SpecimenController.php Normal file → Executable file
View File

6
app/Controllers/Specimen/SpecimenPrepController.php Normal file → Executable file
View File

@ -70,10 +70,12 @@ class SpecimenPrepController extends BaseController {
}
$input['SpcPrpID'] = $id;
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
if ($this->rules !== [] && !$this->validateData($input, $this->rules)) {
return $this->failValidationErrors($this->validator->getErrors());
}
try {
$this->model->update($id, $input);
return $this->respond([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 200);
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}

6
app/Controllers/Specimen/SpecimenStatusController.php Normal file → Executable file
View File

@ -83,10 +83,12 @@ class SpecimenStatusController extends BaseController {
}
$input['SpcStaID'] = $id;
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
if ($this->rules !== [] && !$this->validateData($input, $this->rules)) {
return $this->failValidationErrors($this->validator->getErrors());
}
try {
$this->model->update($id, $input);
return $this->respond([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 200);
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}

0
app/Controllers/Test/DemoOrderController.php Normal file → Executable file
View File

0
app/Controllers/Test/TestMapController.php Normal file → Executable file
View File

0
app/Controllers/Test/TestMapDetailController.php Normal file → Executable file
View File

0
app/Controllers/Test/TestsController.php Normal file → Executable file
View File

0
app/Controllers/User/UserController.php Normal file → Executable file
View File

0
app/Controllers/ValueSetController.php Normal file → Executable file
View File

0
app/Controllers/ValueSetDefController.php Normal file → Executable file
View File

0
app/Controllers/ZonesController.php Normal file → Executable file
View File

0
app/Database/Migrations/.gitkeep Normal file → Executable file
View File

View File

View File

View File

View File

View File

Some files were not shown because too many files have changed in this diff Show More