187 lines
6.9 KiB
PHP
187 lines
6.9 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 = 'appointment_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']);
|
|
}
|
|
if (!isset($_POST['rp'])) {
|
|
$rp=10;
|
|
}
|
|
// Setup sort and search SQL using posted data
|
|
$sortSql = " order by $sortname $sortorder";
|
|
$searchSql = ($qtype != '' && $query != '') ? "and upper($qtype) like upper('%$query%')" : '';
|
|
|
|
|
|
if ($searchSql != '') {
|
|
|
|
if ($qtype == 'appointment_date') {
|
|
|
|
$searchSql = " and date_format(date(appointment_date),'%Y-%m-%d')=str_to_date('$query','%d/%m/%Y') ";
|
|
// $searchSql = " and date_format(date(appointment_date),'%Y-%m-%d')=str_to_date('$query','%d-%m-%Y') ";
|
|
}
|
|
|
|
|
|
else if($qtype=='appointment_date_between'){
|
|
$dates=explode("-",$query);
|
|
|
|
//$qtype=" due_date between ";
|
|
$searchSql=" and appointment_date between str_to_date('".trim($dates[0])."','%d/%m/%Y') and str_to_date('".trim($dates[1])."','%d/%m/%Y') ";
|
|
}
|
|
else if($qtype=='IsEmergency'){
|
|
|
|
if(strtoupper($query)=='Y'){
|
|
$query='1';
|
|
|
|
$searchSql=" and $qtype = '$query' ";
|
|
}else{
|
|
$query='0';
|
|
|
|
$searchSql=" and $qtype='$query' ";
|
|
|
|
}
|
|
|
|
}
|
|
else if($qtype=='appointment_type'){
|
|
|
|
if(strtoupper($query)=='Y'){
|
|
$query='I';
|
|
|
|
$searchSql=" and $qtype ='$query' ";
|
|
}else{
|
|
$query='O';
|
|
|
|
$searchSql=" and $qtype='$query' ";
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
// Get total count of records
|
|
$sql_emp_count = "SELECT count(*) FROM guest_appointment ga inner join guest_patient gp on ga.guest_id=gp.id where ga.guest_id='".$_REQUEST['guest_id']."' $searchSql ";
|
|
|
|
|
|
//echo $sql_emp_count;
|
|
$result_emp_count = mysqli_query($conn,$sql_emp_count);
|
|
$rowCount_emp_count = mysqli_fetch_array($result_emp_count);
|
|
$total = $rowCount_emp_count[0];
|
|
|
|
|
|
// Setup paging SQL
|
|
$pageStart = ($page-1)*$rp;
|
|
$limitSql = " limit $pageStart, $rp";
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
$count=($page-1)*$rp+1;
|
|
|
|
$guest_id=$_REQUEST['guest_id'];
|
|
$sql_list = "SELECT appointment_id, concat(fname,' ',lname) as name,appointment_date, complaints, examination_remarks,ticket_no, ailment_ids, injury_types,hospital_treatment,referral,followup,IsEmergency,appointment_type,bp_sbp,bp_dbp,blood_sugar_fbs,blood_sugar_rbs,gp.associated_emp_id as emp_id, remarks FROM guest_appointment a inner join guest_patient gp on a.guest_id=gp.id where a.guest_id='".$_REQUEST['guest_id']."' ";
|
|
//echo $sql_list;
|
|
|
|
$sql_export=$sql_list." $searchSql $sortSql";
|
|
$sql_list = $sql_list." $searchSql $sortSql $limitSql";
|
|
//echo $sql_list;
|
|
$resultList = mysqli_query($conn,$sql_list);
|
|
//echo $resultList;
|
|
while ($row = mysqli_fetch_array($resultList)) {
|
|
|
|
$id=$row['appointment_id'];
|
|
|
|
$view_link="";
|
|
$edit_link="";
|
|
$delete_link="";
|
|
$links="";
|
|
|
|
//echo "shubham";
|
|
|
|
$roleId=$_SESSION['RoleId'];
|
|
|
|
if($row['appointment_type']=='O'){
|
|
$view_link="<a href=\"view_guest_opd.php?appointmentId=".$id."&flex_opd_id=".$guest_id."&returnPage=opd_form.php?flex_opd_id=".$guest_id."&view=view\" class=\"green\" ><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
}else if($row['appointment_type']=='I'){
|
|
$view_link="<a href=\"view_guest_injury.php?appointmentId=".$id."&flex_opd_id=".$guest_id."&returnPage=opd_form.php?flex_opd_id=".$guest_id."&view=view\" class=\"green\" ><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
|
}
|
|
|
|
|
|
if($row['appointment_type']=='O'){
|
|
$edit_link="<a href=\"view_guest_opd.php?appointmentId=".$id."&flex_opd_id=".$guest_id."&returnPage=opd_form.php?flex_opd_id=".$guest_id."&view=edit\" class=\"blue\" ><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
}else if($row['appointment_type']=='I'){
|
|
$edit_link="<a href=\"view_guest_injury.php?appointmentId=".$id."&flex_opd_id=".$guest_id."&returnPage=opd_form.php?flex_opd_id=".$guest_id."&view=edit\" class=\"blue\" ><i class=\"ace-icon fa fa-pencil bigger-130\"></i></a>";
|
|
}
|
|
|
|
|
|
|
|
$delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_guest_appointment_history('".$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;
|
|
$isEmergency ="";
|
|
$isInjury="";
|
|
if($row['appointment_type']=='I'){
|
|
//$links.="<script>$('#appointment_id_".$appointment_id."').closest('tr').css({\"background-color\": \"#EFAD62\"});</script>";
|
|
$isInjury="<span class='red'><i class=\"ace-icon fa fa-check\"></i></span>";
|
|
|
|
}if($row['IsEmergency']==1 ){
|
|
// $links.="<script>$('#appointment_id_".$appointment_id."').closest('tr').css({\"background-color\": \"##DE1144\"});</script>";
|
|
$isEmergency ="<span class=' lighter red'><i class=\"ace-icon fa fa-check\"></i></span>";
|
|
|
|
}
|
|
$check_results = "SBP:".$row['bp_sbp'].", DBP:".$row['bp_dbp'].", FBS:".$row['blood_sugar_fbs'].", RBS:".$row['blood_sugar_rbs'];
|
|
if($row['appointment_type']=='O'){
|
|
$diagnosis =getCommaSeperatedValuesForInClause("select ailment_name from ailment ","ailment_id",$row['ailment_ids']);
|
|
}else if($row['appointment_type']=='I'){
|
|
$diagnosis=getCommaSeperatedValuesForInClause("select injury_type_name from injury_type","injury_type_id",$row['injury_types']);
|
|
}
|
|
|
|
$appointment_date =$row['appointment_date'];
|
|
$complaints =$row['complaints'];
|
|
$examination_remarks =$row['examination_remarks'];
|
|
$space=" ";
|
|
$links = $view_link.$space.$edit_link.$space.$delete_link;
|
|
$data['rows'][] = array(
|
|
'id' => $row['id'],
|
|
'cell' => array($count++, date_format(date_create($row['appointment_date']),"d-M-Y H:i A"),$row['ticket_no'],$row['name'],getTableFieldValue('employee',"concat(fname,' ',lname)",'id',$row['emp_id']),$complaints, $examination_remarks, $diagnosis, getTreatmentTextForGuest($row['appointment_id']),$row['referral'], $row['followup'],$isEmergency, $isInjury,$check_results,$row['remarks'], $links)
|
|
);
|
|
}
|
|
;
|
|
|
|
$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);
|
|
|
|
|
|
|
|
?>
|