groupStart() ->like('mean', $keyword) ->groupEnd() ->findAll(); } return $this->findAll(); } /** * Get control-test with control and test details */ public function getWithDetails(int $controlTestId): ?array { $builder = $this->db->table('control_tests ct'); $builder->select(' ct.control_test_id as id, ct.control_id as controlId, ct.test_id as testId, ct.mean, ct.sd, c.control_name as controlName, c.lot, t.test_name as testName, t.test_unit as testUnit '); $builder->join('master_controls c', 'c.control_id = ct.control_id'); $builder->join('master_tests t', 't.test_id = ct.test_id'); $builder->where('ct.control_test_id', $controlTestId); $builder->where('ct.deleted_at', null); return $builder->get()->getRowArray() ?: null; } /** * Get tests for a control with QC parameters */ public function getByControl(int $controlId): array { $builder = $this->db->table('control_tests ct'); $builder->select(' ct.control_test_id as id, ct.control_id as controlId, ct.test_id as testId, ct.mean, ct.sd, t.test_name as testName, t.test_unit as testUnit '); $builder->join('master_tests t', 't.test_id = ct.test_id'); $builder->where('ct.control_id', $controlId); $builder->where('ct.deleted_at', null); $builder->where('t.deleted_at', null); $builder->orderBy('t.test_name', 'ASC'); return $builder->get()->getResultArray(); } /** * Get controls for a test with QC parameters */ public function getByTest(int $testId): array { $builder = $this->db->table('control_tests ct'); $builder->select(' ct.control_test_id as id, ct.control_id as controlId, ct.test_id as testId, ct.mean, ct.sd, c.control_name as controlName, c.lot, c.producer '); $builder->join('master_controls c', 'c.control_id = ct.control_id'); $builder->where('ct.test_id', $testId); $builder->where('ct.deleted_at', null); $builder->where('c.deleted_at', null); $builder->orderBy('c.control_name', 'ASC'); return $builder->get()->getResultArray(); } /** * Get by control and test */ public function getByControlAndTest(int $controlId, int $testId): ?array { $builder = $this->db->table('control_tests ct'); $builder->select(' ct.control_test_id as id, ct.control_id as controlId, ct.test_id as testId, ct.mean, ct.sd '); $builder->where('ct.control_id', $controlId); $builder->where('ct.test_id', $testId); $builder->where('ct.deleted_at', null); return $builder->get()->getRowArray() ?: null; } }