clqms-be/app/Models/Organization/WorkstationModel.php
mahdahar 118d490bbd refactor: update TestSeeder to use dynamic ValueSet lookups
- Implemented dynamic VID retrieval from ValueSetModel for all test definitions
- Aligned ResultType, RefType, and SpcType with the valueset table
- Updated sample data for Hematology, Chemistry, and Urinalysis tests
- Ensured consistency between ValueSetSeeder and TestSeeder data
2025-12-29 12:55:31 +07:00

43 lines
1.8 KiB
PHP

<?php
namespace App\Models\Organization;
use App\Models\BaseModel;
class WorkstationModel extends BaseModel {
protected $table = 'workstation';
protected $primaryKey = 'WorkstationID';
protected $allowedFields = ['DepartmentID', 'WorkstationCode', 'WorkstationName', 'Type', 'LinkTo', 'Enable',
'EquipmentID', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getWorkstations($filter = []) {
$this->select('workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName')
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left');
if (!empty($filter['WorkstationCode'])) {
$this->like('workstation.WorkstationCode', $filter['WorkstationCode'], 'both');
}
if (!empty($filter['WorkstationName'])) {
$this->like('workstation.WorkstationName', $filter['WorkstationName'], 'both');
}
$rows = $this->findAll();
return $rows;
}
public function getWorkstation($WorkstationID) {
$row = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,enable.VDesc as EnableName, wstype.VDesc as TypeName")
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left')
->join('valueset wstype', 'wstype.VID=workstation.Type', 'left')
->join('valueset enable', 'enable.VID=workstation.Enable', 'left')
->where('workstation.WorkstationID', $WorkstationID)
->first();
return $row;
}
}