ESH/covid_spo2_severity.php
2024-10-23 18:28:06 +05:30

105 lines
4.0 KiB
PHP

<?php
include('includes/config/config.php');
include('log_entry.php');
// error_reporting(E_ERROR | E_PARSE);
$ohc_location = $_REQUEST['ohc_location'];
$patient_category = $_REQUEST['patient_category'];
$dept = $_REQUEST['dept'];
$emp_designation = $_REQUEST['emp_designation'];
$emp_cadre = $_REQUEST['emp_cadre'];
$employer_contractor = $_REQUEST['employer_contractor'];
$gender = $_REQUEST['gender'];
$start_date = $_REQUEST['startDate'];
$end_date= $_REQUEST['endDate'];
$qry_bu ="";
$qry_date="";
if(isset($ohc_location) && $ohc_location!=''){
$qry_bu.=" and b.ohc_type_id ='".$ohc_location."' ";
}
if(isset($patient_category) && $patient_category!=''){
$qry_bu.=" and b.emp_cat_id ='".$patient_category."' ";
}
if(isset($dept) && $dept!=''){
$qry_bu.=" and b.dept_id ='".$dept."' ";
}
if(isset($emp_designation) && $emp_designation!=''){
$qry_bu.=" and b.designation_id ='".$emp_designation."' ";
}
if(isset($emp_cadre) && $emp_cadre!=''){
$qry_bu.=" and b.emp_cadre ='".$emp_cadre."' ";
}
if(isset($employer_contractor) && $employer_contractor!=''){
$qry_bu.=" and b.employer_contractor_id ='".$employer_contractor."' ";
}
if(isset($gender) && $gender!=''){
$qry_bu.=" and b.gender ='".$gender."' ";
}
// if(isset($start_date) && $start_date!=''){
// //$qry_date.=" and checkup_date >='".$start_date."' ";
// $qry_date.=" and medical_entry_date >=str_to_date('".$start_date."','%d-%m-%Y') ";
// }
// if(isset($end_date) && $end_date!=''){
// //$qry_date.=" and checkup_date <='".$end_date."' ";
// $qry_date.=" and medical_entry_date <=str_to_date('".$end_date."','%d-%m-%Y') ";
// }
$i=0;
$record =array();
// $query="select count(a.id) as total, f.dept_name from covid_monitoring a left join patient_master b on a.emp_id = b.id left join covid_patient_staying c on a.staying_id = c.id left join covid_test_result_master d on a.covid_test_result_id = d.id left join covid_contact_type_master e on a.covid_contact_id = e.id left join department f on b.dept_id = f.dept_id group BY f.dept_name ";
// //echo $query;
// if (!$result = @mysqli_query($conn,$query)) {
// exit(mysqli_error($conn));
// }
// if(mysqli_num_rows($result) > 0) {
// while ($row = @mysqli_fetch_assoc($result)) {
// $record[$i]['bmi_total']=$row['total'];
// $record[$i]['dept_name']=$row['dept_name'];
// $i++;
// }
// }
$query="select count(a.id) as total, a.spo2_basis from covid_monitoring a left join patient_master b on a.emp_id = b.id left join covid_patient_staying c on a.staying_id = c.id left join covid_test_result_master d on a.covid_test_result_id = d.id left join covid_contact_type_master e on a.covid_contact_id = e.id left join department f on b.dept_id = f.dept_id where a.emp_id = b.id $qry_bu group BY a.spo2_basis ";
//echo $query;
if (!$result = @mysqli_query($conn,$query)) {
exit(mysqli_error($conn));
}
if(mysqli_num_rows($result) > 0) {
while ($row = @mysqli_fetch_assoc($result)) {
$record[$i]['bmi_total']=$row['total'];
$record[$i]['dept_name']=$row['spo2_basis'];
$i++;
}
}
$query="SELECT count(*) as total_active from covid_monitoring where id in (select a.id from covid_monitoring a left join patient_master b on a.emp_id = b.id left join covid_patient_staying c on a.staying_id = c.id left join covid_test_result_master d on a.covid_test_result_id = d.id left join covid_contact_type_master e on a.covid_contact_id = e.id left join department f on b.dept_id = f.dept_id where a.emp_id = b.id $qry_bu group BY a.spo2_basis )";
//echo $query;
if (!$result = @mysqli_query($conn,$query)) {
exit(mysqli_error($conn));
}
if(mysqli_num_rows($result) > 0) {
if ($row = @mysqli_fetch_assoc($result)) {
for ($i=0; $i < count($record); $i++) {
// code...
$record[$i]['total_active']=$row['total_active'];
}
}
}
echo json_encode($record);
?>