ESH/pending_patient_list_script.php

285 lines
9.5 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?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_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
$sortSql = "order by $sortname $sortorder";
if ($qtype == 'emp_code') {
$emp_id = getFieldFromTable('id', 'patient_master', 'emp_code', trim($query));
$searchSql = ($qtype != '' && $query != '' && trim($query) != '') ? " and ep.emp_id = '" . $emp_id . "' " : '';
} else {
$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') ";
}
}
$sql = "select count(*) from employee_appointment ep inner join patient_master e on e.id=ep.emp_id left join checkup_form c on ep.appointment_id=c.appointment_id where ((doctor_attended_flag='N' and attended_status='DRP') or (doctor_attended_flag='Y' and attended_status='MDP') or (doctor_attended_flag='Y' and attended_status='DRP')) and ep.appointment_type='O' and ep.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' $searchSql";
error_log("opd pending query count" . $sql);
$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 c.current_status, patient_name,emp_code ,ep.modified_by,e.id,ep.* from employee_appointment ep inner join patient_master e on e.id=ep.emp_id left join checkup_form c on ep.appointment_id=c.appointment_id where ((doctor_attended_flag='N' and attended_status='DRP') or (doctor_attended_flag='Y' and attended_status='MDP') or (doctor_attended_flag='Y' and attended_status='DRP')) and ep.appointment_type='O' and ep.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ";
// echo $sql_employee_appointment;
$sql_export = $sql_employee_appointment;
$sql_employee_appointment .= " $searchSql $sortSql $limitSql ";
error_log("opd pending query " . $sql_employee_appointment);
$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'];
$emp_id = $row_employee_appointment['id'];
$complaints = getCommaSeperatedValuesForInClause("select complaint from complaints ", "complaint_id", $row_employee_appointment['complaints']);
// echo $ailment_id;
$view_link = "";
$print_link = "";
$edit_link = "";
$links = "";
// $delete_link="<a href=\"#\" class=\"blue\" onclick=\"delete_employee_appointment_history('".$appointment_id."');\"><i class=\"ace-icon fa fa-trash-o bigger-130\"></i></a>";
$space = "&nbsp;&nbsp;&nbsp;";
$isEmergency = "";
$isInjury = "";
$checkup_id = getTableFieldValue('checkup_form', 'checkup_id', 'appointment_id', $appointment_id);
$view_link = $space . "<a id='appointment_id_" . $appointment_id . "' href=\"#\"class=\"grey\" onclick=\"open_employee_appointment('" . $appointment_id . "','" . $appointment_type . "','" . $emp_id . "','V','');\"><i class=\"ace-icon fa fa-eye\" style=\"font-size: 15px;\"></i></a>";
$edit_link = $space . "<a href=\"#\" class=\"blue\" onclick=\"open_employee_appointment('" . $appointment_id . "','" . $appointment_type . "','" . $emp_id . "','E','');\"><i class=\"ace-icon fa fa-edit\" style=\"font-size: 15px;\"></i></a>";
$followup_links = "";
$query_followup = "select * from followup_details where appointment_id='" . $row_employee_appointment['appointment_id'] . "' and ((doctor_attended_flag='N' and attended_status='DRP') or (doctor_attended_flag='Y' and attended_status='MDP') or (doctor_attended_flag='Y' and attended_status='DRP')) and appointment_type='O' and ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ";
error_log("Patient_Search_followup:" . $query_followup);
if (!$result_followup = @mysqli_query($conn, $query_followup)) {
exit(mysqli_error($conn));
}
if (mysqli_num_rows($result_followup) > 0) {
while ($row_followup = mysqli_fetch_assoc($result_followup)) {
if (isAccessible($_SESSION['RoleId'], $menu_key, 'W')) {
$followup_links .= "<a href=\"#\" class=\"green\" onclick=\"open_employee_appointment('" . $appointment_id . "','" . $appointment_type . "','" . $emp_id . "','F','" . $row_followup['followup_id'] . "');\">" . $row_followup["ticket_no"] . "</a>";
}
}
}
if ($row_employee_appointment['current_status'] == 'MRA' && $row_employee_appointment['attended_status'] == 'DRP') {
$print_link = $space . "<a href=\"lab_report_pdf.php?checkup_id=" . $checkup_id . "\"class=\"green\" target=\"_blank\" ><i class=\"ace-icon fa fa-file-pdf-o bigger-130\"></i></a>";
}
// if ($appointment_type == 'I') {
// $isInjury = "<span class='red'>Yes</i></span>";
// $edit_link = "<a href=\"edit_injury.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=edit\" class=\"blue\" ><i class=\"menu-icon fa fa-pencil-square-o\"></i></a>";
// $view_link = "<a href=\"view_injury.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=view\" class=\"green\" ><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
// } else {
// $isInjury = "<span class='green'>No</i></span>";
// $edit_link = "<a href=\"edit_opd.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=edit\" class=\"blue\" ><i class=\"menu-icon fa fa-pencil-square-o\"></i></a>";
// $view_link = "<a href=\"view_opd.php?appointmentId=" . $appointment_id . "&flex_opd_id=" . $emp_id . "&returnPage=pending_patient_list.php?view=view\" class=\"green\" ><i class=\"ace-icon fa fa-search-plus bigger-130\"></i></a>";
// }
if ($row_employee_appointment['IsEmergency'] == 1) {
$isEmergency = "<span class=' lighter red'>Yes</i></span>";
} else {
$isEmergency = "<span class='green'>No</i></span>";
}
if (!isAccessible($_SESSION['RoleId'], $menu_key, 'R')) {
$view_link = "";
}
if (!isAccessible($_SESSION['RoleId'], $menu_key, 'W')) {
$edit_link = "";
}
$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'] . ",WEIGHT:" . $row_employee_appointment['weight'] . ",HEIGHT:" . $row_employee_appointment['height'] . ",BMI:" . $row_employee_appointment['bmi'] . ",RESPIARATORY RATE:" . $row_employee_appointment['respiratory_rate'] . ",HEART RATE:" . $row_employee_appointment['heart_rate'] . ",URINE OUTPUT:" . $row_employee_appointment['urine_output'] . ",OXYGEN SUPPLY:" . $row_employee_appointment['oxygen_supply'] . ",AVPU" . $row_employee_appointment['avpu'] . ", MOBILITY:" . $row_employee_appointment['mobility'] . ",TRAMA:" . $row_employee_appointment['trama'] . ", GLASGOW COMA SCALE:" . $row_employee_appointment['glasgow_coma_scale'];
$links = $edit_link . $space . $print_link;
// echo $row_employee_appointment['bp_sbp'];
$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 A"),
$row_employee_appointment['ticket_no'],
$followup_links,
$row_employee_appointment['emp_code'],
$row_employee_appointment['patient_name'],
$complaints,
$isEmergency,
$isInjury,
$check_results,
$row_employee_appointment['remarks_rece'],
getFieldFromTable('user_name', 'tbl_users', 'user_id', $row_employee_appointment['modified_by'])
)
);
}
$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);
?>