- Add TestMapController for managing test-to-analyzer mappings - Create TestMapModel with database operations for test mappings - Update TestsController to support test mapping operations - Add testmap API routes to Routes.php - Create migration updates for test definitions table - Add OpenAPI specification for test mapping endpoints - Include unit tests for TestDef models - Update bundled API documentation
95 lines
2.3 KiB
PHP
95 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Test;
|
|
|
|
use App\Models\BaseModel;
|
|
|
|
class TestMapModel extends BaseModel {
|
|
protected $table = 'testmap';
|
|
protected $primaryKey = 'TestMapID';
|
|
protected $allowedFields = [
|
|
'TestSiteID',
|
|
'HostType',
|
|
'HostID',
|
|
'HostTestCode',
|
|
'HostTestName',
|
|
'ClientType',
|
|
'ClientID',
|
|
'ConDefID',
|
|
'ClientTestCode',
|
|
'ClientTestName',
|
|
'CreateDate',
|
|
'EndDate'
|
|
];
|
|
|
|
protected $useTimestamps = true;
|
|
protected $createdField = 'CreateDate';
|
|
protected $updatedField = '';
|
|
protected $useSoftDeletes = true;
|
|
protected $deletedField = "EndDate";
|
|
|
|
/**
|
|
* Get test mappings by test site
|
|
*/
|
|
public function getMappingsByTestSite($testSiteID) {
|
|
return $this->where('TestSiteID', $testSiteID)
|
|
->where('EndDate IS NULL')
|
|
->findAll();
|
|
}
|
|
|
|
/**
|
|
* Get test mappings by client (equipment/workstation)
|
|
*/
|
|
public function getMappingsByClient($clientType, $clientID) {
|
|
return $this->where('ClientType', $clientType)
|
|
->where('ClientID', $clientID)
|
|
->where('EndDate IS NULL')
|
|
->findAll();
|
|
}
|
|
|
|
/**
|
|
* Get test mappings by host (site/HIS)
|
|
*/
|
|
public function getMappingsByHost($hostType, $hostID) {
|
|
return $this->where('HostType', $hostType)
|
|
->where('HostID', $hostID)
|
|
->where('EndDate IS NULL')
|
|
->findAll();
|
|
}
|
|
|
|
/**
|
|
* Get test mapping by client test code and container
|
|
*/
|
|
public function getMappingByClientCode($clientTestCode, $conDefID = null) {
|
|
$builder = $this->where('ClientTestCode', $clientTestCode)
|
|
->where('EndDate IS NULL');
|
|
|
|
if ($conDefID) {
|
|
$builder->where('ConDefID', $conDefID);
|
|
}
|
|
|
|
return $builder->findAll();
|
|
}
|
|
|
|
/**
|
|
* Get test mapping by host test code
|
|
*/
|
|
public function getMappingByHostCode($hostTestCode) {
|
|
return $this->where('HostTestCode', $hostTestCode)
|
|
->where('EndDate IS NULL')
|
|
->findAll();
|
|
}
|
|
|
|
/**
|
|
* Check if mapping exists for client and host
|
|
*/
|
|
public function mappingExists($testSiteID, $clientType, $clientID, $clientTestCode) {
|
|
return $this->where('TestSiteID', $testSiteID)
|
|
->where('ClientType', $clientType)
|
|
->where('ClientID', $clientID)
|
|
->where('ClientTestCode', $clientTestCode)
|
|
->where('EndDate IS NULL')
|
|
->countAllResults() > 0;
|
|
}
|
|
}
|