$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']."' ";
$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']."' ";