173 lines
7.3 KiB
PHP
173 lines
7.3 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
|
||
|
$emp_id = $_REQUEST['emp_id'];;
|
||
|
//echo $emp_id;
|
||
|
// 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']);
|
||
|
}
|
||
|
// Setup sort and search SQL using posted data
|
||
|
$sortSql = "order by $sortname $sortorder";
|
||
|
$searchSql = ($qtype != '' && $query != '') ? " and upper($qtype) like upper('%$query%')" : '';
|
||
|
// Get total count of records
|
||
|
//echo 'shu'.$p;
|
||
|
|
||
|
|
||
|
$sql = "select count(*)from employee_appointment ep inner join patient_master e on e.id=ep.emp_id where emp_id = '".$emp_id."' $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_employee_appointment = "select patient_name,emp_code,doctor_attended_flag ,e.id,appointment_id,ticket_no, appointment_date,ailments_new, injury_types_new, complaints,examination_remarks,ailment_ids,hospital_treatment, referral,followup,remarks, appointment_type,injury_types,bp_sbp,bp_dbp,blood_sugar_fbs,blood_sugar_rbs,temperature,spo2_percent from employee_appointment ep inner join patient_master e on e.id=ep.emp_id where emp_id = '".$emp_id."' ";
|
||
|
|
||
|
|
||
|
$sql_export = $sql_employee_appointment;
|
||
|
|
||
|
$sql_employee_appointment.=" $searchSql $sortSql $limitSql ";
|
||
|
$sql_export.=" $searchSql $sortSql ";
|
||
|
|
||
|
$results_employee_appointment = mysqli_query($conn,$sql_employee_appointment);
|
||
|
//echo $sql_employee_appointment;
|
||
|
$count=($page-1)*$rp+1;
|
||
|
//echo $sql_ailment;
|
||
|
//echo $access_level;
|
||
|
while ($row_employee_appointment = mysqli_fetch_assoc($results_employee_appointment)) {
|
||
|
|
||
|
extract($row_employee_appointment);
|
||
|
|
||
|
$diagnosis =$row_employee_appointment['appointment_type'];
|
||
|
$appointment_type =$row_employee_appointment['appointment_type'];
|
||
|
|
||
|
$employee_appointment=$row_employee_appointment['appointment_id'];
|
||
|
if($appointment_type=='O'){
|
||
|
$diagnosis =$row_employee_appointment['ailments_new'];
|
||
|
}else if($appointment_type=='I'){
|
||
|
$diagnosis=$row_employee_appointment['injury_types_new'];
|
||
|
}
|
||
|
|
||
|
//echo $ailment_id;
|
||
|
$view_link="";
|
||
|
$edit_link="";
|
||
|
$delete_link="";
|
||
|
$pdf_link="";
|
||
|
$links="";
|
||
|
$emp_id= $row_employee_appointment['id'];
|
||
|
//echo "shubham";
|
||
|
|
||
|
|
||
|
if($appointment_type=='I' && isAccessible($_SESSION['RoleId'],$menu_key,'R')){
|
||
|
$pdf_link="<a href=\"#\" class=\"blue\" onclick=\"pdf2('".$appointment_id."');\"><i class=\"fa fa-file-pdf-o\"></i></a>";
|
||
|
}
|
||
|
|
||
|
if($appointment_type=='O' && isAccessible($_SESSION['RoleId'],$menu_key,'R')){
|
||
|
$pdf_link="<a href=\"#\" class=\"blue\" onclick=\"pdf1('".$appointment_id."');\"><i class=\"fa fa-file-pdf-o\"></i></a>";
|
||
|
}
|
||
|
|
||
|
if(isAccessible($_SESSION['RoleId'],$menu_key,'R'))
|
||
|
{
|
||
|
$view_link="<a id='appointment_id_".$appointment_id."' href=\"#\"class=\"green\" onclick=\"open_employee_appointment('".$appointment_id."','".$appointment_type."','".$emp_id."','V');\"><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
|
||
|
}
|
||
|
|
||
|
if(isAccessible($_SESSION['RoleId'],$menu_key,'W'))
|
||
|
{
|
||
|
$edit_link="<a href=\"#\" class=\"blue\" onclick=\"open_employee_appointment('".$appointment_id."','".$appointment_type."','".$emp_id."','E');\"><i class=\"glyphicon glyphicon-share\"></i></a>";
|
||
|
}
|
||
|
$space=" ";
|
||
|
$history_links = $space.$view_link.$space.$edit_link.$space.$pdf_link;
|
||
|
|
||
|
|
||
|
$isEmergency ="";
|
||
|
$isInjury="";
|
||
|
if ($appointment_type == 'I') {
|
||
|
$isInjury = "<span class='red'>Yes</i></span>";
|
||
|
}else{
|
||
|
$isInjury = "<span class='green'>No</i></span>";
|
||
|
}
|
||
|
if ($row_employee_appointment['IsEmergency'] == 1) {
|
||
|
$isEmergency = "<span class=' lighter red'>Yes</i></span>";
|
||
|
}else{
|
||
|
$isEmergency = "<span class='green'>No</i></span>";
|
||
|
|
||
|
}
|
||
|
$complaint_ids = $row_employee_appointment['complaints'];
|
||
|
$complaint_ids_array = array();
|
||
|
$complaint_ids_array = explode(",", $complaint_ids);
|
||
|
$complaints = "";
|
||
|
for ($i = 0; $i < count($complaint_ids_array); $i++) {
|
||
|
if ($i == 0) {
|
||
|
if (is_numeric($complaint_ids_array[$i])) {
|
||
|
$complaints = getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaint_ids_array[$i]);
|
||
|
} else {
|
||
|
$complaints = $complaint_ids_array[$i];
|
||
|
}
|
||
|
} else {
|
||
|
if (is_numeric($complaint_ids_array[$i])) {
|
||
|
$complaints = $complaints . "," . getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaint_ids_array[$i]);
|
||
|
} else {
|
||
|
$complaints = $complaints . "," . $complaint_ids_array[$i];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$doctor_attended_flag="No";
|
||
|
if ($row_employee_appointment['doctor_attended_flag'] == 'Y') {
|
||
|
$doctor_attended_flag = "<span class=' lighter red'>Yes</i></span>";
|
||
|
}else{
|
||
|
$doctor_attended_flag = "<span class='green'>No</i></span>";
|
||
|
|
||
|
}
|
||
|
$check_results = "SBP:".$row_employee_appointment['bp_sbp'].", DBP:".$row_employee_appointment['bp_dbp'].", FBS:".$row_employee_appointment['blood_sugar_fbs'].", RBS:".$row_employee_appointment['blood_sugar_rbs'].", Temp:".$row_employee_appointment['temperature'].", SPOC2%:".$row_employee_appointment['spo2_percent'];
|
||
|
$referral = getCommaSeperatedValuesForInClause("select referral_point_name from referral_point ", "referral_point_id ", $row_employee_appointment['referral']);
|
||
|
$findings = getCommaSeperatedValuesForInClause("select examination_finding from examination_findings ", "id", $row_employee_appointment['examination_remarks']);
|
||
|
$diagnosis = getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row_employee_appointment['ailments_new']);
|
||
|
$data['rows'][] = array(
|
||
|
'id' => $row_employee_appointment['appointment_id'],
|
||
|
'cell' => array($count++,$history_links, date_format(date_create($row_employee_appointment['appointment_date']),"d-M-Y H:i A"),$row_employee_appointment['ticket_no'], $row_employee_appointment['emp_code'],$row_employee_appointment['patient_name'], $isEmergency, $isInjury,$doctor_attended_flag, $complaints,$findings,$diagnosis,getTreatmentText($row_employee_appointment['appointment_id']),$referral,$row_employee_appointment['followup'],$check_results )
|
||
|
);
|
||
|
}
|
||
|
$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);
|
||
|
?>
|