156 lines
6.6 KiB
PHP
156 lines
6.6 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/auth/auth.php');
|
||
|
include('includes/functions.php');include('access.php');
|
||
|
// error_reporting(E_ERROR | E_PARSE);
|
||
|
include('log_entry.php')
|
||
|
?>
|
||
|
<?php
|
||
|
|
||
|
// Connect to mysqli database
|
||
|
$page = 1; // The current page
|
||
|
$sortname = 'emp_id'; // Sort column
|
||
|
$sortorder = 'asc'; // 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']);
|
||
|
}
|
||
|
// Setup sort and search SQL using posted data
|
||
|
$menu_key='1.171';
|
||
|
$hasReadAccess = isAccessible($_SESSION['RoleId'],$menu_key,'R');
|
||
|
$hasWriteAccess = isAccessible($_SESSION['RoleId'],$menu_key,'W');
|
||
|
$hasExecuteAccess = isAccessible($_SESSION['RoleId'],$menu_key,'E');
|
||
|
|
||
|
if($qtype=='patient_name'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='date_added'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype)= STR_TO_DATE('".trim ( $query )."','%d/%m/%Y')" : '';
|
||
|
}else if($qtype=='dept_name'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='spo2_basis'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='result_name'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='resumed_duties_from'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype)= STR_TO_DATE('".trim ( $query )."','%d/%m/%Y')" : '';
|
||
|
}else if($qtype=='tested_positive_on'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype)= STR_TO_DATE('".trim ( $query )."','%d/%m/%Y')" : '';
|
||
|
}else if($qtype=='discharge_on'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype)= STR_TO_DATE('".trim ( $query )."','%d/%m/%Y')" : '';
|
||
|
}else if($qtype=='emp_id'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='gender'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='remarks'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else if($qtype=='result_name'){
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
}else{
|
||
|
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
|
||
|
|
||
|
}
|
||
|
$sortSql = "order by $sortname $sortorder";
|
||
|
//$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%$query%')" : '';
|
||
|
// Get total count of records
|
||
|
$sql = "select count(*)from covid_monitoring $searchSql";
|
||
|
$result = @mysqli_query($conn,$sql);
|
||
|
$row = @mysqli_fetch_array($result);
|
||
|
$total = $row[0];
|
||
|
// Setup paging
|
||
|
if(!isSet($rp)){
|
||
|
$rp=10;
|
||
|
}
|
||
|
$pageStart = ($page-1)*$rp;
|
||
|
$limitSql = "limit $pageStart, $rp";
|
||
|
// Return JSON data
|
||
|
$data = array();
|
||
|
$data['page'] = $page;
|
||
|
$data['total'] = $total;
|
||
|
$data['rows'] = array();
|
||
|
$sql_ailment = "select a.*, b.patient_name, b.gender, b.dob, b.personal_phone, b.village,b.primary_phone ,b.emp_code,c.name, d.result_name, e.type_name, f.dept_name from covid_monitoring a left join patient_master b on a.emp_id = b.id left join covid_patient_staying c on a.staying_id = c.id left join covid_test_result_master d on a.covid_test_result_id = d.id left join covid_contact_type_master e on a.covid_contact_id = e.id left join department f on b.dept_id = f.dept_id $searchSql $sortSql $limitSql";
|
||
|
//echo $sql_ailment;
|
||
|
error_log("Sql: ".$sql_ailment);
|
||
|
$results_ailment = @mysqli_query($conn,$sql_ailment);
|
||
|
$count=($page-1)*$rp+1;
|
||
|
|
||
|
//echo $sql_ailment;
|
||
|
//echo $access_level;
|
||
|
|
||
|
while ($row_ailment = @mysqli_fetch_assoc($results_ailment)) {
|
||
|
|
||
|
$id=$row_ailment['id'];
|
||
|
//echo $id;
|
||
|
// error_log("id: ".$id);
|
||
|
$view_link="";
|
||
|
$edit_link="";
|
||
|
$delete_link="";
|
||
|
$links="";
|
||
|
if($hasReadAccess)
|
||
|
{
|
||
|
//echo "shubham";
|
||
|
$view_link="<a href=\"#\"class=\"green\" onclick=\"open_covid_monitoring('".$id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
||
|
}
|
||
|
|
||
|
if($hasWriteAccess)
|
||
|
{
|
||
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_covid_monitoring('".$id."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
||
|
}
|
||
|
if($hasExecuteAccess)
|
||
|
{
|
||
|
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_covid_monitoring('".$id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
|
||
|
}
|
||
|
$space=" ";
|
||
|
$links = $assign_link.$space.$view_link.$space.$edit_link.$space.$delete_link;
|
||
|
|
||
|
// calculate age by dob
|
||
|
$age = date_diff(date_create($row_ailment['dob']), date_create('now'))->y;
|
||
|
$date_added=date_create($row_ailment['date_added']);
|
||
|
$date_added=date_format($date_added,"d-m-Y");
|
||
|
$dateStrVal = strtotime($row_ailment['resumed_duties_from']);
|
||
|
if(empty($dateStrVal)) {
|
||
|
$resumed_duties_from = 'NA';
|
||
|
} else {
|
||
|
$resumed_duties_from = date( 'd-m-Y', strtotime($row_ailment['resumed_duties_from']));
|
||
|
}
|
||
|
|
||
|
$dateStrVal2 = strtotime($row_ailment['tested_positive_on']);
|
||
|
if(empty( $dateStrVal2)) {
|
||
|
$tested_positive_on = 'NA';
|
||
|
} else {
|
||
|
$tested_positive_on = date( 'd-m-Y h:i A', strtotime($row_ailment['tested_positive_on']));
|
||
|
}
|
||
|
|
||
|
$dateStrVal3 = strtotime($row_ailment['discharge_on']);
|
||
|
if(empty($dateStrVal3)) {
|
||
|
$discharge_on = 'NA';
|
||
|
} else {
|
||
|
$discharge_on = date( 'd-m-Y h:i A', strtotime($row_ailment['discharge_on']));
|
||
|
}
|
||
|
// error_log("discharge date on script: ".$discharge_on."spo2_basis is: ".$row_ailment['spo2_basis']);
|
||
|
|
||
|
$data['rows'][] = array(
|
||
|
'id' => $row_ailment['id'],
|
||
|
'cell' => array($links, $count++, $date_added ,$row_ailment['patient_name'], $row_ailment['gender'],$row_ailment['emp_code'],$row_ailment['dept_name'], $row_ailment['type_name'], $row_ailment['name'], $row_ailment['primary_phone'], $row_ailment['spo2_basis'], $row_ailment['remarks'], $row_ailment['result_name'], $resumed_duties_from, $tested_positive_on, $discharge_on)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
echo json_encode($data);
|
||
|
// error_log(json_encode($data));
|
||
|
?>
|