2024-12-25 03:04:59 +00:00
< ? php
namespace frontend\modules\approve\models ;
use yii\base\Model ;
use yii\data\ActiveDataProvider ;
use common\models\CenterApprove ;
use Yii ;
use yii\db\Expression ;
/**
* CenterApproveSearch represents the model behind the search form of `common\models\CenterApprove` .
*/
class CenterApproveSearch extends CenterApprove
{
public $patient_name ;
public $h_n ;
public $his_ln ;
public $qa_id ;
/**
* { @ inheritdoc }
*/
public function rules ()
{
return [
[[ 'id' , 'pathologist_id' , /*'cytotech_id',*/ 'is_send_request' , 'approve_status' , 'approve_by' , 'release_by' , 'qa_id' ], 'integer' ],
[[ 'id_case' , 'report_type' , 'send_request_at' , 'approve_at' , 'release_at' , 'remark' , 'patient_name' , 'his_ln' , 'h_n' ], 'safe' ],
];
}
/**
* { @ inheritdoc }
*/
public function scenarios ()
{
// bypass scenarios() implementation in the parent class
return Model :: scenarios ();
}
/**
* Creates data provider instance with search query applied
*
* @ param array $params
*
* @ return ActiveDataProvider
*/
public function search ( $params )
{
$query = CenterApprove :: find () -> joinwith ([ 'patientCase' , 'patientCaseDiagnosis' ]) /*->where(['center_approve.pathologist_id' => Yii::$app->user->getId()])*/ ;
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
]);
$this -> load ( $params );
if ( ! $this -> validate ()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider ;
}
// grid filtering conditions
$query -> andFilterWhere ([
'center_approve.id' => $this -> id ,
'center_approve.pathologist_id' => $this -> pathologist_id ,
//'center_approve.cytotech_id' => $this->cytotech_id,
'center_approve.is_send_request' => $this -> is_send_request ,
'center_approve.send_request_at' => $this -> send_request_at ,
'center_approve.approve_status' => $this -> approve_status ,
'center_approve.approve_by' => $this -> approve_by ,
2025-04-28 03:53:53 +00:00
//'center_approve.approve_at' => $this->approve_at,
2024-12-25 03:04:59 +00:00
'center_approve.release_by' => $this -> release_by ,
//'patient_case_diagnosis.qa_id' => $this->qa_id,
//'patient_case.h_n' => $this->h_n,
//'patient_case.his_ln' => $this->his_ln,
//'center_approve.release_at' => $this->release_at,
]);
$query -> andFilterWhere ([ 'like' , 'center_approve.id_case' , $this -> id_case ])
-> andFilterWhere ([ 'like' , 'center_approve.report_type' , $this -> report_type ])
-> andFilterWhere ([ 'like' , 'center_approve.remark' , $this -> remark ])
-> andFilterWhere ([ 'like' , 'patient_case.patient_name' , $this -> patient_name ])
-> andFilterWhere ([ 'like' , 'patient_case.h_n' , $this -> h_n ])
-> andFilterWhere ([ 'like' , 'his_ln' , $this -> his_ln ])
//->andFilterWhere(['like', 'patient_case_diagnosis.qa_id', $this->qa_id])
// ->andFilterWhere(['like', 'patient_name', $this->patient_name])
//->andFilterWhere(['=', new Expression('TRY_CONVERT(DATE,center_approve.release_at)'), (Yii::$app->pathology->searchDate($this->release_at))]);
2025-04-28 03:53:53 +00:00
-> andFilterWhere ([ '=' , new Expression ( 'STR_TO_DATE(center_approve.approve_at, "%Y-%m-%d")' ), ( Yii :: $app -> pathology -> searchDate ( $this -> approve_at ))])
2024-12-25 03:04:59 +00:00
-> andFilterWhere ([ '=' , new Expression ( 'STR_TO_DATE(center_approve.release_at, "%Y-%m-%d")' ), ( Yii :: $app -> pathology -> searchDate ( $this -> release_at ))]);
//->andFilterWhere(['like', new Expression('CONCAT(case_surgical.given_name,case_surgical.surname)'), $this->patient_name]);
//->andFilterWhere(['like', new Expression('(CONCAT(case_surgical.given_name as nvarchar) , \' \' , CAST(case_surgical.surname as nvarchar))'), $this->patient_name]);
return $dataProvider ;
}
2025-04-28 03:53:53 +00:00
}