2024-10-16 19:18:52 +05:30
< ? php
// $minor=array();
$total = array ();
// $lti=array();
// $hospitalisation=array();
$xaxis = array ();
// $fa_id = '';
// $lti_id = '';
// $hos_id = '';
// $min_id = '';
// $query="SELECT inj_class_id,inj_class_name FROM injury_class";
// if (!$result = @mysqli_query($conn,$query)) {
2024-11-02 18:03:13 +05:30
// die(mysqli_error($conn));
2024-10-16 19:18:52 +05:30
// }
// if(mysqli_num_rows($result) > 0) {
// while ($row = @mysqli_fetch_array($result)) {
// if($row['inj_class_name'] == 'First Aid'){
// $fa_id = $row['inj_class_id'];
// }elseif($row['inj_class_name'] == 'LTI'){
// $lti_id = $row['inj_class_id'];
// }elseif($row['inj_class_name'] == 'Hospitalization'){
// $hos_id = $row['inj_class_id'];
// }elseif($row['inj_class_name'] == 'MINOR'){
// $min_id = $row['inj_class_id'];
// }
// }
// } else {
// echo '0';
// }
for ( $i = 6 ; $i >= 0 ; $i -- ){
error_log ( " FA ID:: " . $fa_id );
$query = " select count(distinct(patient_id)) as total,DATE(NOW()-INTERVAL $i DAY) from ambulance_usage_details a left join patient_master p on a.patient_id=p.id where a.ohc_type_id=' " . $_SESSION [ 'current_ohcttype' ] . " ' and p.client_location_id=' " . $_SESSION [ 'client_location_id' ] . " ' and date(usage_date) = date(NOW()-INTERVAL $i DAY) " ;
error_log ( " FIRST AID QUERY:: " . $query );
if ( ! $result = @ mysqli_query ( $conn , $query )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
if ( mysqli_num_rows ( $result ) > 0 ) {
while ( $row = @ mysqli_fetch_array ( $result )) {
array_push ( $total , $row [ 0 ]);
array_push ( $xaxis , $row [ 1 ]);
}
} else {
echo '0' ;
}
}
// for($i=4; $i>=0; $i--){
// $query="SELECT COUNT(appointment_id),WEEK(now())-$i FROM employee_appointment WHERE WEEK(appointment_date)=WEEK(now())-$i AND injury_classes_new LIKE '%$lti_id%'";
// error_log("LTI QUERY::" .$query);
// if (!$result = @mysqli_query($conn,$query)) {
2024-11-02 18:03:13 +05:30
// die(mysqli_error($conn));
2024-10-16 19:18:52 +05:30
// }
// if(mysqli_num_rows($result) > 0) {
// while ($row = @mysqli_fetch_array($result)) {
// array_push($lti,$row[0]);
// }
// } else {
// echo '0';
// }
// }
// for($i=4; $i>=0; $i--){
// $query="SELECT COUNT(appointment_id),DATE(NOW()-INTERVAL $i DAY) FROM employee_appointment WHERE WEEK(appointment_date)=date(NOW()-INTERVAL $i DAY) AND injury_classes_new LIKE '%$min_id%'";
// if (!$result = @mysqli_query($conn,$query)) {
2024-11-02 18:03:13 +05:30
// die(mysqli_error($conn));
2024-10-16 19:18:52 +05:30
// }
// if(mysqli_num_rows($result) > 0) {
// while ($row = @mysqli_fetch_array($result)) {
// array_push($minor,$row[0]);
// }
// } else {
// echo '0';
// }
// }
// for($i=4; $i>=0; $i--){
// $query="SELECT COUNT(appointment_id),WEEK(now())-$i FROM employee_appointment WHERE WEEK(appointment_date)=WEEK(now())-$i AND injury_classes_new LIKE '%$hos_id%'";
// if (!$result = @mysqli_query($conn,$query)) {
2024-11-02 18:03:13 +05:30
// die(mysqli_error($conn));
2024-10-16 19:18:52 +05:30
// }
// if(mysqli_num_rows($result) > 0) {
// while ($row = @mysqli_fetch_array($result)) {
// array_push($hospitalisation,$row[0]);
// }
// } else {
// echo '0';
// }
// }
?>
< script >
var ctx = document . getElementById ( 'chart_daily_ambulance_cases' ) . getContext ( '2d' );
var total = [ < ? php echo join ( ',' , $total ); ?> ];
// var minor = [<?php echo join(',',$minor); ?>];
// var lti = [<?php echo join(',',$lti); ?>];
// var hospitalisation = [<?php echo join(',',$hospitalisation); ?>];
var xaxis = [ < ? php echo json_encode ( $xaxis ); ?> ];
function formatDate ( input ) {
var datePart = input . match ( / \d +/ g ),
year = datePart [ 0 ],
month = datePart [ 1 ],
day = datePart [ 2 ];
return day + '-' + month + '-' + year ;
}
for ( let i = 0 ; i < 7 ; i ++ ) {
xaxis [ 0 ][ i ] = formatDate ( xaxis [ 0 ][ i ]);
}
var myChart = new Chart ( ctx , {
type : 'line' ,
options : {
title : {
display : true ,
text : " DAILY AMBULANCE CASES TREND "
},
legend : {
position : " bottom "
},
scales : {
yAxes : [{
ticks : {
precision : 0
}
}]
}
},
data : {
labels : xaxis [ 0 ],
datasets : [{
data : total ,
label : " Ambulance Case Count " ,
borderColor : " #092769 " ,
backgroundColor : " #092769 " ,
fill : false ,
}
]
},
});
</ script >