2024-12-25 03:04:59 +00:00
< ? php
/**
* Created by PhpStorm .
* User : Peak
* Date : 20 / 10 / 2559
* Time : 17 : 04
*/
namespace frontend\modules\histo\models ;
use common\models\HistoStaining ;
use Yii ;
use yii\data\ActiveDataProvider ;
use yii\db\Expression ;
class HistoStainingNewSectionSearch extends HistoStaining
{
public $hospital_id ;
public $pathologist_id ;
2025-01-21 02:56:57 +00:00
2024-12-25 03:04:59 +00:00
public function rules ()
{
return [
2025-01-21 02:56:57 +00:00
[[ 'id' , 'id_case' , 'in_at' , 'prepare_at' , 'out_at' , 'status_1' , 'block_no' , 'hospital_id' , 'pathologist_id' , 'pathologist' , 'operate_id' ], 'safe' ]
2024-12-25 03:04:59 +00:00
];
}
public function search ( $params )
{
$query = HistoStaining :: find () -> joinWith ( 'patientCase' )
2025-01-21 02:56:57 +00:00
-> select ([ 'operate_id' , 'MAX(histo_staining.id) as id' , 'MAX(histo_staining.block_no) as block_no' , 'histo_staining.id_case' , 'in_at' , 'MIN(patient_case.hospital_id)' , 'MIN(patient_case.hospital_name)' , 'MIN(patient_case.pathologist_id)' , 'MIN(patient_case.pathologist)' ])
2024-12-25 03:04:59 +00:00
-> orderBy ([ 'in_at' => SORT_DESC ])
-> groupBy ([ 'histo_staining.id_case' , 'histo_staining.in_at' ]);
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
2025-01-21 02:56:57 +00:00
//'pagination' => false
'pagination' => [
2024-12-25 03:04:59 +00:00
'pageSize' => 50
2025-01-21 02:56:57 +00:00
]
2024-12-25 03:04:59 +00:00
]);
2025-01-21 02:56:57 +00:00
$dataProvider -> sort -> attributes [ 'id_case' ] = [
'asc' => [ 'histo_staining.id_case' => SORT_ASC ],
'desc' => [ 'histo_staining.id_case' => SORT_DESC ]
];
/* $query = HistoStaining :: find ()
-> innerJoinWith ([ 'patientCase' ,
'immunoStaining'
])
-> andFilterWhere ([
'and' ,
[ 'not' , [ 'histo_staining.id_case' => null ]],
[ 'not' , [ 'immuno_staining.id_case' => null ]],
])
-> select ([
'histo_staining.operate_id' ,
'MAX(histo_staining.id) as id' ,
'MAX(histo_staining.block_no) as block_no' ,
'histo_staining.id_case' ,
'histo_staining.in_at' ,
'MIN(patient_case.pathologist_id)' ,
'MIN(patient_case.pathologist)' ,
])
-> orderBy ([ 'histo_staining.in_at' => SORT_DESC ])
-> groupBy ([ 'histo_staining.id_case' , 'histo_staining.in_at' , 'immuno_staining.id_case' , 'immuno_staining.in_at' ]);
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
'pagination' => false ,
]); */
2024-12-25 03:04:59 +00:00
$dataProvider -> sort -> attributes [ 'id_case' ] = [
'asc' => [ 'histo_staining.id_case' => SORT_ASC ],
'desc' => [ 'histo_staining.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' , 'histo_staining.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' , 'histo_staining.status_1' , $this -> status_1 ])
-> andFilterWhere ([ 'like' , 'patient_case.hospital_id' , $this -> hospital_id ])
-> andFilterWhere ([ 'like' , 'patient_case.pathologist_id' , $this -> pathologist_id ])
2025-01-21 02:56:57 +00:00
-> andFilterWhere ([ 'like' , 'histo_staining.operate_id' , $this -> operate_id ])
2024-12-25 03:04:59 +00:00
//->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 )])
-> 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 )]);
}
return $dataProvider ;
}
public function search_send ( $params )
{
$query = HistoStaining :: find () -> joinWith ( 'patientCase' )
-> select ([ 'Min(histo_staining.id) as id' , 'MIN(histo_staining.block_no) as block_no' , 'histo_staining.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 ([ 'histo_staining.id_case' , 'histo_staining.in_at' ]);
$dataProvider = new ActiveDataProvider ([
'query' => $query ,
'pagination' => false
/* 'pagination' => [
'pageSize' => 50
] */
]);
$dataProvider -> sort -> attributes [ 'id_case' ] = [
'asc' => [ 'histo_staining.id_case' => SORT_ASC ],
'desc' => [ 'histo_staining.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' , 'histo_staining.id_case' , $this -> id_case ])
-> andFilterWhere ([ 'like' , 'histo_staining.status_1' , $this -> status_1 ])
-> andFilterWhere ([ 'like' , 'patient_case.hospital_id' , $this -> hospital_id ])
-> andFilterWhere ([ 'like' , 'patient_case.pathologist_id' , $this -> pathologist_id ])
2025-01-21 02:56:57 +00:00
-> andFilterWhere ([ 'like' , 'histo_staining.operate_id' , $this -> operate_id ])
2024-12-25 03:04:59 +00:00
-> andFilterWhere ([ '=' , new Expression ( 'CAST(in_at AS date)' ), Yii :: $app -> pathology -> searchDate ( $this -> in_at )])
-> 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 )]);
}
return $dataProvider ;
}
}