69 lines
2.4 KiB
PHP
69 lines
2.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 = "";
|
||
|
|
||
|
$start_date = $_REQUEST['startDate'];
|
||
|
$end_date = $_REQUEST['endDate'];
|
||
|
|
||
|
|
||
|
$ohc_id = $_REQUEST['ohc'];
|
||
|
|
||
|
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 . "'";
|
||
|
}
|
||
|
$data = array();
|
||
|
$sql_abnormality = "select * from abnormality";
|
||
|
$result_abnormality = mysqli_query($conn, $sql_abnormality);
|
||
|
while ($row_abnormality = mysqli_fetch_assoc($result_abnormality)) {
|
||
|
|
||
|
$abnormality_id = $row_abnormality['abnormality_id'];
|
||
|
|
||
|
$query = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' order by id asc) and abnormality_ids ='" . $abnormality_id . "' or abnormality_ids like '%," . $abnormality_id . "' or abnormality_ids like '" . $abnormality_id . ",%' or abnormality_ids like '%," . $abnormality_id . ",%' $qry_filter $qry_date group by emp_id order by emp_id ";
|
||
|
|
||
|
error_log("query for abnormality count " . $query);
|
||
|
if (!$result = mysqli_query($conn, $query)) {
|
||
|
error_log("error " . mysqli_error($conn) . " query " . $query);
|
||
|
} else {
|
||
|
$count = mysqli_num_rows($result);
|
||
|
if ($count > 0) {
|
||
|
$data[$abnormality_id] = $count;
|
||
|
} else {
|
||
|
$data[$abnormality_id] = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$total_count = "select max(checkup_id) from checkup_form where emp_id in (select id from patient_master where status='Active' order by id asc) $qry_filter $qry_date group by emp_id order by emp_id ";
|
||
|
$result_count = mysqli_query($conn, $total_count);
|
||
|
$count = mysqli_num_rows($result_count);
|
||
|
if ($count > 0) {
|
||
|
$data['total'] = $count;
|
||
|
} else {
|
||
|
$data['total'] = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
error_log("abnormality count " . print_r($data, true));
|
||
|
echo json_encode($data);
|