2024-12-25 03:04:59 +00:00
< ? php
namespace frontend\modules\stat\controllers ;
use Yii ;
use yii\db\Query ;
use yii\db\Expression ;
use common\models\ReportTime ;
use common\models\SearchDate ;
use yii\data\SqlDataProvider ;
use common\models\StatSummary ;
use yii\data\ArrayDataProvider ;
use frontend\models\DashboardForm ;
use frontend\modules\stat\models\DateForm ;
use frontend\modules\stat\models\SearchForm ;
2025-01-02 08:05:14 +00:00
use frontend\modules\stat\models\PatientSearch ;
2025-01-21 02:55:08 +00:00
use frontend\modules\stat\models\PatientCaseSearch ;
2024-12-25 03:04:59 +00:00
/**
* frontend\modules\stat\controllers $StatisticController
* @ author Manop Kongoon < contact @ programmerthailand . com >
*
*/
class StatisticController extends \yii\web\Controller
{
/**
* @ return string
*/
public function actionUser ()
{
$date_start = '' ;
$date_end = '' ;
$model = new ReportTime ();
$rows = [];
if ( $model -> load ( Yii :: $app -> request -> post ())) { //เลือกวันเริ่มต้นและวันสิ้นสุดเพื่อค้นหา
$date_start = $model -> date_start ;
$date_end = $model -> date_end ;
}
$where_sql = " ( SELECT
MIN ( user_cut . cut_id ) AS name_id ,
MIN ( user_cut . cut_name ) AS name ,
Count ( user_cut . cut_id ) AS cut_sum ,
'0' AS note_sum ,
'0' AS write_block_sum ,
'0' AS type_sum ,
'0' AS charge_sum ,
'0' AS edit_charge_sum ,
'0' AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_cut
INNER JOIN user_table as u ON ( user_cut . cut_id = u . id AND u . role = 'surgical' )
WHERE ( user_cut . cut_id > 1 AND user_cut . cut_name IS NOT NULL ) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_cut.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY
user_cut . cut_id
) union all (
SELECT
MIN ( user_note . note_id ) AS name_id ,
MIN ( user_note . note_name ) AS name ,
'0' AS cut_sum ,
Count ( user_note . note_id ) AS note_sum ,
'0' AS write_block_sum ,
'0' AS type_sum ,
'0' AS charge_sum ,
'0' AS edit_charge_sum ,
'0' AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_note
INNER JOIN user_table as u_2 ON ( user_note . note_id = u_2 . id AND u_2 . role = 'surgical' )
WHERE ( user_note . note_id > 1 AND user_note . note_name IS NOT NULL ) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_note.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY
user_note . note_id
) union all (
SELECT
MIN ( user_write_block . write_block_id ) AS name_id ,
MIN ( user_write_block . write_block_name ) AS name ,
'0' AS cut_sum ,
'0' AS note_sum ,
Count ( user_write_block . write_block_id ) AS write_block_sum ,
'0' AS type_sum ,
'0' AS charge_sum ,
'0' AS edit_charge_sum ,
'0' AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_write_block
INNER JOIN user_table as u_3 ON ( user_write_block . write_block_id = u_3 . id AND u_3 . role = 'surgical' )
WHERE ( user_write_block . write_block_id > 1 AND user_write_block . write_block_name IS NOT NULL ) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_write_block.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY
user_write_block . write_block_id
) union all (
SELECT
MIN ( user_type . type_id ) AS name_id ,
MIN ( user_type . type_name ) AS name ,
'0' AS cut_sum ,
'0' AS note_sum ,
'0' AS write_block_sum ,
Count ( user_type . type_id ) AS type_sum ,
'0' AS charge_sum ,
'0' AS edit_charge_sum ,
'0' AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_type
INNER JOIN user_table as u_4 ON ( user_type . type_id = u_4 . id AND u_4 . role = 'surgical' )
WHERE ( user_type . type_id > 1 AND user_type . type_name IS NOT NULL ) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_type.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY
user_type . type_id
) union all (
SELECT
MIN ( user_charge . charge_id ) AS name_id ,
MIN ( user_charge . charge_name ) AS name ,
'0' AS cut_sum ,
'0' AS note_sum ,
'0' AS write_block_sum ,
'0' AS type_sum ,
Count ( user_charge . charge_id ) AS charge_sum ,
'0' AS edit_charge_sum ,
'0' AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_charge
INNER JOIN user_table as u_5 ON ( user_charge . charge_id = u_5 . id AND u_5 . role = 'surgical' )
WHERE ( user_charge . charge_id > 1 AND user_charge . charge_name IS NOT NULL ) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_charge.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY
user_charge . charge_id
) union all (
SELECT
MIN ( user_edit_charge . edit_charge_id ) AS name_id ,
MIN ( user_edit_charge . edit_charge_name ) AS name ,
'0' AS cut_sum ,
'0' AS note_sum ,
'0' AS write_block_sum ,
'0' AS type_sum ,
'0' AS charge_sum ,
Count ( user_edit_charge . edit_charge_id ) AS edit_charge_sum ,
'0' AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_edit_charge
INNER JOIN user_table as u_6 ON ( user_edit_charge . edit_charge_id = u_6 . id AND u_6 . role = 'surgical' )
WHERE ( user_edit_charge . edit_charge_id > 1 AND user_edit_charge . edit_charge_name IS NOT NULL ) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_edit_charge.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY user_edit_charge.edit_charge_id ) union all (
SELECT
MIN ( user_choose . choose_id ) AS name_id ,
MIN ( user_choose . choose_name ) AS name ,
'0' AS cut_sum ,
'0' AS note_sum ,
'0' AS write_block_sum ,
'0' AS type_sum ,
'0' AS charge_sum ,
'0' AS edit_charge_sum ,
COUNT ( user_choose . choose_id ) AS choose_sum ,
'0' AS discard_sum
FROM
stat_surgical AS user_choose
INNER JOIN user_table as u_7 ON ( user_choose . choose_id = u_7 . id AND u_7 . role = 'surgical' )
WHERE ( user_choose . choose_id > 1 AND user_choose . choose_name IS NOT NULL
) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_choose.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY user_choose.choose_id ) union all (
SELECT
MIN ( user_discard . discard_id ) AS name_id ,
MIN ( user_discard . discard_name ) AS name ,
'0' AS cut_sum ,
'0' AS note_sum ,
'0' AS write_block_sum ,
'0' AS type_sum ,
'0' AS charge_sum ,
'0' AS edit_charge_sum ,
'0' AS choose_sum ,
COUNT ( user_discard . discard_id ) AS discard_sum
FROM
stat_surgical AS user_discard
INNER JOIN user_table as u_8 ON ( user_discard . discard_id = u_8 . id AND u_8 . role = 'surgical' )
WHERE ( user_discard . discard_id > 1 AND user_discard . discard_name IS NOT NULL
) " ;
if ( $date_start != '' && $date_end != '' ) {
$where_sql .= " AND (user_discard.register_at BETWEEN STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateStart ( $date_start ) . " ', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE(' " . Yii :: $app -> pathology -> searchDateEnd ( $date_end ) . " ', '%Y-%m-%d %H:%i:%s')) " ;
}
$where_sql .= " GROUP BY user_discard.discard_id ) " ;
$sql = " SELECT
MIN ( v . name_id ) AS name_id ,
MIN ( v . name ) AS name ,
SUM ( v . cut_sum ) AS cut_sum ,
SUM ( v . note_sum ) AS note_sum ,
SUM ( v . write_block_sum ) AS write_block_sum ,
SUM ( v . type_sum ) AS type_sum ,
SUM ( v . charge_sum ) AS charge_sum ,
SUM ( v . edit_charge_sum ) AS edit_charge_sum ,
SUM ( v . choose_sum ) AS choose_sum ,
SUM ( v . discard_sum ) AS discard_sum
FROM ( " . $where_sql . " ) AS v
GROUP BY v . name_id " ;
$dataProvider = new SqlDataProvider ([ 'sql' => $sql ]);
return $this -> render ( 'user' , [
'dataProvider' => $dataProvider ,
'model' => $model
]);
}
/**
* รายงานสถิติการเติมชิ้นเนื้อของแพทย์
* @ return string
*/
public function actionAdd ()
{
$model = new ReportTime ();
$patho = [];
$cut = [];
$add = [];
if ( $model -> load ( Yii :: $app -> request -> post ())) { //เลือกวันเริ่มต้นและวันสิ้นสุดเพื่อค้นหา
$patho = ( new Query ())
-> select ( '
COUNT ( t . id_case ) AS total ,
MIN ( cs . pathologist_id ) AS pathologist_id ,
MIN ( ut_patho . realname ) AS realname
' )
-> from ( 'surgical_add t' )
-> leftJoin ( 'case_surgical cs' , 'cs.id_case = t.id_case' )
-> leftJoin ( 'surgical_operate so' , 'so.id_case = t.id_case' )
-> leftJoin ( 'user_table ut_patho' , 'ut_patho.id = cs.pathologist_id' )
-> leftJoin ( 'user_table ut_add' , 'ut_add.id = t.add_id' )
-> leftJoin ( 'user_table ut_cut' , 'ut_cut.id = so.cut_id' )
-> where ( 'cs.pathologist_id > 1' )
-> andWhere ([ 'between' , 'so.register_at' , Yii :: $app -> iop -> searchDateStart ( $model -> date_start ), Yii :: $app -> iop -> searchDateStart ( $model -> date_end )])
-> groupBy ( 'cs.pathologist_id' )
-> all ();
}
return $this -> render ( 'add' , [
'model' => $model ,
'patho' => $patho ,
]);
}
/**
* รายงานสถิติการทิ้งเนื้อ และการทำพิพิธภัณฑ์ จากวันที่ลงทะเบียน
* @ return string
*/
public function actionMuseum ()
{
$model = new ReportTime ();
$rows = [];
$dataProvider = [];
if ( $model -> load ( Yii :: $app -> request -> post ())) {
$rows = ( new Query ())
-> select ( '
MONTH ( t . register_at ) AS month_register ,
( YEAR ( t . register_at ) + 543 ) AS year_register ,
COUNT ( t . register_at ) AS amount_per_register ,
COUNT ( sd . ready_at ) AS amount_per_ready ,
COUNT ( sd . discard_at ) AS amount_per_discard ,
COUNT ( sd . is_postpone ) AS amount_per_postpone ,
COUNT ( DISTINCT sm . id_case ) AS amount_museum
' )
-> from ( 'surgical_operate t' )
-> leftJoin ( 'surgical_discard sd' , 'sd.id_case = t.id_case' )
-> leftJoin ( '(SELECT DISTINCT id_case FROM surgical_museum) as sm' , 't.id_case = sm.id_case' )
-> where ([ 'between' , 't.register_at' , new Expression ( " CONVERT(DATETIME,' " . Yii :: $app -> iop -> searchDateStart ( $model -> date_start ) . " ',120) " ), new Expression ( " CONVERT(DATETIME,' " . Yii :: $app -> iop -> searchDateEnd ( $model -> date_end ) . " ',120) " )])
-> groupBy ([ 'MONTH(t.register_at)' , 'YEAR(t.register_at)' ])
-> all ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $rows
]);
}
return $this -> render ( 'museum' , [
'model' => $model ,
'rows' => $rows ,
'dataProvider' => $dataProvider ,
]);
}
public function actionStatSummary ()
{
$search = new SearchDate ();
$model = [];
if ( $search -> load ( Yii :: $app -> request -> get ())) {
$model = StatSummary :: find ()
-> where ([ 'between' , 'register_at' , Yii :: $app -> pathology -> searchDateStart ( $search -> date_start ), Yii :: $app -> pathology -> searchDateEnd ( $search -> date_end )])
-> andFilterWhere ([ 'in' , 'report_type' , $search -> report_type ])
-> andFilterWhere ([ 'case_type' => $search -> case_type ])
-> all ();
}
return $this -> render ( 'stat-summary' , [
'model' => $model ,
'search' => $search ,
]);
}
public function actionSize ()
{
$search_date = new SearchDate ();
if ( $search_date -> load ( Yii :: $app -> request -> get ())) {
}
return $this -> render ( 'size' , [
'search_date' => $search_date
]);
}
public function actionRegisterOutlab ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT patient_case . register_at as month , COUNT ( * ) as cnt
FROM patient_case
WHERE ( register_at BETWEEN '" . Yii::$app->pathology->searchDateStart($model->date_start) . " 00:00:00'
AND '" . Yii::$app->pathology->searchDateEnd($model->date_end) . " 23:59:59' )
AND is_outlab = 1
-- AND LEFT ( id_case , 1 ) = 'S'
GROUP BY DATE ( register_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'cnt' ];
}
}
return $this -> render ( 'register-outlab' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionRegisterOutlabMonth ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
$model -> scenario = 'register' ;
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT MONTH ( register_at ) as month , COUNT ( * ) AS specimen
FROM patient_case
WHERE YEAR ( register_at ) = '
" . $model->year . " '
AND is_outlab = 1
-- AND LEFT ( id_case , 1 ) = 'S'
GROUP BY MONTH ( register_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'specimen' ];
}
}
return $this -> render ( 'register-outlab-month' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionReviewDay ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT patient_case_diagnosis . review_at as month , COUNT ( * ) as cnt
FROM patient_case_diagnosis
WHERE ( review_at BETWEEN '" . Yii::$app->pathology->searchDateStart($model->date_start) . " 00:00:00'
AND '" . Yii::$app->pathology->searchDateEnd($model->date_end) . " 23:59:59' )
-- AND LEFT ( id_case , 1 ) = 'S'
GROUP BY DATE ( review_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'cnt' ];
}
}
return $this -> render ( 'review-day' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionReviewMonth ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
$model -> scenario = 'register' ;
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT MONTH ( review_at ) as month , COUNT ( * ) AS specimen
FROM patient_case_diagnosis
WHERE YEAR ( review_at ) = '
" . $model->year . " '
-- AND LEFT ( id_case , 1 ) = 'S'
GROUP BY MONTH ( review_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'specimen' ];
}
}
return $this -> render ( 'review-month' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionRegisterConsultOutlab ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT stat_register_consult_outlab . register_at as month , COUNT ( * ) as cnt
FROM stat_register_consult_outlab
WHERE ( register_at BETWEEN '" . Yii::$app->pathology->searchDateStart($model->date_start) . " 00:00:00'
AND '" . Yii::$app->pathology->searchDateEnd($model->date_end) . " 23:59:59' )
AND status_outlab = 1
GROUP BY DATE ( register_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'cnt' ];
}
}
return $this -> render ( 'register-consult-outlab' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionRegisterConsultOutlabMonth ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
$model -> scenario = 'register' ;
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT MONTH ( register_at ) as month , COUNT ( * ) AS specimen
FROM stat_register_consult_outlab
WHERE YEAR ( register_at ) = '
" . $model->year . " '
AND status_outlab = 1
GROUP BY MONTH ( register_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'specimen' ];
}
}
return $this -> render ( 'register-consult-outlab-month' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
/*
public function actionStatIncident ()
{
$search = new SearchDate ();
$model = [];
if ( $search -> load ( Yii :: $app -> request -> get ())) {
$model = StatSummary :: find ()
-> where ([ 'between' , 'register_at' , Yii :: $app -> pathology -> searchDateStart ( $search -> date_start ), Yii :: $app -> pathology -> searchDateEnd ( $search -> date_end )])
-> andFilterWhere ([ 'in' , 'report_type' , $search -> report_type ])
-> andFilterWhere ([ 'case_type' => $search -> case_type ])
-> all ();
}
return $this -> render ( 'stat-incident' , [
'model' => $model ,
'search' => $search ,
]);
}
*/
public function actionStatIncident ()
{
$search_date = new SearchDate ;
$inciden = [];
$sum_inciden = 1 ;
if ( $search_date -> load ( Yii :: $app -> request -> get ())) {
}
return $this -> render ( 'stat-incident' , [
'search_date' => $search_date ,
'inciden' => $inciden ,
'sum_inciden' => $sum_inciden ,
]);
}
public function actionStatConferenceSurgical ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT case_surgical . conference_at as month , COUNT ( case_surgical . is_conference ) as cnt
FROM case_surgical
WHERE ( conference_at BETWEEN '" . Yii::$app->pathology->searchDateStart($model->date_start) . " 00:00:00'
AND '" . Yii::$app->pathology->searchDateEnd($model->date_end) . " 23:59:59' )
AND LEFT ( id_case , 1 ) = 'S'
GROUP BY DATE ( conference_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'cnt' ];
}
}
return $this -> render ( 'stat-conference-surgical' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionStatConferenceNonGyn ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT case_non_gyn . conference_at as month , COUNT ( case_non_gyn . is_conference ) as cnt
FROM case_non_gyn
WHERE ( conference_at BETWEEN '" . Yii::$app->pathology->searchDateStart($model->date_start) . " 00:00:00'
AND '" . Yii::$app->pathology->searchDateEnd($model->date_end) . " 23:59:59' )
-- AND LEFT ( id_case , 1 ) = 'C'
GROUP BY DATE ( conference_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'cnt' ];
}
}
return $this -> render ( 'stat-conference-non-gyn' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionStatConferenceGyn ()
{
$dataProvider = false ;
$data = false ;
$total = 0 ;
$model = new DateForm ();
if ( $model -> load ( Yii :: $app -> request -> get ())) {
$sql = "
SELECT case_pap . conference_at as month , COUNT ( case_pap . is_conference ) as cnt
FROM case_pap
WHERE ( conference_at BETWEEN '" . Yii::$app->pathology->searchDateStart($model->date_start) . " 00:00:00'
AND '" . Yii::$app->pathology->searchDateEnd($model->date_end) . " 23:59:59' )
-- AND LEFT ( id_case , 1 ) = 'P'
GROUP BY DATE ( conference_at )
" ;
$data = Yii :: $app -> db -> createCommand ( $sql ) -> queryAll ();
$dataProvider = new ArrayDataProvider ([
'allModels' => $data ,
'pagination' => false ,
]);
foreach ( $data as $t ) {
$total += $t [ 'cnt' ];
}
}
return $this -> render ( 'stat-conference-gyn' , [
'dataProvider' => $dataProvider ,
'data' => $data ,
'total' => $total ,
'model' => $model
]);
}
public function actionStatHospital ()
{
$model = new DashboardForm ();
$search = new SearchForm ();
$search = new SearchForm ();
$model = new DashboardForm ();
if ( $model -> load ( Yii :: $app -> request -> get ()) && $search -> load ( Yii :: $app -> request -> get ()) ) {
}
return $this -> render ( 'stat-hospital' , [
'model' => $model ,
'search' => $search ,
]);
}
2025-01-02 08:05:14 +00:00
/**
* @ return string
*/
public function actionPatientStat ()
{
2025-01-21 02:55:08 +00:00
$searchModel = new PatientCaseSearch ();
2025-01-02 08:05:14 +00:00
$dataProvider = $searchModel -> search ( Yii :: $app -> request -> queryParams );
return $this -> render ( 'patient-stat' , [
'searchModel' => $searchModel ,
'dataProvider' => $dataProvider ,
]);
}
2024-12-25 03:04:59 +00:00
}