238 lines
11 KiB
PHP
238 lines
11 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_date'; // 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
|
|
// Setup paging
|
|
if (! isSet($rp)) {
|
|
$rp = 20;
|
|
}
|
|
$sortSql = "order by $sortname $sortorder";
|
|
$pageStart = ($page - 1) * $rp;
|
|
$limitSql = " limit $pageStart, $rp";
|
|
// $searchSql = ($qtype != '' && $query != '') ? "where upper($qtype) like upper('%" . trim($query) . "%')" : '';
|
|
// Get total count of records
|
|
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 == 'ailment_name') {
|
|
$searchSql = " and upper(ailments_new) like upper(trim('%$query%') ) ";
|
|
}else if ($qtype == 'complaints') {
|
|
$query='"'.$query.'"';
|
|
$dates = getTableFieldValue("complaints","complaint_id","complaint",$query);
|
|
// $qtype=" due_date between ";
|
|
$searchSql ="and FIND_IN_SET('$dates',complaints)" ;
|
|
} else if ($qtype == 'IsEmergency') {
|
|
if($query=="Y" || $query=="y" ){
|
|
$dates=1;
|
|
}
|
|
else{
|
|
$dates=0;
|
|
}
|
|
// $qtype=" due_date between ";
|
|
$searchSql ="and $qtype=$dates" ;
|
|
}
|
|
else if ($qtype == 'examination_remarks') {
|
|
$query='"'.$query.'"';
|
|
$dates = getTableFieldValue("examination_findings","id","examination_finding",trim($query));
|
|
// $qtype=" due_date between ";
|
|
$searchSql ="and FIND_IN_SET('$dates',examination_remarks)" ;
|
|
} else {
|
|
$searchSql = ($qtype != '' && $query != '') ? " and upper($qtype) like upper('%$query%')" : '';
|
|
}
|
|
|
|
$sql = "SELECT count(*) from employee_appointment ep inner join patient_master e on e.id=ep.emp_id left join detention_master dm on ep.appointment_id=dm.opd_id where ep.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and ep.is_detention ='Y' $searchSql ";
|
|
// echo $sql;
|
|
// echo $sql;
|
|
$result = mysqli_query($conn,$sql);
|
|
$row = mysqli_fetch_array($result);
|
|
$total = $row[0];
|
|
// Return JSON data
|
|
$data = array();
|
|
$data['page'] = $page;
|
|
$data['total'] = $total;
|
|
$data['rows'] = array();
|
|
|
|
|
|
|
|
$sql_employee_appointment = "select patient_name,emp_code ,e.id,appointment_id, appointment_date,ticket_no, token_no, 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
|
|
,IsEmergency,doctor_attended_flag,ailments_new, injury_types_new,ep.attended_status,disposal_time, ep.is_detention,ep.is_discharge from employee_appointment ep inner join patient_master e on e.id=ep.emp_id left join detention_master dm on ep.appointment_id=dm.opd_id where ep.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and ep.is_detention IN ('Y') $searchSql $sortSql";
|
|
// echo $sql_employee_appointment;
|
|
$sql_export = $sql_employee_appointment;
|
|
$sql_employee_appointment .= $limitSql ;
|
|
// echo $sql_employee_appointment;
|
|
$results_employee_appointment = mysqli_query($conn,$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 = "";
|
|
$appointment_type = $row_employee_appointment['appointment_type'];
|
|
$appointment_id = $row_employee_appointment['appointment_id'];
|
|
$appointment_status = $row_employee_appointment['attended_status'];
|
|
$emp_id = $row_employee_appointment['id'];
|
|
if ($appointment_type == 'O') {
|
|
$diagnosis = getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row_employee_appointment['ailments_new']);
|
|
// $diagnosis =$row_employee_appointment['ailments_new'];
|
|
} else if ($appointment_type == 'I') {
|
|
// $diagnosis=$row_employee_appointment['injury_types_new'];
|
|
$diagnosis = getCommaSeperatedValuesForInClause("select injury_type_name from injury_type", "injury_type_id", $row_employee_appointment['injury_types_new']);
|
|
}
|
|
$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];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$view_link = "";
|
|
$edit_link = "";
|
|
$pdf_link = "";
|
|
$links = "";
|
|
$delete_link = "";
|
|
$dashboard_link="";
|
|
$space = " ";
|
|
$treatment_text = getTreatmentText($row_employee_appointment['appointment_id']);
|
|
if (isAccessible($_SESSION['RoleId'], $menu_key, 'R')) {
|
|
$pdf_link = $space . "<a href=\"#\" class=\"red\" onclick=\"exporttopdf_common_ipd('" . $appointment_type . "','" . $appointment_id . "','" . $appointment_status . "');\"><i class=\"fa fa-file-pdf-o\" style=\"font-size: 15px;\"></i></a>";
|
|
// $view_link = $space . "<a id='appointment_id_" . $appointment_id . "' href=\"#\"class=\"green\" onclick=\"open_detention('" . $appointment_id . "','" . $appointment_status . "','" . $emp_id . "','V');\"><i class=\"ace-icon fa fa-search-plus\" style=\"font-size: 15px;\"></i></a>";
|
|
$dashboard_link=$space . "<a href=\"#\" class=\"megenta\" onclick=\"open_dashboard('" . $emp_id . "');\"><i style=\"font-size: 15px;\" class=\"glyphicon glyphicon-user\"></i></a>";
|
|
|
|
}
|
|
if (isAccessible($_SESSION['RoleId'], $menu_key, 'W')) {
|
|
$edit_link = $space . "<a href=\"#\" class=\"blue\" onclick=\"open_detention('" . $appointment_id . "','" . $appointment_status . "','" . $emp_id . "','E');\"><i class=\"glyphicon glyphicon-share\" style=\"font-size: 15px;\"></i></a>";
|
|
}
|
|
if (isAccessible($_SESSION['RoleId'], $menu_key, 'E') && $treatment_text == '' && $row_employee_appointment['doctor_attended_flag'] != 'Y') {
|
|
$delete_link = $space . "<a href=\"#\" class=\"blue\" onclick=\"delete_employee_appointment_history('" . $appointment_id . "');\"><i class=\"ace-icon fa fa-trash-o\" style=\"font-size: 15px;\"></i></a>";
|
|
}
|
|
|
|
|
|
$detention_status = '';
|
|
if( $row_employee_appointment['is_discharge']=='Y'){
|
|
$detention_status = "<span class='green'>Discharge</i></span>";
|
|
}
|
|
else{
|
|
$detention_status = "<span class='red'>Admitted</i></span>";
|
|
}
|
|
|
|
|
|
|
|
if($row_employee_appointment['doctor_attended_flag'] != 'Y'){
|
|
$pdf_link="";
|
|
}
|
|
$links = $view_link . $edit_link . $delete_link . $pdf_link . $dashboard_link;
|
|
|
|
// $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>";
|
|
// }
|
|
|
|
|
|
if ($row_employee_appointment['is_detention']=='Y' || $row_employee_appointment['is_detention']=='N') {
|
|
$doctor_attended_flag = "<span class=' lighter green'>YES</i></span>";
|
|
}else{
|
|
$doctor_attended_flag = "<span class=' lighter red'>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];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
$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'];
|
|
$data['rows'][] = array(
|
|
'id' => $row_employee_appointment['appointment_id'],
|
|
'cell' => array(
|
|
$count ++,
|
|
$links,
|
|
date_format(date_create($row_employee_appointment['appointment_date']), "d-M-Y H:i "),
|
|
$row_employee_appointment['ticket_no'],
|
|
$row_employee_appointment['emp_code'],
|
|
$row_employee_appointment['patient_name'],
|
|
$doctor_attended_flag,
|
|
$detention_status,
|
|
$complaints,
|
|
getTableFieldValue("examination_findings","examination_finding","id",$row_employee_appointment['examination_remarks']),
|
|
$diagnosis,
|
|
$treatment_text,
|
|
$row_employee_appointment['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);
|
|
?>
|