133 lines
5.4 KiB
PHP
133 lines
5.4 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
// $year = implode(',', $_REQUEST['year']);
|
|
$year2 = $_REQUEST['year'];
|
|
// $year1 = explode(',', $year);
|
|
$qry_filter = "";
|
|
$query_date = "";
|
|
|
|
$ohc_id = $_REQUEST['ohc'];
|
|
|
|
$start_date = $_REQUEST['startDate'];
|
|
$end_date = $_REQUEST['endDate'];
|
|
|
|
error_log("ohc id ".$ohc_id);
|
|
|
|
if (isset($ohc_id) && $ohc_id != '') {
|
|
$qry_filter .= " and ohc_type_id = '" . $ohc_id . "' ";
|
|
}
|
|
|
|
if (isset($start_date) && $start_date != '') {
|
|
$qry_date .= " and date(checkup_date) >=str_to_date('" . $start_date . "','%d-%m-%Y') ";
|
|
}
|
|
if (isset($end_date) && $end_date != '') {
|
|
$qry_date .= " and date(checkup_date) <=str_to_date('" . $end_date . "','%d-%m-%Y') ";
|
|
}
|
|
|
|
if (isset($year2) && $year2 != '') {
|
|
$qry_filter .= " and year(checkup_date) ='" . $year2 . "'";
|
|
}
|
|
|
|
|
|
// selecting different age groups
|
|
$query_age_part = "";
|
|
$data_gender = [];
|
|
$data_pat_cat = [];
|
|
$data_collar = [];
|
|
|
|
$query_age = "select * from rule_age_range";
|
|
|
|
if (!$result_age = mysqli_query($conn, $query_age)) {
|
|
error_log("error in age range query " . $query_age . " query " . $query_age);
|
|
} else {
|
|
while ($row_age = mysqli_fetch_assoc($result_age)) {
|
|
$start_age = $row_age['rule_age_start'];
|
|
$end_age = $row_age['rule_age_end'];
|
|
if ($end_age == 0) {
|
|
$start_age = $row_age['rule_age_start'];
|
|
$query_age_part = "year(CURDATE())-year(dob)>='" . $start_age . "'";
|
|
} else {
|
|
$query_age_part = "year(CURDATE())-year(dob)>='" . $start_age . "' and year(CURDATE())-year(dob)<'" . $end_age . "'";
|
|
}
|
|
|
|
$query1 = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' and $query_age_part and gender='M' order by id asc) $qry_filter $qry_date group by emp_id order by emp_id ";
|
|
|
|
if (!$result1 = mysqli_query($conn, $query1)) {
|
|
error_log("error in query for male count " . $start_age . " " . mysqli_error($conn));
|
|
}
|
|
|
|
$data_gender["male"][$start_age] = mysqli_num_rows($result1);
|
|
|
|
error_log("query for male count " . $start_age . " " . $query1);
|
|
|
|
|
|
$query2 = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' and $query_age_part and gender='F' order by id asc) $qry_filter $qry_date group by emp_id order by emp_id ";
|
|
|
|
if (!$result2 = mysqli_query($conn, $query2)) {
|
|
error_log("error in female count query 18-24 " . mysqli_error($conn));
|
|
}
|
|
$data_gender["female"][$start_age] = mysqli_num_rows($result2);
|
|
|
|
error_log("query for female count 18 24 " . $query2);
|
|
|
|
|
|
// for patient category distribution
|
|
|
|
$query_cat = "select * from patient_category";
|
|
$result_cat = mysqli_query($conn, $query_cat);
|
|
|
|
while ($row_cat = mysqli_fetch_assoc($result_cat)) {
|
|
$pat_cat = $row_cat['patient_cat_id'];
|
|
$query3 = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' and patient_cat_id = '" . $pat_cat . "' and $query_age_part) $qry_filter $qry_date group by emp_id order by emp_id ";
|
|
|
|
if (!$result3 = mysqli_query($conn, $query3)) {
|
|
error_log("error in cat wise query " . $query3);
|
|
}
|
|
error_log("query " . $query3);
|
|
$data_pat_cat[$pat_cat][$start_age] = mysqli_num_rows($result3);
|
|
}
|
|
|
|
// for designation collar distribution for WC
|
|
|
|
// $part_query = "select designation_id as dsg from designation where designation_collar='WC'";
|
|
// $part_result = mysqli_query($conn,$part_query);
|
|
// $part_row = mysqli_fetch_assoc($part_result);
|
|
// error_log("WC ".$part_row['dsg']);
|
|
|
|
$query4 = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' and designation_id in (select designation_id from designation where designation_collar='WC') and $query_age_part) $qry_filter $qry_date group by emp_id order by emp_id ";
|
|
|
|
if (!$result4 = mysqli_query($conn, $query4)) {
|
|
error_log("error in query 4 " . mysqli_error($conn) . " query " . $query4);
|
|
}
|
|
$data_collar["WC"][$start_age] = mysqli_num_rows($result4);
|
|
error_log("query4 " . $query4);
|
|
|
|
// for designation collar distribution for BC
|
|
|
|
// $part_query_2 = "select designation_id as dsg from designation where designation_collar='WC'";
|
|
// $part_result_2 = mysqli_query($conn,$part_query_2);
|
|
// $part_row_2 = mysqli_fetch_assoc($part_result_2);
|
|
// error_log("BC ".$part_row_2['dsg']);
|
|
|
|
$query5 = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' and designation_id in (select designation_id from designation where designation_collar='BC') and $query_age_part) $qry_filter $qry_date group by emp_id order by emp_id ";
|
|
|
|
if (!$result5 = mysqli_query($conn, $query5)) {
|
|
error_log("error in query 5 " . mysqli_error($conn) . " query " . $query5);
|
|
}
|
|
error_log("query5 " . $query5);
|
|
$data_collar["BC"][$start_age] = mysqli_num_rows($result5);
|
|
}
|
|
}
|
|
$data = array(
|
|
'gender' => $data_gender,
|
|
'patient_category' => $data_pat_cat,
|
|
'collar' => $data_collar
|
|
);
|
|
|
|
error_log("data for 1st graph " . print_r($data, true));
|
|
echo json_encode($data);
|