259 lines
11 KiB
PHP
259 lines
11 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/auth/auth.php');
|
|
include('includes/functions.php');
|
|
include('access.php');
|
|
include('log_entry.php');
|
|
include('constants.php');
|
|
|
|
?>
|
|
<?php
|
|
|
|
// Connect to mysqli database
|
|
$page = 1; // The current page
|
|
$sortname = 'a.last_modified'; // Sort column
|
|
$sortorder = 'desc'; // Sort order
|
|
$qtype = ''; // Search column
|
|
$query = ''; // Search string
|
|
// Get posted data
|
|
if (isset($_POST['page'])) {
|
|
$page = mysqli_real_escape_string($conn, $_POST['page']);
|
|
}
|
|
if (isset($_POST['sortname'])) {
|
|
$sortname = mysqli_real_escape_string($conn, $_POST['sortname']);
|
|
}
|
|
if (isset($_POST['sortorder'])) {
|
|
$sortorder = mysqli_real_escape_string($conn, $_POST['sortorder']);
|
|
}
|
|
if (isset($_POST['qtype'])) {
|
|
$qtype = mysqli_real_escape_string($conn, $_POST['qtype']);
|
|
}
|
|
if (isset($_POST['query'])) {
|
|
$query = mysqli_real_escape_string($conn, $_POST['query']);
|
|
}
|
|
if (isset($_POST['rp'])) {
|
|
$rp = mysqli_real_escape_string($conn, $_POST['rp']);
|
|
}
|
|
|
|
if ($qtype == 'patient_name') {
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
error_log("patient name......." . $searchSql);
|
|
} else if ($qtype == 'medical_entry_date') {
|
|
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype)= STR_TO_DATE('" . trim($query) . "','%d/%m/%Y')" : '';
|
|
error_log("Exam Date......." . $searchSql);
|
|
} else if ($qtype == 'medical_entry_date_between') {
|
|
$dates = explode("-", $query);
|
|
$searchSql = " and medical_entry_date between str_to_date('" . trim($dates[0]) . "','%d/%m/%Y') and str_to_date('" . trim($dates[1]) . "','%d/%m/%Y') ";
|
|
} else if ($qtype == 'task') {
|
|
if ($query == 'Annual Medical Examination') {
|
|
$query = 'annual';
|
|
} else {
|
|
$query = 'pre_employment';
|
|
}
|
|
|
|
// echo $query;
|
|
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
} else if ($qtype == 'aadhar_no') {
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
} else if ($qtype == 'primary_phone') {
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
} else if ($qtype == 'emp_code') {
|
|
$searchSql = ($qtype != '' && $query != '') ? "and trim($qtype) = '" . trim($query) . "'" : '';
|
|
} else if ($qtype == 'patient_cat_name') {
|
|
$searchSql = " and b.patient_cat_id in (select patient_cat_id from patient_category where upper(patient_cat_name) like upper('%" . trim($query) . "%')) ";
|
|
error_log("patient_cat_name......." . $searchSql);
|
|
} else {
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
}
|
|
// Setup sort and search SQL using posted data
|
|
$sortSql = "order by $sortname $sortorder";
|
|
|
|
// Get total count of records
|
|
$ohc_type = $_SESSION['current_ohcttype'];
|
|
// $sql = "select count(*) from medical_examination a, patient_master b where a.patient_id=b.id and (a.forward_status in ('M','D')) and ohc_location_id=$ohc_type $searchSql";
|
|
if ($_SESSION['RoleCode'] == 'LAB') {
|
|
$sql = "SELECT count(*) FROM checkup_form a,patient_master b , checkup_type x where a.emp_id=b.id and a.checkup_type_id=x.checkup_type_id and current_status='DRP' $searchSql";
|
|
}
|
|
if ($_SESSION['RoleCode'] == 'DOC') {
|
|
$sql = "SELECT count(*) FROM checkup_form a,patient_master b , checkup_type x where a.emp_id=b.id and a.checkup_type_id=x.checkup_type_id and current_status='DRP' and a.ohc_type_id='" . $ohc_type . "' $searchSql";
|
|
}
|
|
|
|
if ($_SESSION['RoleCode'] == 'RCP') {
|
|
$sql = "SELECT count(*) FROM checkup_form a,patient_master b , checkup_type x where a.emp_id=b.id and a.checkup_type_id=x.checkup_type_id and current_status='RCP' and a.ohc_type_id='" . $ohc_type . "' $searchSql";
|
|
}
|
|
//echo $sql;
|
|
error_log("query: " . $sql);
|
|
$result = mysqli_query($conn, $sql);
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
// Setup paging
|
|
if (!isset($rp)) {
|
|
$rp = 10;
|
|
}
|
|
//echo $_REQUEST[emp_id];
|
|
$pageStart = ($page - 1) * $rp;
|
|
$limitSql = "limit $pageStart, $rp";
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
// $sql_medical_examination = "select a.*, b.* from medical_examination a, patient_master b where a.patient_id=b.id and (a.forward_status in ('M','D')) and ohc_location_id=$ohc_type";
|
|
//echo $sql_medical_examination;
|
|
// $sql_medical_examination="SELECT a.*, b.* FROM checkup_form a,patient_master b where a.emp_id=b.id and is_test_completed='Y' and b.ohc_type_id=$ohc_type";
|
|
|
|
|
|
// $sql_medical_examination="select a.*, b.patient_name from checkup_form a, patient_master b where a.emp_id=b.id and current_status='$__STATUS_DOCTOR_PENDING' and a.ohc_type_id=$ohc_type $searchSql";
|
|
// error_log("Pending Doc Approval Surveliance:".$sql_medical_examination);
|
|
if ($_SESSION['RoleCode'] == 'LAB') {
|
|
$sql_medical_examination = "SELECT a.*, b.* from checkup_form a, patient_master b , checkup_type x where a.emp_id=b.id and a.checkup_type_id=x.checkup_type_id and current_status='DRP' $searchSql";
|
|
}
|
|
|
|
if ($_SESSION['RoleCode'] == 'DOC') {
|
|
$sql_medical_examination = "SELECT a.*, b.* from checkup_form a, patient_master b , checkup_type x where a.emp_id=b.id and a.checkup_type_id=x.checkup_type_id and current_status ='DRP' and a.ohc_type_id='" . $ohc_type . "' $searchSql";
|
|
}
|
|
|
|
|
|
if ($_SESSION['RoleCode'] == 'RCP') {
|
|
$sql_medical_examination = "SELECT a.*, b.* from checkup_form a, patient_master b , checkup_type x where a.emp_id=b.id and a.checkup_type_id=x.checkup_type_id and current_status ='RCP' and a.ohc_type_id='" . $ohc_type . "' $searchSql";
|
|
}
|
|
|
|
$sql_export = $sql_medical_examination;
|
|
$sql_medical_examination .= " $searchSql $sortSql $limitSql ";
|
|
|
|
$sql_export .= " $searchSql $sortSql ";
|
|
|
|
|
|
|
|
|
|
error_log("medical examination query: " . $sql_medical_examination);
|
|
$results_medical_examination = mysqli_query($conn, $sql_medical_examination);
|
|
$count = ($page - 1) * $rp + 1;
|
|
|
|
//echo $sql_checkup;
|
|
//echo $access_level;
|
|
|
|
|
|
// Setup sort and search SQL using posted data
|
|
$hasReadAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'R');
|
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'W');
|
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'], $menu_key, 'E');
|
|
|
|
|
|
while ($row_medical_examination = mysqli_fetch_assoc($results_medical_examination)) {
|
|
|
|
$checkup_id = $medical_exam_id = $row_medical_examination['checkup_id'];
|
|
$id = $row_medical_examination['emp_id'];
|
|
$checkup_type_id = $row_medical_examination['checkup_type_id'];
|
|
|
|
error_log('#CHECKUP id : ' . $checkup_id);
|
|
error_log('#EMP : ' . $id);
|
|
error_log('#CHECkup_type : ' . $checkup_type_id);
|
|
|
|
$checkup_code = getFieldFromTable('checkup_type_code', 'checkup_type', 'checkup_type_id', $checkup_type_id);
|
|
|
|
|
|
|
|
|
|
//echo $checkup_id;
|
|
$view_link = "";
|
|
$edit_link = "";
|
|
$delete_link = "";
|
|
$links = "";
|
|
/*if($access_level=='R' ||$access_level=='W' || $access_level=='E' )
|
|
{*/
|
|
//echo "shubham";
|
|
//$roleId=$_SESSION['RoleId'];
|
|
/*if($roleId!=6){
|
|
|
|
$edit_link="<a href=\"checkup.php?checkup_id=".$checkup_id."&returnPage=pending_checkup_list.php?pageKey=28&view=edit\" class=\"blue\" ><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
|
|
|
|
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_checkup('".$checkup_id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
|
}*/
|
|
|
|
//$view_link="<a href=\"#\"class=\"green\" onclick=\"open_checkup('".$checkup_id."','".$row_checkup['emp_id']."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
//}
|
|
|
|
//if($access_level=='W' || $access_level=='E' )
|
|
//{
|
|
|
|
//}
|
|
//if($access_level=='E' )
|
|
//{
|
|
|
|
//}
|
|
//
|
|
// $edit_link="<a href=\"checkup.php?checkup_id=".$checkup_id."&returnPage=pending_checkup_list.php?pageKey=28&view=edit\" class=\"blue\" ><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
if ($hasWriteAccess) {
|
|
$edit_link = $space . "<a href=\"#\" class=\"blue\" onclick=\"open_checkup('$checkup_id','$id','E','$checkup_type_id');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
}
|
|
|
|
// $edit_link="<a href='#' class='blue' onclick='open_checkup_form1(".$medical_exam_id.");'><i class='ace-icon fa fa-pencil bigger-130'></i></a>";
|
|
// $edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_checkup_form('".$row_medical_examination['checkup_id']."','".$row_medical_examination['emp_id']."','E');\"><span style=\"font-size:20px\" class=\"glyphicon glyphicon-edit\"></span></a>";
|
|
// if($row_medical_examination['task']=='pme'){
|
|
// $form_name="PME Form";
|
|
// }else if($row_medical_examination['task']=='annual'){
|
|
// $form_name="Annual Medical Examination";
|
|
// }else if($row_medical_examination['task']=='pre_employment'){
|
|
// $form_name="PRE Employment Examination";
|
|
// }else if($row_medical_examination['task']=='semi_annual'){
|
|
// $form_name="Semi-Annual Examination";
|
|
// }
|
|
|
|
|
|
|
|
$medical_entry_date = date_format(date_create($row_medical_examination['checkup_date']), "d-M-Y ");
|
|
// $space=" ";
|
|
|
|
|
|
if ($hasWriteAccess) {
|
|
$checkbox = "<input type='checkbox' value='" . $checkup_id . "' data-checkup-code='" . $checkup_code . "' id='check_" . $count . "' class='checkbox' />";
|
|
}
|
|
|
|
|
|
error_log("checkbox " . $checkbox);
|
|
|
|
|
|
$links = $assign_link . $space . $view_link . $space . $edit_link . $space . $delete_link;
|
|
|
|
|
|
$past_present_illnes = getCommaSeperatedValuesForInClause('select param_name from history_parameter ', 'param_id', $row_medical_examination['past_present_illness']);
|
|
$checkupSections = getCommaSeperatedValuesForInClause("select section_name from checkup_form_section", "section_id", $row_medical_examination['checkup_section_ids']);
|
|
$data['rows'][] = array(
|
|
'id' => $row_medical_examination['checkup_id'],
|
|
|
|
'cell' => array(
|
|
$checkbox,
|
|
$count++,
|
|
$links,
|
|
$medical_entry_date,
|
|
$row_medical_examination['ticket_no'],
|
|
|
|
// $form_name,
|
|
|
|
// $row_medical_examination['emp_id'],
|
|
$row_medical_examination['patient_name'],
|
|
$row_medical_examination['emp_code'],
|
|
getFieldFromTable('checkup_type_name', 'checkup_type', 'checkup_type_id', $row_medical_examination['checkup_type_id']),
|
|
getFieldFromTable('ohc_type_name', 'ohc_type', 'ohc_type_id', $row_medical_examination['ohc_type_id']),
|
|
$row_medical_examination['patient_cat_id'] == 0 ? 'Non-Employee' : 'Employee',
|
|
$row_medical_examination['aadhar_no'],
|
|
$row_medical_examination['primary_phone'],
|
|
// $row_medical_examination['remarks'],
|
|
// $checkupSections,
|
|
$row_medical_examination['is_test_completed'] == 'Y' ? 'YES' : 'NO'
|
|
// $row_medical_examination['current_status']=='Aproved'?'approved':'not aprroved'
|
|
)
|
|
);
|
|
}
|
|
$data['rows'][] = array(
|
|
'id' => $row_medical_examination['filterkey'],
|
|
'cell' => array('', "<input type=hidden name='filterkey' id='filterkey' value=\"" . base64_encode($sql_export) . "\">", "<input type=hidden name=paramlist id=paramlist value=\"" . base64_encode($paramlist) . "\">", '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')
|
|
);
|
|
|
|
// error_log("data: ".print_r($data, true));
|
|
echo json_encode($data);
|
|
?>
|