include_once $root_path . 'include/care_api_classes/class_lab.php';
 $lab_obj = new Lab();
 #Load and create paginator object
 include_once $root_path . 'include/care_api_classes/class_paginator.php';
 $pagen =& new Paginator($pgx, $thisfile, $_SESSION['sess_searchkey'], $root_path);
 $GLOBAL_CONFIG = array();
 include_once $root_path . 'include/care_api_classes/class_globalconfig.php';
 $glob_obj = new GlobalConfig($GLOBAL_CONFIG);
 # Get the max nr of rows from global config
 $glob_obj->getConfig('pagin_patient_search_max_block_rows');
 if (empty($GLOBAL_CONFIG['pagin_patient_search_max_block_rows'])) {
     $pagen->setMaxCount(MAX_BLOCK_ROWS);
 } else {
     $pagen->setMaxCount($GLOBAL_CONFIG['pagin_patient_search_max_block_rows']);
 }
 $encounter =& $lab_obj->searchPatientWithPendingLabResults($keyword, $pagen->MaxCount(), $pgx, $oitem, $odir);
 //echo $lab_obj->getLastQuery()."<p>";
 # Get the resulting record count
 if ($linecount = $lab_obj->LastRecordCount()) {
     if ($mode != 'paginate') {
         $_SESSION['sess_searchkey'] = $keyword;
     }
     $pagen->setTotalBlockCount($linecount);
     # Count total available data
     if (isset($totalcount) && $totalcount) {
         $pagen->setTotalDataCount($totalcount);
     } else {
         if ($editmode) {
             @$lab_obj->searchEncounterLaboratoryInfo($keyword);
         } else {
             @$lab_obj->searchEncounterLabResults($keyword);