138 lines
4.1 KiB
PHP
138 lines
4.1 KiB
PHP
<?php
|
|
$sickness=array();
|
|
$opd=array();
|
|
$injury=array();
|
|
$xaxis = array();
|
|
|
|
$id = ($_REQUEST['flex_opd_id']!='')?($_REQUEST['flex_opd_id']):($_REQUEST['patient_id']);
|
|
if(!isset($id)){
|
|
$id = ($_REQUEST['flex_patient_id']!='')?($_REQUEST['flex_patient_id']):($_REQUEST['patient_id']);
|
|
}
|
|
$year = date("Y");
|
|
for($i=0; $i<=11; $i++){
|
|
$query="SELECT COUNT(appointment_id) FROM employee_appointment WHERE MONTH(appointment_date) = $i and year(appointment_date) = '$year' AND appointment_type='O' AND emp_id='$id' ";
|
|
// echo $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($xaxis,$i);
|
|
array_push($opd,$row[0]);
|
|
}
|
|
} else {
|
|
echo '0';
|
|
}
|
|
}
|
|
for($i=0; $i<=11; $i++){
|
|
$query="SELECT COUNT(appointment_id) FROM employee_appointment WHERE MONTH(appointment_date) = $i and year(appointment_date) = '$year' AND appointment_type='I' AND emp_id='$id' ";
|
|
// echo $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($injury,$row[0]);
|
|
}
|
|
} else {
|
|
echo '0';
|
|
}
|
|
}
|
|
for($i=0; $i<=11; $i++){
|
|
$query="SELECT COUNT(sickness_id) FROM sickness WHERE MONTH(sickness_date) = $i and year(sickness_date) = '$year'AND emp_id='$id' ";
|
|
// echo $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($sickness,$row[0]);
|
|
}
|
|
} else {
|
|
echo '0';
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
<script>
|
|
var ctx = document.getElementById('patient_osi').getContext('2d');
|
|
var opd = [<?php echo join(',',$opd); ?>];
|
|
var injury = [<?php echo join(',',$injury); ?>];
|
|
var sickness = [<?php echo join(',',$sickness); ?>];
|
|
var xaxis = [<?php echo join(',',$xaxis); ?>];
|
|
|
|
for (var i = 0; i < xaxis.length; i++) {
|
|
xaxis[i] = "Month:" + xaxis[i];
|
|
}
|
|
|
|
var myChart = new Chart(ctx, {
|
|
type: 'line',
|
|
options: {
|
|
title: {
|
|
display: true,
|
|
text: "Employee Monthly OSI"
|
|
},
|
|
legend: {
|
|
position: "bottom"
|
|
},
|
|
scales: {
|
|
yAxes: [{
|
|
ticks: {
|
|
precision: 0
|
|
}
|
|
}]
|
|
}
|
|
},
|
|
data: {
|
|
labels: xaxis,
|
|
datasets: [{
|
|
data: opd,
|
|
label: "Illness",
|
|
borderColor: "#d45087",
|
|
backgroundColor: "#d45087",
|
|
fill: false,
|
|
pointBackgroundColor: function(context) {
|
|
var index = context.dataIndex;
|
|
var value = context.dataset.data[index];
|
|
return value < 85 ? 'red' : // draw negative values in red
|
|
index % 2 ? 'blue' :
|
|
// else, alternate values in blue and green
|
|
'green';
|
|
}
|
|
|
|
}, {
|
|
data: injury,
|
|
label: "Injury",
|
|
borderColor: "#ff7c43",
|
|
backgroundColor: "#ffa500",
|
|
fill: false,
|
|
pointBackgroundColor: function(context) {
|
|
var index = context.dataIndex;
|
|
var value = context.dataset.data[index];
|
|
return value < 124 ? 'red' : // draw negative values in red
|
|
index % 2 ? 'blue' :
|
|
// else, alternate values in blue and green
|
|
'green';
|
|
}
|
|
|
|
}, {
|
|
data: sickness,
|
|
label: "Sickness",
|
|
borderColor: "#3e95cd",
|
|
backgroundColor: "#7bb6dd",
|
|
fill: false,
|
|
pointBackgroundColor: function(context) {
|
|
var index = context.dataIndex;
|
|
var value = context.dataset.data[index];
|
|
return value < 124 ? 'red' : // draw negative values in red
|
|
index % 2 ? 'blue' :
|
|
// else, alternate values in blue and green
|
|
'green';
|
|
}
|
|
|
|
}]
|
|
},
|
|
});
|
|
</script>
|