2024-12-25 03:04:59 +00:00
< ? php
namespace frontend\modules\pathologist\models ;
use common\models\CaseNonGyn ;
use yii\data\ActiveDataProvider ;
use yii\db\Expression ;
use Yii ;
class CaseNonGynSearch extends CaseNonGyn
{
public $patient_name ;
public $hospital_name ;
public function rules ()
{
return [
[[ 'status_id' ], 'integer' ],
2025-05-27 04:08:10 +00:00
[[ 'patient_name' , 'hospital_name' , 'register_at' , 'receive_at' , 'id_case' , 'h_n' , 'is_outlab' , 'is_cell_block' /*'priority_code'*/ ], 'safe' ]
2024-12-25 03:04:59 +00:00
];
}
public function attributeLabels ()
{
return [
'register_at' => 'วันที่ลงทะเบียน' ,
'hospital' => 'โรงพยาบาล' ,
'patient' => 'ชื่อ-นามสกุล' ,
];
}
public function search ( $params )
{
$query = CaseNonGyn :: find ()
-> with ([ 'patient' , 'hospital' ])
-> andFilterWhere ([ 'pathologist_id' => Yii :: $app -> user -> getId ()]);
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
]);
$this -> load ( $params );
$query //->andFilterWhere(['like', new Expression('CONCAT(case_non_gyn.given_name,case_non_gyn.surname)'), $this->patient_name])
-> andFilterWhere ([ 'like' , new Expression ( 'CONCAT(case_non_gyn.given_name,case_non_gyn.surname)' ), $this -> patient_name ])
//->andFilterWhere(['like', new Expression('(CAST(case_non_gyn.given_name as nvarchar) + \' \' + CAST(case_non_gyn.surname as nvarchar))'), $this->patient_name])
-> andFilterWhere ([ 'like' , 'const_hospital.name' , $this -> hospital_name ])
-> andFilterWhere ([ 'like' , 'id_case' , $this -> id_case ])
-> andFilterWhere ([ 'case_non_gyn.status_id' => $this -> status_id ])
2025-05-27 04:08:10 +00:00
-> andFilterWhere ([ 'case_non_gyn.is_cell_block' => $this -> is_cell_block ])
2024-12-25 03:04:59 +00:00
-> andFilterWhere ([ 'case_non_gyn.is_outlab' => $this -> is_outlab ])
-> andFilterWhere ([ 'case_non_gyn.h_n' => $this -> h_n ])
//->andFilterWhere(['=', new Expression('TRY_CONVERT(DATE,case_non_gyn.receive_at)'), (Yii::$app->pathology->searchDate($this->receive_at))])
-> andFilterWhere ([ '=' , new Expression ( 'CAST(case_non_gyn.receive_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> receive_at )])
//->andFilterWhere(['=', new Expression('TRY_CONVERT(DATE,case_non_gyn.register_at)'), (Yii::$app->pathology->searchDate($this->register_at))])
-> andFilterWhere ([ '=' , new Expression ( 'CAST(case_non_gyn.register_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> register_at )]);
return $dataProvider ;
}
}