2024-12-25 03:04:59 +00:00
< ? php
use common\models\CasePap ;
use common\models\CenterApprove ;
use common\models\ConstStatus ;
use common\models\CytoPapDiagnosis ;
use yii\grid\GridView ;
use yii\helpers\ArrayHelper ;
use yii\helpers\Html ;
use yii\widgets\MaskedInput ;
?>
< ? = GridView :: widget ([
'dataProvider' => $dataProvider ,
'pager' => [ 'class' => 'yii\bootstrap5\LinkPager' ],
'filterModel' => $searchModel ,
'tableOptions' => [ 'class' => 'table align-middle truncate m-0' ],
'layout' => " { summary}<div class='table-outer'><div class='table-responsive'> \n { items} \n </div></div><div class='d-flex justify-content-between align-items-center mt-4'> { pager}</div> " ,
'columns' => [
[ 'class' => 'yii\grid\SerialColumn' ],
[
'class' => 'yii\grid\ActionColumn' ,
'template' => '{transfer} {do-task}' ,
'visibleButtons' => [
'transfer' => function ( $model ) {
return $model -> status_id <= 6 ;
},
],
'buttons' => [
'do-task' => function ( $url , $model ) {
return Html :: a ( '<i class="ri-file-text-line"></i> Diagnosis' , [ 'do' , 'id_case' => $model [ 'id_case' ]], [ 'class' => 'btn btn-sm btn-primary' ]) . ' ' ;
},
'transfer' => function ( $url , $model ) {
return Html :: a ( '<i class="ri-repeat-line"></i> Transfer' , [ 'transfer' , 'id_case' => $model [ 'id_case' ]], [ 'class' => 'btn btn-sm btn-warning' , 'data' => [ 'confirm' => 'ต้องการ Transfer Case นี้?' ]]);
}
]
],
[
'attribute' => 'status_id' ,
'filter' => ArrayHelper :: map ( ConstStatus :: find () -> all (), 'id' , 'status' ),
'format' => 'raw' ,
'value' => function ( $model ) {
//return $model->status->status;
return Yii :: $app -> pathology -> getStatus ( $model -> status_id );
}
],
[
'attribute' => 'id_case' ,
'format' => 'raw' ,
'value' => function ( $model ) {
$case = Yii :: $app -> pathology -> getCase ( $model -> id_case );
$case_type = Yii :: $app -> pathology -> getCaseType ( $model -> id_case );
$c = '' ;
$rt = '' ;
if ( isset ( $case ) && ! empty ( $case -> previous_report )) {
$c .= '<br /><small>(' . $case -> previous_report . ')</small>' ;
}
if ( $case_type == 'pap' ) {
$case = CasePap :: findOne ([ 'id_case' => $model -> id_case ]);
$rt .= ( ! empty ( $case -> decal_end_date ) ? '<small><br />Decal end:' . $case -> decal_end_date . '</small>' : '' );
}
return Html :: a ( Html :: encode ( $model -> id_case ), [ 'do' , 'id_case' => $model -> id_case ]) . $c . '<br>' . Yii :: $app -> pathology -> getExpress ( $model ) . ' ' . Yii :: $app -> pathology -> getCaseDate ( $model -> id_case ) . $rt ;
}
],
[
'label' => 'Report Status' ,
'headerOptions' => [ 'style' => 'text-align:center; width: 150;' ],
'format' => 'raw' ,
'value' => function ( $model ) {
$case_type = Yii :: $app -> pathology -> getCaseType ( $model -> id_case );
$rt = '' ;
if ( $case_type == 'pap' ) {
$pap_count = CytoPapDiagnosis :: find ()
-> where ([
'id_case' => $model -> id_case
]) -> count ();
if ( $pap_count > 0 ) {
$rt .= '<div class="table-outer"><table style="font-size: 11px;" class="table table-striped truncate m-0">' ;
$rt .= '<thead>' ;
2025-04-21 08:38:53 +00:00
$rt .= '<tr><td>Report Type</td><td>Status</td><td>Authorised At</td><td>Approved At</td><td>Release By</td><td>Release At</td></tr>' ;
2024-12-25 03:04:59 +00:00
$rt .= '</thead>' ;
$rt .= '<tbody>' ;
foreach (
CytoPapDiagnosis :: find ()
-> where ([
'id_case' => $model -> id_case
])
-> all () as $case
) {
$center_approve = CenterApprove :: findOne ([
'id_case' => $case -> id_case ,
'report_type' => $case -> report_type ,
'ref_id' => $case -> id ,
]);
if ( ! $center_approve ) {
$check = '<span class="badge border border-info bg-info-subtle text-info">รอแพทย์ Authorized</span>' ;
} else {
$arr = [ 1 => '<span class="badge border border-danger bg-danger-subtle text-danger">ยังไม่ตรวจสอบ</span>' , 2 => '<span class="badge border border-warning bg-warning-subtle text-warning">รอแก้ไข</span>' , 3 => '<span class="badge border border-info bg-info-subtle text-info">แพทย์แก้ไขผลแล้ว</span>' , 4 => '<span class="badge border border-success bg-success-subtle text-success">ตรวจสอบแล้ว</span>' ];
$check = $arr [ $center_approve -> approve_status ];
}
if ( ! empty ( $case -> pathologist_id )) {
$report = isset ( $case -> pathologist_at ) ? $case -> pathologist_at : '' ;
} else {
$report = isset ( $case -> cytotech1_at ) ? $case -> cytotech1_at : '' ;
}
$rt .= '<tr>' ;
$rt .= '<td>' . Html :: encode ( ucfirst ( $case -> report_type )) . '</td>' ;
$rt .= '<td>' . ( isset ( $case -> status ) ? Html :: encode ( $case -> status -> name ) : '' ) . '</td>' ;
$rt .= '<td>' . $report . '</td>' ;
$rt .= '<td>' . $check . '</td>' ;
2025-04-21 08:38:53 +00:00
$rt .= '<td>' . ( isset ( $center_approve -> releaseBy ) ? $center_approve -> releaseBy -> realname : '' ) . '</td>' ;
2024-12-25 03:04:59 +00:00
$rt .= '<td>' . ( isset ( $center_approve -> release_at ) ? $center_approve -> release_at : '' ) . '</td>' ;
$rt .= '</tr>' ;
}
$rt .= '</tbody>' ;
$rt .= '</table></div>' ;
} //surgical count
}
return $rt ;
}
],
[
'attribute' => 'h_n' ,
'format' => 'raw' ,
'value' => function ( $model ) {
return Html :: encode ( $model -> h_n );
}
],
[
'attribute' => 'patient_name' ,
'value' => function ( $model ) {
return isset ( $model ) ? Html :: encode ( $model -> getFullname ()) : null ;
}
],
[
'attribute' => 'is_outlab' ,
'filter' => [ 1 => 'Case Outlab' ],
'format' => 'raw' ,
'value' => function ( $model ) {
return $model -> is_outlab == 1 ? '<span class="badge border border-danger bg-danger-subtle text-danger">Case Outlab</span>' : '' ;
}
],
[
'attribute' => 'age' ,
'value' => function ( $model ) {
return intval ( $model -> age );
}
],
'age_unit' ,
[
'attribute' => 'hospital_id' ,
'value' => function ( $model ) {
return Html :: encode ( $model -> hospital -> name );
}
],
[
'attribute' => 'cytotech1_id' ,
'value' => function ( $model ) {
return isset ( $model -> cytotech1 ) ? Html :: encode ( $model -> cytotech1 -> report_name ) : null ;
}
],
[
'attribute' => 'register_at' ,
'filter' => MaskedInput :: widget ([
'model' => $searchModel ,
'attribute' => 'register_at' ,
'mask' => '99/99/9999'
]),
'value' => function ( $model ) {
return $model -> register_at ;
}
],
'remark' ,
]
]) ?>
< ? php $this -> registerCss ( "
. grid - view td {
white - space : nowrap ;
}
" ) ?>