feat: update test management APIs and reference range models
This commit is contained in:
parent
49d3a69308
commit
e9c7beeb2b
@ -176,7 +176,7 @@ class PatVisitController extends BaseController {
|
|||||||
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
||||||
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
||||||
->where('patvisitadt.InternalPVID', $InternalPVID)
|
->where('patvisitadt.InternalPVID', $InternalPVID)
|
||||||
->where('patvisitadt.DelDate IS NULL')
|
->where('patvisitadt.DelDate', null)
|
||||||
->orderBy('patvisitadt.CreateDate', 'ASC')
|
->orderBy('patvisitadt.CreateDate', 'ASC')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ class PatVisitController extends BaseController {
|
|||||||
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
->join('contact admDoc', 'admDoc.ContactID = patvisitadt.AdmDoc', 'left')
|
||||||
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
->join('contact cnsDoc', 'cnsDoc.ContactID = patvisitadt.CnsDoc', 'left')
|
||||||
->where('patvisitadt.PVADTID', $PVADTID)
|
->where('patvisitadt.PVADTID', $PVADTID)
|
||||||
->where('patvisitadt.DelDate IS NULL')
|
->where('patvisitadt.DelDate', null)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class TestMapController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function show($id = null) {
|
public function show($id = null) {
|
||||||
$row = $this->model->where('TestMapID',$id)->where('EndDate IS NULL')->first();
|
$row = $this->model->where('TestMapID',$id)->where('EndDate', null)->first();
|
||||||
if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); }
|
if (empty($row)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200); }
|
||||||
|
|
||||||
$row = ValueSet::transformLabels([$row], [
|
$row = ValueSet::transformLabels([$row], [
|
||||||
@ -83,7 +83,7 @@ class TestMapController extends BaseController {
|
|||||||
if (!$id) { return $this->failValidationErrors('TestMapID is required.'); }
|
if (!$id) { return $this->failValidationErrors('TestMapID is required.'); }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapID', $id)->where('EndDate IS NULL')->first();
|
$row = $this->model->where('TestMapID', $id)->where('EndDate', null)->first();
|
||||||
if (empty($row)) { return $this->respond([ 'status' => 'failed', 'message' => "Data not found or already deleted.", 'data' => null ], 404); }
|
if (empty($row)) { return $this->respond([ 'status' => 'failed', 'message' => "Data not found or already deleted.", 'data' => null ], 404); }
|
||||||
|
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
@ -93,7 +93,7 @@ class TestMapController extends BaseController {
|
|||||||
|
|
||||||
// Soft delete all related details
|
// Soft delete all related details
|
||||||
$this->modelDetail->where('TestMapID', $id)
|
$this->modelDetail->where('TestMapID', $id)
|
||||||
->where('EndDate IS NULL')
|
->where('EndDate', null)
|
||||||
->set('EndDate', date('Y-m-d H:i:s'))
|
->set('EndDate', date('Y-m-d H:i:s'))
|
||||||
->update();
|
->update();
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ class TestMapController extends BaseController {
|
|||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapID', $id)->where('EndDate IS NULL')->first();
|
$row = $this->model->where('TestMapID', $id)->where('EndDate', null)->first();
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
$results['failed'][] = ['TestMapID' => $id, 'error' => 'Not found or already deleted'];
|
$results['failed'][] = ['TestMapID' => $id, 'error' => 'Not found or already deleted'];
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class TestMapDetailController extends BaseController {
|
|||||||
if ($testMapID) {
|
if ($testMapID) {
|
||||||
$rows = $this->model->getDetailsByTestMap($testMapID);
|
$rows = $this->model->getDetailsByTestMap($testMapID);
|
||||||
} else {
|
} else {
|
||||||
$rows = $this->model->where('EndDate IS NULL')->findAll();
|
$rows = $this->model->where('EndDate', null)->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
@ -47,7 +47,7 @@ class TestMapDetailController extends BaseController {
|
|||||||
return $this->failValidationErrors('TestMapDetailID is required.');
|
return $this->failValidationErrors('TestMapDetailID is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate IS NULL')->first();
|
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => null ], 200);
|
||||||
@ -122,7 +122,7 @@ class TestMapDetailController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate IS NULL')->first();
|
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -228,7 +228,7 @@ class TestMapDetailController extends BaseController {
|
|||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
try {
|
try {
|
||||||
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate IS NULL')->first();
|
$row = $this->model->where('TestMapDetailID', $id)->where('EndDate', null)->first();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
$results['failed'][] = ['TestMapDetailID' => $id, 'error' => 'Not found or already deleted'];
|
$results['failed'][] = ['TestMapDetailID' => $id, 'error' => 'Not found or already deleted'];
|
||||||
|
|||||||
@ -42,52 +42,16 @@ class TestsController extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$siteId = $this->request->getGet('SiteID');
|
$filters = [
|
||||||
$testType = $this->request->getGet('TestType');
|
'SiteID' => $this->request->getGet('SiteID'),
|
||||||
$visibleScr = $this->request->getGet('VisibleScr');
|
'TestType' => $this->request->getGet('TestType'),
|
||||||
$visibleRpt = $this->request->getGet('VisibleRpt');
|
'VisibleScr' => $this->request->getGet('VisibleScr'),
|
||||||
$testSiteName = $this->request->getGet('TestSiteName');
|
'VisibleRpt' => $this->request->getGet('VisibleRpt'),
|
||||||
$testSiteCode = $this->request->getGet('TestSiteCode');
|
'TestSiteName' => $this->request->getGet('TestSiteName'),
|
||||||
|
'TestSiteCode' => $this->request->getGet('TestSiteCode'),
|
||||||
|
];
|
||||||
|
|
||||||
$builder = $this->db->table('testdefsite')
|
$rows = $this->model->getTestsWithRelations($filters);
|
||||||
->select(
|
|
||||||
"testdefsite.TestSiteID, testdefsite.TestSiteCode, testdefsite.TestSiteName, testdefsite.TestType,
|
|
||||||
testdefsite.SeqScr, testdefsite.SeqRpt, testdefsite.VisibleScr, testdefsite.VisibleRpt,
|
|
||||||
testdefsite.CountStat, testdefsite.StartDate, testdefsite.EndDate,
|
|
||||||
COALESCE(testdefsite.DisciplineID, cal.DisciplineID) as DisciplineID,
|
|
||||||
COALESCE(testdefsite.DepartmentID, cal.DepartmentID) as DepartmentID,
|
|
||||||
d.DisciplineName, dept.DepartmentName"
|
|
||||||
)
|
|
||||||
->join('testdefcal cal', 'cal.TestSiteID = testdefsite.TestSiteID AND cal.EndDate IS NULL', 'left')
|
|
||||||
->join('discipline d', 'd.DisciplineID = COALESCE(testdefsite.DisciplineID, cal.DisciplineID)', 'left')
|
|
||||||
->join('department dept', 'dept.DepartmentID = COALESCE(testdefsite.DepartmentID, cal.DepartmentID)', 'left')
|
|
||||||
->where('testdefsite.EndDate IS NULL');
|
|
||||||
|
|
||||||
if ($siteId) {
|
|
||||||
$builder->where('testdefsite.SiteID', $siteId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($testType) {
|
|
||||||
$builder->where('testdefsite.TestType', $testType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($visibleScr !== null) {
|
|
||||||
$builder->where('testdefsite.VisibleScr', $visibleScr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($visibleRpt !== null) {
|
|
||||||
$builder->where('testdefsite.VisibleRpt', $visibleRpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($testSiteName) {
|
|
||||||
$builder->like('testdefsite.TestSiteName', $testSiteName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($testSiteCode) {
|
|
||||||
$builder->like('testdefsite.TestSiteCode', $testSiteCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $builder->orderBy('testdefsite.SeqScr', 'ASC')->get()->getResultArray();
|
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -133,25 +97,9 @@ class TestsController extends BaseController
|
|||||||
$typeCode = $row['TestType'] ?? '';
|
$typeCode = $row['TestType'] ?? '';
|
||||||
|
|
||||||
if ($typeCode === 'CALC') {
|
if ($typeCode === 'CALC') {
|
||||||
$row['testdefcal'] = $this->db->table('testdefcal')
|
$row['testdefcal'] = $this->modelCal->getByTestSiteID($id);
|
||||||
->select('testdefcal.*, d.DisciplineName, dept.DepartmentName')
|
|
||||||
->join('discipline d', 'd.DisciplineID=testdefcal.DisciplineID', 'left')
|
|
||||||
->join('department dept', 'dept.DepartmentID=testdefcal.DepartmentID', 'left')
|
|
||||||
->where('testdefcal.TestSiteID', $id)
|
|
||||||
->where('testdefcal.EndDate IS NULL')
|
|
||||||
->get()->getResultArray();
|
|
||||||
} elseif ($typeCode === 'GROUP') {
|
} elseif ($typeCode === 'GROUP') {
|
||||||
$row['testdefgrp'] = $this->db->table('testdefgrp')
|
$row['testdefgrp'] = $this->modelGrp->getGroupMembers($id);
|
||||||
->select('testdefgrp.*, t.TestSiteCode, t.TestSiteName, t.TestType')
|
|
||||||
->join('testdefsite t', 't.TestSiteID=testdefgrp.Member', 'left')
|
|
||||||
->where('testdefgrp.TestSiteID', $id)
|
|
||||||
->where('testdefgrp.EndDate IS NULL')
|
|
||||||
->orderBy('testdefgrp.TestGrpID', 'ASC')
|
|
||||||
->get()->getResultArray();
|
|
||||||
|
|
||||||
$row['testdefgrp'] = ValueSet::transformLabels($row['testdefgrp'], [
|
|
||||||
'TestType' => 'test_type',
|
|
||||||
]);
|
|
||||||
} elseif ($typeCode === 'TITLE') {
|
} elseif ($typeCode === 'TITLE') {
|
||||||
} else {
|
} else {
|
||||||
$row['testdeftech'] = $this->db->table('testdefsite')
|
$row['testdeftech'] = $this->db->table('testdefsite')
|
||||||
@ -168,11 +116,7 @@ class TestsController extends BaseController
|
|||||||
$resultType = $techData['ResultType'] ?? '';
|
$resultType = $techData['ResultType'] ?? '';
|
||||||
|
|
||||||
if (TestValidationService::usesRefNum($resultType, $refType)) {
|
if (TestValidationService::usesRefNum($resultType, $refType)) {
|
||||||
$refnumData = $this->modelRefNum
|
$refnumData = $this->modelRefNum->getActiveByTestSiteID($id);
|
||||||
->where('TestSiteID', $id)
|
|
||||||
->where('EndDate IS NULL')
|
|
||||||
->orderBy('Display', 'ASC')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
$row['refnum'] = array_map(function ($r) {
|
$row['refnum'] = array_map(function ($r) {
|
||||||
return [
|
return [
|
||||||
@ -198,11 +142,7 @@ class TestsController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (TestValidationService::usesRefTxt($resultType, $refType)) {
|
if (TestValidationService::usesRefTxt($resultType, $refType)) {
|
||||||
$reftxtData = $this->modelRefTxt
|
$reftxtData = $this->modelRefTxt->getActiveByTestSiteID($id);
|
||||||
->where('TestSiteID', $id)
|
|
||||||
->where('EndDate IS NULL')
|
|
||||||
->orderBy('RefTxtID', 'ASC')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
$row['reftxt'] = array_map(function ($r) {
|
$row['reftxt'] = array_map(function ($r) {
|
||||||
return [
|
return [
|
||||||
@ -416,21 +356,15 @@ class TestsController extends BaseController
|
|||||||
$typeCode = $testType;
|
$typeCode = $testType;
|
||||||
|
|
||||||
if (TestValidationService::isCalc($typeCode)) {
|
if (TestValidationService::isCalc($typeCode)) {
|
||||||
$this->db->table('testdefcal')
|
$this->modelCal->disableByTestSiteID($id);
|
||||||
->where('TestSiteID', $id)
|
|
||||||
->update(['EndDate' => $now]);
|
|
||||||
} elseif (TestValidationService::isGroup($typeCode)) {
|
} elseif (TestValidationService::isGroup($typeCode)) {
|
||||||
$this->db->table('testdefgrp')
|
$this->modelGrp->disableByTestSiteID($id);
|
||||||
->where('TestSiteID', $id)
|
|
||||||
->update(['EndDate' => $now]);
|
|
||||||
} elseif (TestValidationService::isTechnicalTest($typeCode)) {
|
} elseif (TestValidationService::isTechnicalTest($typeCode)) {
|
||||||
$this->modelRefNum->where('TestSiteID', $id)->set('EndDate', $now)->update();
|
$this->modelRefNum->where('TestSiteID', $id)->set('EndDate', $now)->update();
|
||||||
$this->modelRefTxt->where('TestSiteID', $id)->set('EndDate', $now)->update();
|
$this->modelRefTxt->where('TestSiteID', $id)->set('EndDate', $now)->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->table('testmap')
|
$this->modelMap->disableByTestSiteID($id);
|
||||||
->where('TestSiteID', $id)
|
|
||||||
->update(['EndDate' => $now]);
|
|
||||||
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
@ -605,10 +539,7 @@ class TestsController extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($action === 'update') {
|
if ($action === 'update') {
|
||||||
$exists = $this->db->table('testdefcal')
|
$exists = $this->modelCal->existsByTestSiteID($testSiteID);
|
||||||
->where('TestSiteID', $testSiteID)
|
|
||||||
->where('EndDate IS NULL')
|
|
||||||
->get()->getRowArray();
|
|
||||||
|
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
$this->modelCal->update($exists['TestCalID'], $calcData);
|
$this->modelCal->update($exists['TestCalID'], $calcData);
|
||||||
@ -623,9 +554,7 @@ class TestsController extends BaseController
|
|||||||
private function saveGroupDetails($testSiteID, $data, $input, $action)
|
private function saveGroupDetails($testSiteID, $data, $input, $action)
|
||||||
{
|
{
|
||||||
if ($action === 'update') {
|
if ($action === 'update') {
|
||||||
$this->db->table('testdefgrp')
|
$this->modelGrp->disableByTestSiteID($testSiteID);
|
||||||
->where('TestSiteID', $testSiteID)
|
|
||||||
->update(['EndDate' => date('Y-m-d H:i:s')]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$members = $data['members'] ?? ($input['Members'] ?? []);
|
$members = $data['members'] ?? ($input['Members'] ?? []);
|
||||||
@ -647,20 +576,17 @@ class TestsController extends BaseController
|
|||||||
{
|
{
|
||||||
if ($action === 'update') {
|
if ($action === 'update') {
|
||||||
$existingMaps = $this->modelMap->where('TestSiteID', $testSiteID)
|
$existingMaps = $this->modelMap->where('TestSiteID', $testSiteID)
|
||||||
->where('EndDate IS NULL')
|
->where('EndDate', null)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
foreach ($existingMaps as $existingMap) {
|
foreach ($existingMaps as $existingMap) {
|
||||||
$this->modelMapDetail->where('TestMapID', $existingMap['TestMapID'])
|
$this->modelMapDetail->where('TestMapID', $existingMap['TestMapID'])
|
||||||
->where('EndDate IS NULL')
|
->where('EndDate', null)
|
||||||
->set('EndDate', date('Y-m-d H:i:s'))
|
->set('EndDate', date('Y-m-d H:i:s'))
|
||||||
->update();
|
->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->table('testmap')
|
$this->modelMap->disableByTestSiteID($testSiteID);
|
||||||
->where('TestSiteID', $testSiteID)
|
|
||||||
->where('EndDate IS NULL')
|
|
||||||
->update(['EndDate' => date('Y-m-d H:i:s')]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($mappings)) {
|
if (is_array($mappings)) {
|
||||||
@ -690,4 +616,4 @@ class TestsController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,4 +36,14 @@ class RefNumModel extends BaseModel
|
|||||||
protected $updatedField = '';
|
protected $updatedField = '';
|
||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = "EndDate";
|
protected $deletedField = "EndDate";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get active numeric reference ranges for a test
|
||||||
|
*/
|
||||||
|
public function getActiveByTestSiteID($testSiteID) {
|
||||||
|
return $this->where('TestSiteID', $testSiteID)
|
||||||
|
->where('EndDate', null)
|
||||||
|
->orderBy('Display', 'ASC')
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,4 +30,14 @@ class RefTxtModel extends BaseModel
|
|||||||
protected $updatedField = '';
|
protected $updatedField = '';
|
||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = "EndDate";
|
protected $deletedField = "EndDate";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get active text reference ranges for a test
|
||||||
|
*/
|
||||||
|
public function getActiveByTestSiteID($testSiteID) {
|
||||||
|
return $this->where('TestSiteID', $testSiteID)
|
||||||
|
->where('EndDate', null)
|
||||||
|
->orderBy('RefTxtID', 'ASC')
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,18 +30,35 @@ class TestDefCalModel extends BaseModel {
|
|||||||
protected $deletedField = "EndDate";
|
protected $deletedField = "EndDate";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get calculation details for a test
|
* Get calculation details for a test with relations
|
||||||
*/
|
*/
|
||||||
public function getCalcDetails($testSiteID) {
|
public function getByTestSiteID($testSiteID) {
|
||||||
$db = \Config\Database::connect();
|
return $this->db->table('testdefcal')
|
||||||
|
->select('testdefcal.*, d.DisciplineName, dept.DepartmentName')
|
||||||
return $db->table('testdefcal')
|
->join('discipline d', 'd.DisciplineID=testdefcal.DisciplineID', 'left')
|
||||||
->select('testdefcal.*, d.DisciplineName, dept.DepartmentName')
|
->join('department dept', 'dept.DepartmentID=testdefcal.DepartmentID', 'left')
|
||||||
->join('discipline d', 'd.DisciplineID=testdefcal.DisciplineID', 'left')
|
->where('testdefcal.TestSiteID', $testSiteID)
|
||||||
->join('department dept', 'dept.DepartmentID=testdefcal.DepartmentID', 'left')
|
->where('testdefcal.EndDate IS NULL')
|
||||||
->where('testdefcal.TestSiteID', $testSiteID)
|
->get()->getResultArray();
|
||||||
->where('testdefcal.EndDate IS NULL')
|
}
|
||||||
->get()->getResultArray();
|
|
||||||
|
/**
|
||||||
|
* Check if calculation exists for a test
|
||||||
|
*/
|
||||||
|
public function existsByTestSiteID($testSiteID) {
|
||||||
|
return $this->db->table('testdefcal')
|
||||||
|
->where('TestSiteID', $testSiteID)
|
||||||
|
->where('EndDate IS NULL')
|
||||||
|
->get()->getRowArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable calculation by TestSiteID
|
||||||
|
*/
|
||||||
|
public function disableByTestSiteID($testSiteID) {
|
||||||
|
$this->db->table('testdefcal')
|
||||||
|
->where('TestSiteID', $testSiteID)
|
||||||
|
->update(['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -46,4 +46,14 @@ class TestDefGrpModel extends BaseModel {
|
|||||||
->where('testdefgrp.EndDate IS NULL')
|
->where('testdefgrp.EndDate IS NULL')
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable group members by TestSiteID
|
||||||
|
*/
|
||||||
|
public function disableByTestSiteID($testSiteID) {
|
||||||
|
$this->db->table('testdefgrp')
|
||||||
|
->where('TestSiteID', $testSiteID)
|
||||||
|
->update(['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,6 +78,51 @@ class TestDefSiteModel extends BaseModel {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tests list with discipline and department info
|
||||||
|
*/
|
||||||
|
public function getTestsWithRelations($filters = []) {
|
||||||
|
$builder = $this->db->table('testdefsite')
|
||||||
|
->select(
|
||||||
|
"testdefsite.TestSiteID, testdefsite.TestSiteCode, testdefsite.TestSiteName, testdefsite.TestType,
|
||||||
|
testdefsite.SeqScr, testdefsite.SeqRpt, testdefsite.VisibleScr, testdefsite.VisibleRpt,
|
||||||
|
testdefsite.CountStat, testdefsite.StartDate, testdefsite.EndDate,
|
||||||
|
COALESCE(testdefsite.DisciplineID, cal.DisciplineID) as DisciplineID,
|
||||||
|
COALESCE(testdefsite.DepartmentID, cal.DepartmentID) as DepartmentID,
|
||||||
|
d.DisciplineName, dept.DepartmentName"
|
||||||
|
)
|
||||||
|
->join('testdefcal cal', 'cal.TestSiteID = testdefsite.TestSiteID AND cal.EndDate IS NULL', 'left')
|
||||||
|
->join('discipline d', 'd.DisciplineID = COALESCE(testdefsite.DisciplineID, cal.DisciplineID)', 'left')
|
||||||
|
->join('department dept', 'dept.DepartmentID = COALESCE(testdefsite.DepartmentID, cal.DepartmentID)', 'left')
|
||||||
|
->where('testdefsite.EndDate IS NULL');
|
||||||
|
|
||||||
|
if (!empty($filters['SiteID'])) {
|
||||||
|
$builder->where('testdefsite.SiteID', $filters['SiteID']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filters['TestType'])) {
|
||||||
|
$builder->where('testdefsite.TestType', $filters['TestType']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($filters['VisibleScr'])) {
|
||||||
|
$builder->where('testdefsite.VisibleScr', $filters['VisibleScr']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($filters['VisibleRpt'])) {
|
||||||
|
$builder->where('testdefsite.VisibleRpt', $filters['VisibleRpt']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filters['TestSiteName'])) {
|
||||||
|
$builder->like('testdefsite.TestSiteName', $filters['TestSiteName']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filters['TestSiteCode'])) {
|
||||||
|
$builder->like('testdefsite.TestSiteCode', $filters['TestSiteCode']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $builder->orderBy('testdefsite.SeqScr', 'ASC')->get()->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
public function getTest($TestSiteID) {
|
public function getTest($TestSiteID) {
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
|
|
||||||
|
|||||||
@ -104,4 +104,13 @@ class TestMapModel extends BaseModel {
|
|||||||
->where('testmapdetail.EndDate IS NULL')
|
->where('testmapdetail.EndDate IS NULL')
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable test mappings by TestSiteID
|
||||||
|
*/
|
||||||
|
public function disableByTestSiteID($testSiteID) {
|
||||||
|
$this->db->table('testmap')
|
||||||
|
->where('TestSiteID', $testSiteID)
|
||||||
|
->update(['EndDate' => date('Y-m-d H:i:s')]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user