function consult_info()
 {
     if (func_num_args() > 0) {
         $arg_list = func_get_args();
         $menu_id = $arg_list[0];
         $post_vars = $arg_list[1];
         $get_vars = $arg_list[2];
         $validuser = $arg_list[3];
         $isadmin = $arg_list[4];
         //print_r($arg_list);
     }
     $arr_facility = array();
     if (mysql_num_rows(mysql_query("SHOW TABLES LIKE 'm_lib_health_facility_barangay'")) != 0) {
         $q_facility = mysql_query("SELECT DISTINCT(a.facility_id),b.facility_name FROM m_lib_health_facility_barangay a,m_lib_health_facility b WHERE a.facility_id=b.facility_id ORDER by b.facility_name ASC") or die("Cannot query 1226 " . mysql_error());
         if (mysql_num_rows($q_facility) != 0) {
             while (list($facility_id, $facility_name) = mysql_fetch_array($q_facility)) {
                 array_push($arr_facility, array($facility_id, $facility_name));
             }
         }
     }
     if (empty($arr_facility)) {
         $result = mysql_query("select c.consult_id, p.patient_id, p.patient_lastname, p.patient_firstname, see_doctor_flag, date_format(p.patient_dob, '%Y-%m-%d'), round((to_days(c.consult_date)-to_days(p.patient_dob))/365,1) from m_consult c, m_patient p where c.patient_id = p.patient_id and consult_end = '0000-00-00 00:00:00' order by c.consult_date asc") or die("Cannot query 1241 " . mysql_error());
     } else {
         if (!empty($_GET["facid"])) {
             $q_facid = mysql_query("SELECT a.barangay_id FROM m_lib_barangay a, m_lib_health_facility_barangay b WHERE b.facility_id='{$_GET['facid']}' AND a.barangay_id=b.barangay_id") or die("Cannot query 1246 " . mysql_error());
             if (mysql_num_rows($q_facid) != 0) {
                 $arr_brgy = array();
                 while (list($brgy_id) = mysql_fetch_array($q_facid)) {
                     array_push($arr_brgy, $brgy_id);
                 }
                 $str_brgy = implode(",", $arr_brgy);
                 $result = mysql_query("select c.consult_id, p.patient_id, p.patient_lastname, p.patient_firstname, see_doctor_flag, date_format(p.patient_dob, '%Y-%m-%d'), round((to_days(c.consult_date)-to_days(p.patient_dob))/365,1) from m_consult c, m_patient p, m_family_members x, m_family_address y, m_lib_barangay z where c.patient_id = p.patient_id and consult_end = '0000-00-00 00:00:00' AND p.patient_id=x.patient_id AND x.family_id=y.family_id AND y.barangay_id IN ({$str_brgy}) AND y.barangay_id=z.barangay_id order by c.consult_date asc") or die("Cannot query 1258 " . mysql_error());
             } else {
                 echo "<script language='Javascript'>";
                 echo "window.alert('Invalid health facility code!')";
                 echo "</script>";
             }
         } else {
             $result = mysql_query("select c.consult_id, p.patient_id, p.patient_lastname, p.patient_firstname, see_doctor_flag, date_format(p.patient_dob, '%Y-%m-%d'), round((to_days(c.consult_date)-to_days(p.patient_dob))/365,1) from m_consult c, m_patient p where c.patient_id = p.patient_id and consult_end = '0000-00-00 00:00:00' order by c.consult_date asc") or die("Cannot query 1271 " . mysql_error());
         }
     }
     if ($result) {
         print "<a name='consults'></a>";
         print "<span class='patient'>" . FTITLE_CONSULTS_TODAY . "</span>";
         healthcenter::show_tab_headers($arr_facility);
         print "<table width=600 bgcolor='#FFFFFF' cellpadding='3' cellspacing='0' style='border: 2px solid black'>";
         print "<tr>";
         print "<td>";
         print "<span class='tinylight'><b><span style='background-color:#FFFF00'>NAME</span> </b> - WILL SEE PHYSICIAN.</span>";
         if (mysql_num_rows($result)) {
             // initialize array index
             $i = 0;
             // have to return always to consult page
             // wherever this is shown
             $consult_menu_id = module::get_menu_id("_consult");
             $patient_count = 0;
             while (list($cid, $pid, $plast, $pfirst, $see_doctor, $patient_dobx, $age) = mysql_fetch_array($result)) {
                 $q_lab = mysql_query("SELECT request_id,request_done FROM m_consult_lab WHERE patient_id='{$pid}' AND consult_id='{$cid}'") or die("Cannot query 1224" . mysql_error());
                 if (mysql_num_rows($q_lab) != 0) {
                     $arr_done = array();
                     $arr_id = array();
                     while (list($req_id, $done_status) = mysql_fetch_array($q_lab)) {
                         array_push($arr_id, $req_id);
                         array_push($arr_done, $done_status);
                     }
                     $done = in_array("N", $arr_done) ? "N" : "Y";
                     $request_id = $arr_id[0];
                     $url = "page=CONSULTS&menu_id=1327&consult_id={$cid}&ptmenu=LABS";
                 } else {
                     $request_id = $done = "";
                 }
                 $visits = healthcenter::get_total_visits($pid);
                 $ptgroup = healthcenter::check_icons($pid, $cid, $consult_menu_id);
                 /*
                 if($age>=60){
                 	$prio_color = '#006600';
                 }else{
                 	if($_SESSION['mc_tag']>=1){
                 		$prio_color= '#CC0033';
                 	}else{
                 		$prio_color ='#000000';
                 	}
                 }
                 */
                 if ($see_doctor == "Y") {
                     $style = "style='background-color:#FFFF00'";
                 } else {
                     $style = '';
                 }
                 $patient_elapsed = healthcenter::get_elapsedtime($cid);
                 $consult_array[$i] = "<tr><td {$style}><a style='text-decoration:none' href='" . $_SERVER["PHP_SELF"] . "?page=CONSULTS&menu_id={$consult_menu_id}&consult_id={$cid}&ptmenu=DETAILS' title='" . INSTR_CLICK_TO_VIEW_RECORD . "' " . ($see_doctor == "Y" ? "style='text-color: #FFFF33'" : "") . ">" . "<b>{$plast}, {$pfirst}</b></td></a><td style='text-align:center'>[{$visits}]</td><td style='text-align:center'>" . $patient_dobx . "</td><td align='center'>" . ($request_id != "" ? $done == "Y" ? "<a href='{$_SERVER['PHP_SELF']}?{$url}' title='lab completed' ><img src='../images/lab.png' width='15px' height='15px' border='0' alt='lab completed' /></a>{$ptgroup}" : "<a href='{$_SERVER['PHP_SELF']}?{$url}' title='lab pending'><img src='../images/lab_untested.png' width='15px' height='15px' border='0' alt='lab pending' /></a>" . ($age >= 60 ? "<img src='../images/senior.jpg' width='20' height='20' />" : '') . "{$ptgroup}" : "" . ($age >= 60 ? "<img src='../images/senior.jpg' width='20' height='20' />" : '') . " {$ptgroup}") . "</td><td>{$patient_elapsed}</td>";
                 $i++;
                 $patient_count += 1;
             }
             // pass on patient list to be columnized
             print healthcenter::display_todays_consult($consult_array);
         } else {
             print "<font color='red'>No consults available.</font>";
         }
         print "<tr>";
         print "<td>";
         print "Number of patients waiting: <b>" . $patient_count . "</b>";
         print "</td>";
         print "</tr>";
         /*
         $sql_time = "select round(avg(unix_timestamp(consult_end)-unix_timestamp(consult_date))/60,2) consult_minutes from m_consult where consult_end>0 and to_days(consult_date) = to_days(sysdate());";
         if ($result_time = mysql_query($sql_time)) {
         	if (mysql_num_rows($result_time)) {
         		list($mean_consult_time) = mysql_fetch_array($result_time);
         	}
         	if ($mean_consult_time) {
         		print "<tr><td class='tinylight'>";
         		if ($mean_consult_time>60) {
         			$unit_time = "hour(s)";
         		} elseif ($meantime>1440) {
         			$unit_time = "day(s)";
         		} else {
         			$unit_time = "minute(s)";
         		}
         		print "AVERAGE CONSULT TIME: <font color='red'>$mean_consult_time $unit_time</font>";
         		print "</td></tr>";
         	}
         }
         */
         print "</td>";
         print "</tr>";
         print "</table>";
     }
 }