2024-12-25 03:04:59 +00:00
< ? php
namespace frontend\modules\histo\models ;
use Yii ;
use yii\base\Model ;
use yii\db\Expression ;
use common\models\RecutCase ;
use yii\data\ActiveDataProvider ;
/**
* RecutCaseSearch represents the model behind the search form of `common\models\RecutCase` .
*/
class RecutCaseSearch extends RecutCase
{
/**
* { @ inheritdoc }
*/
public $hospital_id ;
public $pathologist_id ;
public function rules ()
{
return [
[[ 'id' , 'recut_oder' , 'operate_id' , 'status_1' , 'is_able' , 'is_view' , 'send_outlab_id' , 'send_id' ], 'integer' ],
[[ 'id_case' , 'block_no' , 'request_type' , 'note' , 'in_at' , 'receive_at' , 'out_at' , 'disable_comment' , 'send_outlab_at' , 'send_at' , 'group_name' ], 'safe' ],
];
}
public function search ( $params )
{
$query = RecutCase :: find () -> joinWith ( 'patientCase' )
-> select ([ 'MAX(recut_case.id) as id' , 'MAX(recut_case.block_no) as block_no' , 'recut_case.id_case' , 'in_at' , 'MIN(patient_case.hospital_id)' , 'MIN(patient_case.hospital_name)' , 'MIN(patient_case.pathologist_id)' , 'MIN(patient_case.pathologist)' ])
-> orderBy ([ 'in_at' => SORT_DESC ])
-> groupBy ([ 'recut_case.id_case' , 'recut_case.in_at' ]);
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
'pagination' => false
/* 'pagination' => [
'pageSize' => 50
] */
]);
$dataProvider -> sort -> attributes [ 'id_case' ] = [
'asc' => [ 'recut_case.id_case' => SORT_ASC ],
'desc' => [ 'recut_case.id_case' => SORT_DESC ]
];
if ( ! $this -> validate ()) {
// uncomment the following line if you do not want to return any records when validation fails
return $dataProvider ;
}
//$query->joinWith(['caseBlock']);
if ( $this -> load ( $params )) {
$query -> andFilterWhere ([ 'like' , 'recut_case.id_case' , $this -> id_case ])
//->andFilterWhere(['like', 'case_block.block_ex', $this->bex])
//->andFilterWhere(['like', 'case_block.block_in', $this->bin])
//->andFilterWhere(['like', 'in_at', Yii::$app->pathology->searchDate($this->in_at)])
//->andFilterWhere(['like', 'prepare_at', Yii::$app->pathology->searchDate($this->prepare_at)])
-> andFilterWhere ([ 'like' , 'recut_case.status_1' , $this -> status_1 ])
-> andFilterWhere ([ 'like' , 'patient_case.hospital_id' , $this -> hospital_id ])
-> andFilterWhere ([ 'like' , 'patient_case.pathologist_id' , $this -> pathologist_id ])
//->andFilterWhere(['=', new Expression('CAST(in_at AS date)'), Yii::$app->pathology->searchDate($this->in_at)])
-> andFilterWhere ([ '=' , new Expression ( 'CAST(in_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> in_at )])
2025-07-25 04:34:48 +00:00
-> andFilterWhere ([ '=' , new Expression ( 'CAST(out_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> out_at )]);
//->andFilterWhere(['=', new Expression('CAST(prepare_at AS date)'), Yii::$app->pathology->searchDate($this->prepare_at)]);
2024-12-25 03:04:59 +00:00
}
return $dataProvider ;
}
public function search_send ( $params )
{
$query = RecutCase :: find () -> joinWith ( 'patientCase' )
-> select ([ 'Min(recut_case.id) as id' , 'MIN(recut_case.block_no) as block_no' , 'recut_case.id_case' , 'in_at' , 'MIN(patient_case.hospital_id)' , 'MIN(patient_case.hospital_name)' , 'MIN(patient_case.pathologist_id)' , 'MIN(patient_case.pathologist)' ])
-> orderBy ([ 'in_at' => SORT_DESC ])
-> groupBy ([ 'recut_case.id_case' , 'recut_case.in_at' ]);
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
'pagination' => false
/* 'pagination' => [
'pageSize' => 50
] */
]);
$dataProvider -> sort -> attributes [ 'id_case' ] = [
'asc' => [ 'recut_case.id_case' => SORT_ASC ],
'desc' => [ 'recut_case.id_case' => SORT_DESC ]
];
if ( ! $this -> validate ()) {
// uncomment the following line if you do not want to return any records when validation fails
return $dataProvider ;
}
// $query->joinWith(['caseBlock']);
if ( $this -> load ( $params )) {
$query -> andFilterWhere ([ 'like' , 'recut_case.id_case' , $this -> id_case ])
-> andFilterWhere ([ 'like' , 'recut_case.status_1' , $this -> status_1 ])
-> andFilterWhere ([ 'like' , 'patient_case.hospital_id' , $this -> hospital_id ])
-> andFilterWhere ([ 'like' , 'patient_case.pathologist_id' , $this -> pathologist_id ])
-> andFilterWhere ([ '=' , new Expression ( 'CAST(in_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> in_at )])
2025-07-25 04:34:48 +00:00
-> andFilterWhere ([ '=' , new Expression ( 'CAST(out_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> out_at )]);
//->andFilterWhere(['=', new Expression('CAST(prepare_at AS date)'), Yii::$app->pathology->searchDate($this->prepare_at)]);
2024-12-25 03:04:59 +00:00
}
return $dataProvider ;
}
2025-07-25 04:34:48 +00:00
}