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

47 lines
1.8 KiB
PHP

<?php
namespace App\Models\Organization;
use App\Models\BaseModel;
class AccountModel extends BaseModel {
protected $table = 'account';
protected $primaryKey = 'AccountID';
protected $allowedFields = ['Parent', 'AccountName', 'Initial', 'Street_1', 'Street_2', 'Street_3',
'City', 'Province', 'ZIP', 'Country', 'AreaCode', 'EmailAddress1', 'EmailAddress2',
'Phone', 'Fax', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getAccounts($filter=[]) {
$builder = $this->select('account.AccountID, account.AccountName, account.Parent, pa.AccountName as ParentName, account.Initial')
->join('account pa', 'pa.AccountID=account.Parent', 'left');
if (!empty($filter['Parent'])) {
$builder->where('account.Parent', $filter['Parent']);
}
if (!empty($filter['AccountName'])) {
$builder->like('account.AccountName', $filter['AccountName'], 'both');
}
$rows = $builder->findAll();
return $rows;
}
public function getAccount($AccountID) {
$row = $this->select('account.*, pa.AccountName as ParentName, areageo.AreaName, areageo.AreaGeoID,
city.AreaName as CityName, city.AreaGeoID as City, prov.AreaName as ProvName, prov.AreaGeoID as Prov,
country.VValue as CountryName, country.VID as country')
->join('account pa', 'pa.AccountID=account.Parent', 'left')
->join('areageo', 'areageo.AreaCode=account.AreaCode', 'left')
->join('areageo city', 'city.AreaGeoID=account.City', 'left')
->join('areageo prov', 'prov.AreaGeoID=account.Province', 'left')
->join('valueset country', 'country.VID=account.Country', 'left')
->where('account.AccountID', $AccountID)
->first();
return $row;
}
}