149 lines
4.1 KiB
PHP
149 lines
4.1 KiB
PHP
<?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)) {
|
|
// exit(mysqli_error($conn));
|
|
// }
|
|
// 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 = 12; $i >= 0; $i--) {
|
|
error_log("FA ID::" . $fa_id);
|
|
$query = "select count(distinct(patient_id)) as total,MONTH(now())-$i 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 month(usage_date) =month(date(NOW()-INTERVAL $i MONTH)) and year(usage_date) = year(date(NOW() - INTERVAL $i MONTH))";
|
|
|
|
|
|
error_log("FIRST AID QUERY::" . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
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)) {
|
|
// exit(mysqli_error($conn));
|
|
// }
|
|
// 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)) {
|
|
// exit(mysqli_error($conn));
|
|
// }
|
|
// 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)) {
|
|
// exit(mysqli_error($conn));
|
|
// }
|
|
// 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_yearly_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 join(',', $xaxis); ?>];
|
|
|
|
function getMonthAndYear(monthNumber) {
|
|
const date = new Date();
|
|
date.setMonth(monthNumber - 1);
|
|
const month = date.toLocaleString('en-US', {
|
|
month: 'long',
|
|
});
|
|
const year = date.getFullYear();
|
|
|
|
return `${month} ${year}`;
|
|
}
|
|
|
|
for (var i = 0; i < xaxis.length; i++) {
|
|
xaxis[i] = getMonthAndYear(xaxis[i]);
|
|
}
|
|
|
|
var myChart = new Chart(ctx, {
|
|
type: 'line',
|
|
options: {
|
|
title: {
|
|
display: true,
|
|
text: "MONTHLY AMBULANCE CASES TREND"
|
|
},
|
|
legend: {
|
|
position: "bottom"
|
|
},
|
|
scales: {
|
|
yAxes: [{
|
|
ticks: {
|
|
precision: 0
|
|
}
|
|
}]
|
|
}
|
|
},
|
|
data: {
|
|
labels: xaxis,
|
|
datasets: [{
|
|
data: total,
|
|
label: "Ambulance Case Count",
|
|
borderColor: "#800818",
|
|
backgroundColor: "#800818",
|
|
fill: false,
|
|
|
|
}]
|
|
},
|
|
});
|
|
</script>
|