ESH/covid_screening_grid_script.php
2024-10-23 18:28:06 +05:30

193 lines
7.4 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);
?>
<?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']);
}
// 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');
$sortSql = "order by $sortname $sortorder";
if($qtype=='patient_name'){
$searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
}else if ($qtype == 'emp_code') {
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . 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 ) . "%')) ";
}else if ($qtype == 'aadhar_no') {
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
}else if ($qtype == 'rac_test') {
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
}else if ($qtype == 'rac_result') {
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
}else {
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%" . trim ( $query ) . "%')" : '';
}
$ohc_type=$_SESSION['current_ohcttype'];
// Get total count of records
$sql = "select count(*) from covid_screening_details AS a INNER JOIN patient_master AS b ON a.patient_id=b.id INNER JOIN answer_covid AS c ON a.patient_id=c.patient_id $searchSql";
// $sql_export
//echo $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 * FROM covid_screening_details AS a INNER JOIN patient_master AS b ON a.patient_id=b.id INNER JOIN answer_covid AS c ON a.patient_id=c.patient_id ";
$sql_export=$sql_medical_examination;
$sql_export.="$searchSql $sortSql";
$sql_medical_examination.="$searchSql $sortSql $limitSql";
//echo $sql_medical_examination;
$results_medical_examination = mysqli_query($conn,$sql_medical_examination);
$count=($page-1)*$rp+1;
//echo $sql_checkup;
//echo $access_level;
while ($row_medical_examination = mysqli_fetch_assoc($results_medical_examination)) {
// $medical_exam_id=$row_medical_examination['medical_exam_id'];
//echo $checkup_id;
$patient_id=$row_medical_examination['patient_id'];
$view_link="";
$edit_link="";
$delete_link="";
$links="";
// if($hasReadAccess)
// {
// //echo "shubham";
// $view_link="<a href=\"#\"class=\"green\" onclick=\"open_covid_form('".$patient_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_form('".$row_medical_examination['patient_id']."','E');\"><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
$pdf_link="<a href=\"#\" class=\"blue\" onclick=\"open_covid_pdf('".$row_medical_examination['patient_id']."','E');\"><span style=\"font-size:20px\" class=\"fa fa-file-pdf-o\"></span></a>";
}
if($hasExecuteAccess)
{
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_vaccine('".$patient_id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
$pdf_link="<a href=\"#\" class=\"blue\" onclick=\"open_covid_pdf('".$row_medical_examination['patient_id']."','E');\"><span style=\"font-size:20px\" class=\"fa fa-file-pdf-o\"></span></a>";
}
/*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>";
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_checkup('".$checkup_id."','".$row_checkup['emp_id']."','E');\"><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' )
//{
//}
// if($access_level=='W' || $access_level=='E' )
// {
// $edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_medical_examination_form('".$row_medical_examination[medical_exam_id]."','".$row_medical_examination['patient_id']."','".$row_medical_examination['task']."','E');\"><span style=\"font-size:20px\" class=\"glyphicon glyphicon-edit\"></span></a>";
// }
// if($access_level=='E' || $access_level=='W' )
// {
// $delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_medical_examination_form('".$row_medical_examination[medical_exam_id]."','".$row_medical_examination['patient_id']."','".$row_medical_examination['task']."','E');\"><span style=\"font-size:20px\" class=\"glyphicon glyphicon-trash\"></span></a>";
// }
$space="&nbsp;&nbsp;&nbsp;";
$links = $assign_link.$space.$view_link.$space.$edit_link.$space.$delete_link.$space.$pdf_link;
//$past_present_illnes=getCommaSeperatedValuesForInClause('select param_name from history_parameter ','param_id',$row_medical_examination['past_present_illness']);
$data['rows'][] = array(
'id' => $row_medical_examination['patient_id'],
'cell' => array($links,$count++,$row_medical_examination['test_date'] ,$row_medical_examination['patient_name'],$row_medical_examination['emp_code'],$row_medical_examination['patient_cat_id']==0?'Non-Employee':'Employee',$row_medical_examination['aadhar_no'],$row_medical_examination['primary_phone'],$row_medical_examination['rac_test'],$row_medical_examination['rac_result'])
);
}
$data ['rows'] [] = array (
'id' => $row ['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 ) . "\">",
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''
)
);
echo json_encode($data);
?>