ohctech_p8/heath_index_all_data_script.php

60 lines
1.9 KiB
PHP
Raw Normal View History

2024-10-16 19:18:52 +05:30
<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
$year = $_GET['year'];
$checkUpTypeid = getFieldFromTable("checkup_type_id", "checkup_type", "checkup_type_code", "Statutory_Medical_Checkup");
$sqlOfAllCheckupData = "SELECT a.checkup_id , a.checkup_date , b.patient_name , a.health_index , b.emp_code FROM checkup_form a INNER JOIN patient_master b ON a.emp_id = b.id WHERE YEAR(a.checkup_date) = '".$year."' AND a.checkup_type_id = '".$checkUpTypeid."' and (current_status='DRA' or current_status='MRA') AND (health_index != '' AND health_index != '0') ORDER BY checkup_date desc";
error_log("HEALTH INDEX DATA : " . $sqlOfAllCheckupData);
$resultOfSql = mysqli_query($conn , $sqlOfAllCheckupData);
$data = array();
while ($fetch = mysqli_fetch_assoc($resultOfSql)) {
$Date = date('d-m-Y', strtotime($fetch['checkup_date']));
error_log("HEALTH INDEX : " . $fetch['health_index']);
if ($fetch['health_index'] >= 0 && $fetch['health_index'] <= 1) {
$color = 1;
} elseif ($fetch['health_index'] > 1 && $fetch['health_index'] <= 2) {
$color = 2;
} elseif ($fetch['health_index'] > 2 && $fetch['health_index'] <= 3) {
$color = 3;
} elseif ($fetch['health_index'] > 3 && $fetch['health_index'] <= 4) {
$color = 4;
} elseif ($fetch['health_index'] > 4 && $fetch['health_index'] <= 5) {
$color = 5;
} elseif ($fetch['health_index'] > 5 && $fetch['health_index'] <= 7) {
$color = 6;
} else {
continue;
}
$data[] = array(
"name" => $fetch['patient_name'],
"emp_code" => $fetch['emp_code'],
"color" => $color,
"checkup_id" =>$fetch['checkup_id'],
"date" => $Date
);
}
$response = array(
"data" => $data
);
error_log('due data' . json_encode($data));
echo json_encode($response);
?>