standard crud for specimen and test

This commit is contained in:
mahdahar 2025-11-10 16:02:52 +07:00
parent 0e4b9824f7
commit a450392cfc
23 changed files with 738 additions and 48 deletions

View File

@ -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');

View File

@ -0,0 +1,62 @@
<?php
namespace App\Controllers\Specimen;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Specimen\SpecimenModel;
class Specimen extends BaseController {
use ResponseTrait;
protected $db;
protected $model;
protected $rules;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace App\Controllers\Specimen;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Specimen\SpecimenCollectionModel;
class SpecimenCollection extends BaseController {
use ResponseTrait;
protected $db;
protected $model;
protected $rules;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace App\Controllers\Specimen;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Specimen\SpecimenPrepModel;
class SpecimenPrep extends BaseController {
use ResponseTrait;
protected $db;
protected $model;
protected $rules;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace App\Controllers\Specimen;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Specimen\SpecimenStatusModel;
class ContainerDef extends BaseController {
use ResponseTrait;
protected $db;
protected $model;
protected $rules;
public function __construct() {
$this->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());
}
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace App\Controllers\ValueSet;
namespace App\Controllers\Test;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
@ -18,14 +18,13 @@ class TestDef extends BaseController {
}
public function index() {
$param = $this->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());
}
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Controllers\Test;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Test\TestDefCalModel;
class TestDefCal extends BaseController {
use ResponseTrait;
protected $db;
protected $rules;
protected $model;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Controllers\Test;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Test\TestDefSiteModel;
class TestDefSite extends BaseController {
use ResponseTrait;
protected $db;
protected $rules;
protected $model;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Controllers\Test;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Test\TestDefTechModel;
class TestDefTech extends BaseController {
use ResponseTrait;
protected $db;
protected $rules;
protected $model;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Controllers\Test;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Test\TestGrpModel;
class TestGrp extends BaseController {
use ResponseTrait;
protected $db;
protected $rules;
protected $model;
public function __construct() {
$this->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());
}
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Controllers\Test;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\Test\TestMapModel;
class TestMap extends BaseController {
use ResponseTrait;
protected $db;
protected $rules;
protected $model;
public function __construct() {
$this->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());
}
}
}

View File

@ -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],

View File

@ -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');
}
}

View File

@ -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')

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models\Specimen;
use App\Models\BaseModel;
class SpecimenCollectionModel extends BaseModel {
protected $table = 'specimencollection';
protected $primaryKey = 'SpcColID';
protected $allowedFields = ['SpcColID', 'SpcStaID', 'SpRole', 'ColMethod', 'BodySite', 'CntSize', 'FastingVolume',
'ColStart', 'ColEnd', 'CreateDate', 'EndDate', 'ArchiveDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Models\Specimen;
use App\Models\BaseModel;
class SpecimenPrepModel extends BaseModel {
protected $table = 'specimenprep';
protected $primaryKey = 'SpcPrpID';
protected $allowedFields = ['SpcStaID', 'Description', 'Method', 'Additive', 'AddQty', 'AddUnit', 'PrepStart', 'PrepEnd', 'CreateDate', 'EndDate', 'ArchiveDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models\Specimen;
use App\Models\BaseModel;
class SpecimenModel extends BaseModel {
protected $table = 'specimen';
protected $primaryKey = 'InternalSID';
protected $allowedFields = ['SID', 'SiteID', 'OrderID', 'ConDefID', 'Parent', 'Qty', 'Unit', 'GenerateBy',
'SchDateTime','CreateDate', 'EndDate', 'ArchiveDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Models\Specimen;
use App\Models\BaseModel;
class SpecimenPrepModel extends BaseModel {
protected $table = 'specimenprep';
protected $primaryKey = 'SpcPrpID';
protected $allowedFields = ['SpcStaID', 'Description', 'Method', 'Additive', 'AddQty', 'AddUnit', 'PrepStart', 'PrepEnd', 'CreateDate', 'EndDate', 'ArchiveDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models\Specimen;
use App\Models\BaseModel;
class SpecimenStatusModel extends BaseModel {
protected $table = 'specimenstatus';
protected $primaryKey = 'SpcStaID';
protected $allowedFields = ['SID', 'OrderID', 'SpcAct', 'ActRes', 'SpcStatus', 'Qty', 'Unit', 'SpcCon', 'Comment', 'CurrSiteID', 'CurrLocID', 'Origin',
'GeoLocationSystem', 'GeoLocationData', 'DIDType', 'DID', 'UserID', 'CreateDate', 'EndDate', 'ArchiveDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
}

View File

@ -7,7 +7,7 @@ use App\Models\BaseModel;
class TestDefCalModel extends BaseModel {
protected $table = 'testdefcal';
protected $primaryKey = 'TestCalID';
protected $allowedFields = ['SiteID', 'TestSiteID', 'FormulaCode', 'FormulaLang', 'FormulaInput',
protected $allowedFields = ['SiteID', 'TestSiteID', 'DisciplineID', 'DepartmentID','FormulaCode', 'FormulaLang', 'FormulaInput',
'Unit1', 'Factor', 'Unit2', 'Decimal' ,'CreateDate', 'EndDate'];
protected $useTimestamps = true;

View File

@ -7,7 +7,7 @@ use App\Models\BaseModel;
class TestDefModel extends BaseModel {
protected $table = 'testdef';
protected $primaryKey = 'TestID';
protected $allowedFields = ['ParentTest', 'TestCode', 'TestName', 'Description', 'DisciplineID',
protected $allowedFields = ['Parent', 'TestCode', 'TestName', 'Description', 'DisciplineID',
'Method', 'Seq', 'CountStat', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;

View File

@ -8,8 +8,7 @@ class TestDefTechModel extends BaseModel {
protected $table = 'testdeftech';
protected $primaryKey = 'TestTechID';
protected $allowedFields = ['SiteID', 'TestSiteID', 'DisciplineID', 'DepartmentID', 'WorkstationID', 'EquipmentID', 'VSet', 'SpcType',
'ReqQty', 'ReqQtyUnit', 'Unit1', 'Factor', 'Unit2', 'Decimal', 'CollReq', 'ConDefID', 'TestTechCode', 'TestTechAbb', 'TestTechName',
'Method', 'ExpectedTAT', 'CreateDate', 'EndDate'];
'ReqQty', 'ReqQtyUnit', 'Unit1', 'Factor', 'Unit2', 'Decimal', 'CollReq', 'Method', 'ExpectedTAT', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models\Test;
use App\Models\BaseModel;
class TestMapModel extends BaseModel {
protected $table = 'testmap';
protected $primaryKey = 'TestMapID';
protected $allowedFields = ['HostType', 'HostID', 'HostDataSource', 'HostTestCode', 'HostTestName',
'ClientType', 'ClientID', 'ClientTestCode', 'ClientTestName', 'CreateDate', 'EndDate' ];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = "EndDate";
}