clqms-be/app/Models/Organization/DepartmentModel.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

41 lines
1.5 KiB
PHP

<?php
namespace App\Models\Organization;
use App\Models\BaseModel;
class DepartmentModel extends BaseModel {
protected $table = 'department';
protected $primaryKey = 'DepartmentID';
protected $allowedFields = ['DisciplineID', 'SiteID', 'DepartmentCode', 'DepartmentName', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getDepartments($filter = []) {
$this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName')
->join('discipline', 'discipline.DisciplineID=department.DisciplineID', 'left')
->join('site', 'department.SiteID=site.SiteID', 'left');
if (!empty($filter['DepartmentCode'])) {
$this->like('department.DepartmentCode', $filter['DepartmentCode'], 'both');
}
if (!empty($filter['DepartmentName'])) {
$this->like('department.DepartmentName', $filter['DepartmentName'], 'both');
}
$rows = $this->findAll();
return $rows;
}
public function getDepartment($DepartmentID) {
$row = $this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName')
->join('discipline', 'discipline.DisciplineID=department.DisciplineID', 'left')
->join('site', 'site.SiteID=department.SiteID', 'left')
->where('department.DepartmentID', $DepartmentID)
->first();
return $row;
}
}