340 lines
10 KiB
PHP
340 lines
10 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
$ohc_type = $_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'];
|
|
$year = implode(',',$_REQUEST['year']);
|
|
$month = implode(',', $_REQUEST['month']);
|
|
|
|
$year2=implode(',',$_REQUEST['year']);
|
|
|
|
$year1 = explode(',',$year);
|
|
// $year1 = array(2020,2021);
|
|
|
|
|
|
error_log("values::".$ohc_location." ".$patient_category." ".$dept." ".$emp_designation." ".$emp_cadre." ".$employer_contractor." ".$gender." ".$start_date." ".$end_date." ".$year." ".$month);
|
|
|
|
|
|
|
|
$qry_filter ="";
|
|
|
|
if(isset($dept) && $dept!=''){
|
|
$qry_filter.=" and dept_id ='".$dept."' ";
|
|
}
|
|
|
|
|
|
if(isset($ohc_type) && $ohc_type!=''){
|
|
$qry_filter.=" and ohc_type_id ='".$ohc_type."' ";
|
|
}
|
|
|
|
if(isset($gender) && $gender!=''){
|
|
$qry_filter.=" and gender ='".$gender."' ";
|
|
}
|
|
|
|
if(isset($patient_category) && $patient_category!=''){
|
|
$qry_filter.=" and emp_cat_id ='".$patient_category."' ";
|
|
}
|
|
|
|
if(isset($emp_designation) && $emp_designation!=''){
|
|
$qry_filter.=" and designation_id ='".$emp_designation."' ";
|
|
}
|
|
|
|
if(isset($emp_cadre) && $emp_cadre!=''){
|
|
$qry_filter.=" and emp_cadre ='".$emp_cadre."' ";
|
|
}
|
|
|
|
if(isset($employer_contractor) && $employer_contractor!=''){
|
|
$qry_filter.=" and employer_contractor_id ='".$employer_contractor."' ";
|
|
}
|
|
|
|
if(isset($start_date) && $start_date!=''){
|
|
$qry_filter.=" and date(doj) >=str_to_date('".$start_date."','%d-%m-%Y') ";
|
|
}
|
|
if(isset($end_date) && $end_date!=''){
|
|
$qry_filter.=" and date(doj) <=str_to_date('".$end_date."','%d-%m-%Y') ";
|
|
}
|
|
|
|
if(isset($month) && $month!=''){
|
|
$qry_filter.=" and month(doj) in (".$month.")";
|
|
}
|
|
|
|
$i=0;
|
|
$record =array();
|
|
|
|
if(isset($year) && $year!='' && sizeof($year1)>1){
|
|
|
|
for($j=0; $j<sizeof($year1);$j++){
|
|
|
|
error_log("year:".$year1[$j]." size:".sizeof($year1));
|
|
$qry_date="";
|
|
|
|
$qry_date.="and year(doj) <='".$year1[$j]."'";
|
|
|
|
$per_for_0_to_2 = 0;
|
|
$query1="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=0 and (datediff(CURRENT_DATE,doj)/365)<2 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result1 = @mysqli_query($conn,$query1)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
error_log("['2'] query:".$query1);
|
|
|
|
$per_for_2_to_5=0;
|
|
$query2="select count(id) as total from patient_master where (datediff(CURRENT_DATE,doj)/365)>=2 and (datediff(CURRENT_DATE,doj)/365)<5 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result2 = @mysqli_query($conn,$query2)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
error_log("['5'] query:".$query2);
|
|
|
|
$per_for_5_to_10=0;
|
|
$query3="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=5 and (datediff(CURRENT_DATE,doj)/365)<10 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result3 = @mysqli_query($conn,$query3)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
error_log("['10'] query:".$query3);
|
|
|
|
$per_for_10_to_15=0;
|
|
$query4="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=10 and (datediff(CURRENT_DATE,doj)/365)<15 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result4 = @mysqli_query($conn,$query4)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
error_log("['15'] query:".$query4);
|
|
|
|
$per_for_15_to_20=0;
|
|
$query5="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=15 and (datediff(CURRENT_DATE,doj)/365)<20 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result5 = @mysqli_query($conn,$query5)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
error_log("['20'] query:".$query5);
|
|
|
|
$per_for_20_to_25=0;
|
|
$query6="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=20 and (datediff(CURRENT_DATE,doj)/365)<25 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result6 = @mysqli_query($conn,$query6)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
error_log("['25'] query:".$query6);
|
|
|
|
$per_for_greater_than_25=0;
|
|
$query7="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=25 and status='Active' $qry_filter $qry_date";
|
|
|
|
if (!$result7 = @mysqli_query($conn,$query7)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
error_log("['>25'] query:".$query7);
|
|
|
|
$query="select count(id) as total_count FROM patient_master where status='Active'$qry_date $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
$row_count = mysqli_fetch_assoc($result);
|
|
|
|
error_log("count query:".$query);
|
|
|
|
if(mysqli_num_rows($result1) > 0) {
|
|
if ($row1 = mysqli_fetch_assoc($result1)) {
|
|
$per_for_0_to_2 = ($row1['total']/$row_count['total_count'])*100;
|
|
$record['0-2'][$year1[$j]]['total'] = round($per_for_0_to_2,2);
|
|
}
|
|
}
|
|
|
|
if(mysqli_num_rows($result2) > 0) {
|
|
if ($row2 = mysqli_fetch_assoc($result2)) {
|
|
$per_for_2_to_5 = ($row2['total']/$row_count['total_count'])*100;
|
|
$record['2-5'][$year1[$j]]['total'] = round($per_for_2_to_5,2);
|
|
}
|
|
}
|
|
|
|
if(mysqli_num_rows($result3) > 0) {
|
|
if ($row3 = mysqli_fetch_assoc($result3)) {
|
|
$per_for_5_to_10 = ($row3['total']/$row_count['total_count'])*100;
|
|
$record['5-10'][$year1[$j]]['total'] = round($per_for_5_to_10,2);
|
|
}
|
|
}
|
|
|
|
if(mysqli_num_rows($result4) > 0) {
|
|
if ($row4 = mysqli_fetch_assoc($result4)) {
|
|
$per_for_10_to_15 = ($row4['total']/$row_count['total_count'])*100;
|
|
$record['10-15'][$year1[$j]]['total'] = round($per_for_10_to_15,2);
|
|
}
|
|
}
|
|
|
|
if(mysqli_num_rows($result5) > 0) {
|
|
if ($row5 = mysqli_fetch_assoc($result5)) {
|
|
$per_for_15_to_20 = ($row5['total']/$row_count['total_count'])*100;
|
|
$record['15-20'][$year1[$j]]['total'] = round($per_for_15_to_20,2);
|
|
}
|
|
}
|
|
|
|
if(mysqli_num_rows($result6) > 0) {
|
|
if ($row6 = mysqli_fetch_assoc($result6)) {
|
|
$per_for_20_to_25 = ($row6['total']/$row_count['total_count'])*100;
|
|
$record['20-25'][$year1[$j]]['total'] = round($per_for_20_to_25,2);
|
|
}
|
|
}
|
|
|
|
if(mysqli_num_rows($result7) > 0) {
|
|
if ($row7 = mysqli_fetch_assoc($result7)) {
|
|
$per_for_greater_than_25 = ($row7['total']/$row_count['total_count'])*100;
|
|
$record['>25'][$year1[$j]]['total'] = round($per_for_greater_than_25,2);
|
|
}
|
|
}
|
|
}
|
|
echo json_encode($record);
|
|
}
|
|
else{
|
|
if(isset($year2) && $year2!=''){
|
|
$qry_filter.=" and year(doj) <='".$year2."'";
|
|
}
|
|
$query="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=0 and (datediff(CURRENT_DATE,doj)/365)<2 and status='Active' $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
$record[$i]['key'] ='0-2';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
error_log("['2'] query:".$query);
|
|
|
|
$query="select count(id) as total from patient_master where (datediff(CURRENT_DATE,doj)/365)>=2 and (datediff(CURRENT_DATE,doj)/365)<5 and status='Active' $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='2-5';
|
|
$record[$i]['total'] =$row['total'];
|
|
|
|
$i++;
|
|
}
|
|
}
|
|
error_log("['5'] query:".$query);
|
|
|
|
$query="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=5 and (datediff(CURRENT_DATE,doj)/365)<10 and status='Active' $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='5-10';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
error_log("['10'] query:".$query);
|
|
|
|
$query="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=10 and (datediff(CURRENT_DATE,doj)/365)<15 and status='Active' $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='10-15';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
error_log("['15'] query:".$query);
|
|
|
|
$query="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=15 and (datediff(CURRENT_DATE,doj)/365)<20 and status='Active' $qry_filter
|
|
$qry_date";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='15-20';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
error_log("['20'] query:".$query);
|
|
|
|
$query="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=20 and (datediff(CURRENT_DATE,doj)/365)<25 and status='Active' $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$record[$i]['key'] ='20-25';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
error_log("['25'] query:".$query);
|
|
$query="select count(id) as total FROM patient_master where (datediff(CURRENT_DATE,doj)/365)>=25 and status='Active' $qry_filter";
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
|
|
$record[$i]['key'] ='>25';
|
|
$record[$i]['total'] =$row['total'];
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
$query="select count(id) as total FROM patient_master where status='Active' $qry_filter";
|
|
|
|
//echo $query.$qry_bu;
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
}
|
|
|
|
if(mysqli_num_rows($result) > 0) {
|
|
if ($row = mysqli_fetch_assoc($result)) {
|
|
$data['total_count'] = $row['total'];
|
|
}
|
|
}
|
|
|
|
error_log("final query:".$query);
|
|
$data1=array('total_count'=>$data['total_count'],'data'=>$record);
|
|
|
|
echo json_encode($data1);
|
|
}
|