95 lines
3.1 KiB
PHP
95 lines
3.1 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();
|
|
|
|
// get the last 30 days of from today
|
|
$today = new DateTime(); // today
|
|
$begin = $today->sub(new DateInterval('P7D')); //created 30 days interval back
|
|
$end = new DateTime();
|
|
$end = $end->modify('+1 day'); // interval generates upto last day
|
|
$interval = new DateInterval('P1D'); // 1d interval range
|
|
$daterange = new DatePeriod($begin, $interval, $end); // it always runs forwards in date
|
|
$total_patient_count = 0;
|
|
foreach ($daterange as $date) { // date object
|
|
$new_date = $date->format("Y-m-d"); // your date
|
|
$query="select count(a.emp_id) as todays_case from covid_monitoring a left join patient_master b on a.emp_id = b.id where a.covid_test_result_id = '2' and a.date_added = '$new_date' $qry_bu group by a.date_added ";
|
|
// echo $query;
|
|
error_log('query: '.$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]['todays_case']=$row['todays_case'];
|
|
$total_patient_count += $row['todays_case'];
|
|
$record[$i]['total_case']=$total_patient_count;
|
|
$record[$i]['date'] = $date->format("d-m-Y");
|
|
$i++;
|
|
}
|
|
} else {
|
|
$record[$i]['todays_case'] = 0;
|
|
$total_patient_count += 0;
|
|
$record[$i]['total_case']=$total_patient_count;
|
|
$record[$i]['date'] = $date->format("d-m-Y");
|
|
$i++;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
echo json_encode($record);
|
|
?>
|
|
|