public static function getDiscreteInfectionStatsAggregate($lab_config_id, $date_from, $date_to, $test_type_id) { $retval = array(); #All Tests & All Labs if ($test_type_id == 0 && $lab_config_id == 0) { $site_list = get_site_list($_SESSION['user_id']); $userId = $_SESSION['user_id']; $saved_db = DbUtil::switchToGlobal(); $query = "SELECT * FROM test_mapping WHERE user_id = {$userId}"; $resultset = query_associative_all($query, $row_count); foreach ($resultset as $record) { $labIdTestIds = explode(';', $record['lab_id_test_id']); foreach ($labIdTestIds as $labIdTestId) { $labIdTestId = explode(':', $labIdTestId); $labId = $labIdTestId[0]; $testId = $labIdTestId[1]; $test_type_list_all[$labId][] = $testId; $test_type_names[$labId][] = $record['test_name']; } } DbUtil::switchRestore($saved_db); foreach ($site_list as $key => $value) { $lab_config = LabConfig::getById($key); $test_type_list = array(); $test_type_list = $test_type_list_all[$key]; $testNames = $test_type_names[$key]; $saved_db = DbUtil::switchToLabConfig($lab_config->id); $testCount = -1; # For each test type, fetch negative records foreach ($test_type_list as $test_type_id) { $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND (result LIKE 'N,%' OR result LIKE 'n�gatif,%' OR result LIKE 'negatif,%' OR result LIKE 'n,%' OR result LIKE 'negative,%')"; $record = query_associative_one($query_string); $count_negative = intval($record['count_val']); $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )"; $record = query_associative_one($query_string); $count_all = intval($record['count_val']); $testCount++; # If total tests is 0, ignore if ($count_all == 0) { continue; } $testName = $testNames[$testCount]; if (!array_key_exists($testName, $retval)) { $retval[$testName] = array($count_all, $count_negative); } else { $count_all += intval($retval[$testName][0]); $count_negative += intval($retval[$testName][1]); $retval[$testName] = array($count_all, $count_negative); } } } DbUtil::switchRestore($saved_db); return $retval; } else { if ($test_type_id == 0 && count($lab_config_id) == 1) { $lab_config = LabConfig::getById($lab_config_id[0]); $retvalues = StatsLib::getDiscreteInfectionStats($lab_config, $date_from, $date_to); $saved_db = DbUtil::switchToLabConfig($lab_config->id); foreach ($retvalues as $key => $value) { $testName = get_test_name_by_id($key); $retval[$testName] = $value; } DbUtil::switchRestore($saved_db); return $retval; } else { if ($test_type_id == 0 && count($lab_config_id) > 1) { $userId = $_SESSION['user_id']; $saved_db = DbUtil::switchToGlobal(); $query = "SELECT * FROM test_mapping WHERE user_id = {$userId}"; $resultset = query_associative_all($query, $row_count); foreach ($resultset as $record) { $labIdTestIds = explode(';', $record['lab_id_test_id']); foreach ($labIdTestIds as $labIdTestId) { $labIdTestId = explode(':', $labIdTestId); $labId = $labIdTestId[0]; $testId = $labIdTestId[1]; $test_type_list_all[$labId][] = $testId; $test_type_names[$labId][] = $record['test_name']; } } DbUtil::switchRestore($saved_db); foreach ($lab_config_id as $key) { $lab_config = LabConfig::getById($key); $test_type_list = array(); $test_type_list = $test_type_list_all[$key]; $testNames = $test_type_names[$key]; $saved_db = DbUtil::switchToLabConfig($lab_config->id); $testCount = -1; # For each test type, fetch negative records foreach ($test_type_list as $test_type_id) { $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND (result LIKE 'N,%' OR result LIKE 'n�gatif,%' OR result LIKE 'negatif,%' OR result LIKE 'n,%' OR result LIKE 'negative,%')"; $record = query_associative_one($query_string); $count_negative = intval($record['count_val']); $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )"; //echo($query_string); $record = query_associative_one($query_string); $count_all = intval($record['count_val']); $testCount++; # If total tests is 0, ignore if ($count_all == 0) { continue; } $testName = $testNames[$testCount]; if (!array_key_exists($testName, $retval)) { $retval[$testName] = array($count_all, $count_negative); } else { $count_all += intval($retval[$testName][0]); $count_negative += intval($retval[$testName][1]); $retval[$testName] = array($count_all, $count_negative); } } } DbUtil::switchRestore($saved_db); return $retval; } else { /* Build Array Map with Lab Id as Key and Test Id as corresponding Value */ $labIdTestIds = explode(";", $test_type_id); $testIds = array(); foreach ($labIdTestIds as $labIdTestId) { $labIdTestIdsSeparated = explode(":", $labIdTestId); $labId = $labIdTestIdsSeparated[0]; $testId = $labIdTestIdsSeparated[1]; $testIds[$labId] = $testId; } # Particular Test & All Labs if ($test_type_id != 0 && $lab_config_id == 0) { $site_list = get_site_list($_SESSION['user_id']); foreach ($site_list as $key => $value) { $lab_config = LabConfig::getById($key); $saved_db = DbUtil::switchToLabConfig($lab_config->id); $test_type_id = $testIds[$lab_config->id]; # For particular test type, fetch negative records $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND (result LIKE 'N,%' OR result LIKE 'n�gatif,%' OR result LIKE 'negatif,%' OR result LIKE 'n,%' OR result LIKE 'negative,%')"; $record = query_associative_one($query_string); $count_negative = intval($record['count_val']); $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )"; $record = query_associative_one($query_string); $count_all = intval($record['count_val']); # If total tests is 0, ignore if ($count_all == 0) { continue; } $testName = get_test_name_by_id($test_type_id); $labName = $lab_config->name; $retval[$labName] = array($count_all, $count_negative); } DbUtil::switchRestore($saved_db); return $retval; } else { if ($test_type_id != 0 && count($lab_config_id) == 1) { $lab_config = LabConfig::getById($lab_config_id[0]); $test_type_id = $testIds[$lab_config->id]; $retvalues = StatsLib::getDiscreteInfectionStats($lab_config, $date_from, $date_to, $test_type_id); $saved_db = DbUtil::switchToLabConfig($lab_config->id); foreach ($retvalues as $key => $value) { $testName = get_test_name_by_id($key); $retval[$testName] = $value; } DbUtil::switchRestore($saved_db); return $retval; } else { if ($lab_config_id != 0 && $test_type_id != 0) { foreach ($lab_config_id as $key) { $lab_config = LabConfig::getById($key); $test_type_id = $testIds[$lab_config->id]; $saved_db = DbUtil::switchToLabConfig($lab_config->id); # For particular test type, fetch negative records $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND (result LIKE 'N,%' OR result LIKE 'n�gatif,%' OR result LIKE 'negatif,%' OR result LIKE 'n,%' OR result LIKE 'negative,%')"; $record = query_associative_one($query_string); $count_negative = intval($record['count_val']); $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )"; //echo($query_string); $record = query_associative_one($query_string); $count_all = intval($record['count_val']); # If total tests is 0, ignore if ($count_all == 0) { continue; } $testName = get_test_name_by_id($test_type_id); $labName = $lab_config->name; $query_string = "SELECT prevalence_threshold FROM test_type " . "WHERE test_type_id={$test_type_id} "; $record = query_associative_one($query_string); $threshold = intval($record['prevalence_threshold']); $retval[$labName] = array($count_all, $count_negative, $threshold); } DbUtil::switchRestore($saved_db); return $retval; } } } } } } }
<?php # # Deletes a test type from DB # Sets disabled flag to true instead of deleting the record # This maintains info for samples that were linked to this test type previously # include "../includes/db_lib.php"; $saved_session = SessionUtil::save(); $saved_db = DbUtil::switchToGlobal(); $test_type_id = $_REQUEST['id']; TestType::deleteById($test_type_id); DbUtil::switchRestore($saved_db); SessionUtil::restore($saved_session); header("Location: catalog.php?tdel");
public static function getByKeys($user_id, $test_type_id, $measure_id) { # Fetches a record by compound key $saved_db = DbUtil::switchToGlobal(); $query_string = "SELECT * FROM infection_report_settings " . "WHERE user_id={$user_id} " . "AND test_id={$test_type_id} " . "AND measure_id={$measure_id} LIMIT 1"; $record = query_associative_one($query_string); $retval = GlobalInfectionReport::getObject($record); DbUtil::switchRestore($saved_db); return $retval; }
public function getEditCustomWorksheetForm($worksheet_id, $lab_config) { if($lab_config == null) { echo LangUtil::$generalTerms['MSG_NOTFOUND']; return; } $worksheet = CustomWorksheet::getById($worksheet_id, $lab_config); if($worksheet == null) { echo LangUtil::$generalTerms['MSG_NOTFOUND']; return; } ?> <input type='hidden' name='location' value='<?php echo $lab_config->id; ?>'></input> <input type='hidden' name='wid' value='<?php echo $worksheet_id; ?>'></input> <table class='hor-minimalist-b' style='width:auto;'> <tbody> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['NAME']; ?></td> <td><input type='text' name='wname' id='wname' value='<?php echo $worksheet->name; ?>' class='uniform_width_more'></input></td> </tr> <tr valign='top'> <td>Header</td> <td><input type='text' name='header' id='header' value='<?php echo $worksheet->headerText; ?>' class='uniform_width_more'></td> </tr> <tr valign='top'> <td>Title</td> <td><input type='text' name='title' id='title' value='<?php echo $worksheet->titleText; ?>' class='uniform_width_more'></td> </tr> <tr valign='top'> <td>Footer</td> <td><input type='text' name='footer' id='footer' value='<?php echo $worksheet->footerText; ?>' class='uniform_width_more'></td> </tr> <tr valign='top'> <td><?php echo LangUtil::$pageTerms['MARGINS']; ?> (%)</td> <td> <?php echo LangUtil::$pageTerms['TOP'];?> <input type='text' name='margin_top' id='margin_top' value='<?php echo $worksheet->margins[ReportConfig::$TOP]; ?>' size='2'></input> <?php echo LangUtil::$pageTerms['BOTTOM'];?> <input type='text' name='margin_bottom' id='margin_bottom' value='<?php echo $worksheet->margins[ReportConfig::$BOTTOM]; ?>' size='2'></input> <?php echo LangUtil::$pageTerms['LEFT'];?> <input type='text' name='margin_left' id='margin_left' value='<?php echo $worksheet->margins[ReportConfig::$LEFT]; ?>' size='2'></input> <?php echo LangUtil::$pageTerms['RIGHT'];?> <input type='text' name='margin_right' id='margin_right' value='<?php echo $worksheet->margins[ReportConfig::$RIGHT]; ?>' size='2'></input> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['PATIENT_ID']; ?></td> <td> <input type='radio' name='is_pid' value='Y' id='is_pid'<?php if($worksheet->idFields[CustomWorksheet::$OFFSET_PID] == 1) { echo " checked "; }?>><?php echo LangUtil::$generalTerms['YES']; ?></input> <input type='radio' name='is_pid' value='N'<?php if($worksheet->idFields[CustomWorksheet::$OFFSET_PID] == 0) { echo " checked "; }?>><?php echo LangUtil::$generalTerms['NO']; ?></input> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></td> <td> <input type='radio' name='is_dnum' value='Y' id='is_dnum'<?php if($worksheet->idFields[CustomWorksheet::$OFFSET_DNUM] == 1) { echo " checked "; }?>><?php echo LangUtil::$generalTerms['YES']; ?></input> <input type='radio' name='is_dnum' value='N'<?php if($worksheet->idFields[CustomWorksheet::$OFFSET_DNUM] == 0) { echo " checked "; }?>><?php echo LangUtil::$generalTerms['NO']; ?></input> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['ADDL_ID']; ?></td> <td> <input type='radio' name='is_addlid' value='Y' id='is_addlid'<?php if($worksheet->idFields[CustomWorksheet::$OFFSET_ADDLID] == 1) { echo " checked "; }?>><?php echo LangUtil::$generalTerms['YES']; ?></input> <input type='radio' name='is_addlid' value='N'<?php if($worksheet->idFields[CustomWorksheet::$OFFSET_ADDLID] == 0) { echo " checked "; }?>><?php echo LangUtil::$generalTerms['NO']; ?></input> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$pageTerms['CUSTOMFIELDS']; ?></td> <td> <span id='uf_list_box'> <?php echo LangUtil::$generalTerms['NAME']; ?> <?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?> <br> <?php if($worksheet->userFields == null || count($worksheet->userFields) == 0) { //echo LangUtil::$generalTerms['NO']."<br>"; } foreach($worksheet->userFields as $field_entry) { $field_id = $field_entry[0]; $field_name = $field_entry[1]; $field_width = $field_entry[2]; ?> <input type='hidden' name='existing_uf_id[]' value='<?php echo $field_id; ?>'></input> <input type='text' name='existing_uf_name[]' value='<?php echo $field_name; ?>' class='uniform_width'></input> <input type='text' name='existing_uf_width[]' size='2' value='<?php echo $field_width; ?>'></input> <br> <?php } ?> </span> <small><a href='javascript:add_another_uf();'><?php echo LangUtil::$generalTerms['ADDNEW']; ?>»</a></small> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['LAB_SECTION']; ?></td> <td> <?php $test_type_id = $worksheet->testTypes[0]; $saved_db = DbUtil::switchToGlobal(); $query_string = "SELECT test_category_id FROM test_type WHERE test_type_id=$test_type_id"; $record = query_associative_one($query_string); $cat_code = $record['test_category_id']; $cat_name = get_test_category_name_by_id($cat_code); DbUtil::switchRestore($saved_db); echo $cat_name; ?> </td> </tr> </table> <br> <div id='test_boxes' class='smaller_font' style='width:auto;'> <?php $test_type_list = get_test_types_by_site_category($lab_config->id, $cat_code); foreach($test_type_list as $test_type) { $measure_list = $test_type->getMeasures(); ?> <div> <input type='checkbox' class='test_type_checkbox' name='ttype_<?php echo $test_type->testTypeId; ?>' id='ttype_<?php echo $test_type->testTypeId; ?>' <?php if(in_array($test_type->testTypeId, $worksheet->testTypes)) echo " checked "; ?>> <?php echo $test_type->getName(); ?> </input> <br> <div id='ttype_<?php echo $test_type->testTypeId; ?>_mlist' style='position:relative; margin-left:15px;<?php if(in_array($test_type->testTypeId, $worksheet->testTypes) === false) echo "display:none;"; ?>'> <table class='hor-minimalist-b'> <thead> <tr> <th style='width:200px;'><?php echo LangUtil::$generalTerms['MEASURES']; ?></th> <th><?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?> (%)</th> </tr> <?php foreach($measure_list as $measure) { if(in_array($test_type->testTypeId, $worksheet->testTypes)) $width_val = $worksheet->columnWidths[$test_type->testTypeId][$measure->measureId]; else $width_val = ""; ?> <tr> <td> <?php echo $measure->getName(); ?> </td> <td> <input type='text' value='<?php echo $width_val; ?>' size='2' name='width_<?php echo $test_type->testTypeId."_".$measure->measureId; ?>'> </input> </td> </tr> <?php } ?> </thead> <tbody> </tbody> </table> </div> </div> <br> <?php } ?> <input type='button' value='<?php echo LangUtil::$generalTerms['CMD_SUBMIT']; ?>' id='worksheet_submit_button' onclick='javascript:submit_worksheet_form();'> </input> <small> <a href='lab_config_home.php?id=<?php echo $lab_config->id; ?>'> <?php echo LangUtil::$generalTerms['CMD_CANCEL']; ?> </a> </small> <span id='worksheet_submit_progress' style='display:none;'> <?php $this->getProgressSpinner(LangUtil::$generalTerms['CMD_SUBMITTING']); ?> </span> <script type='text/javascript'> $(document).ready(function(){ $('.test_type_checkbox').change( function() { toggle_mlist(this); }); }); function toggle_mlist(elem) { var target_div = elem.name+"_mlist"; if(elem.checked == true) { $('#'+target_div).show(); } else { $('#'+target_div).hide(); } } </script> <?php }
function runGlobalUpdate() { global $con; $saved_db = DbUtil::switchToGlobal(); /* BLIS 1.35 Update $query_insert = "CREATE TABLE test_mapping (". "user_id int(11), ". "test_name varchar(256), ". "lab_id_test_id varchar(256), ". "test_id int(10) unsigned, ". "test_category_id int(10) unsigned, ". "primary key (user_id, test_id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "CREATE TABLE specimen_mapping (". "user_id int(11), ". "specimen_name varchar(256), ". "lab_id_specimen_id varchar(256), ". "specimen_id int(10), ". "primary key (user_id, specimen_id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "CREATE TABLE test_category_mapping (". "user_id int(11), ". "test_category_name varchar(256), ". "lab_id_test_category_id varchar(256), ". "test_category_id int(10), ". "primary key (user_id, test_category_id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "CREATE TABLE measure_mapping (". "user_id int(11), ". "measure_name varchar(256), ". "lab_id_measure_id varchar(256), ". "measure_id int(10), ". "primary key (user_id, measure_id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "CREATE TABLE global_measures (". "user_id int(11), ". "name varchar(128), ". "range varchar(1024), ". "test_id int(10), ". "measure_id int(10), ". "unit varchar(64), ". "primary key (user_id, test_id, measure_id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "CREATE TABLE infection_report_settings (". "id int(10) unsigned, ". "group_by_age int(10) unsigned, ". "group_by_gender int(10) unsigned, ". "age_groups varchar(512), ". "measure_groups varchar(512), ". "measure_id int(10), ". "user_id int(11), ". "test_id int(10), ". "primary key (user_id, id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "CREATE TABLE reference_range_global (". "measure_id int(10), ". "age_min varchar(64), ". "age_max varchar(64), ". "sex varchar(64), ". "range_lower varchar(64), ". "range_upper varchar(64), ". "user_id int(11), ". "primary key (user_id, measure_id) )"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "INSERT INTO user (user_id, username, `password`, actualname, email, lang_id, `level`, created_by, lab_config_id, phone) ". "VALUES (401, 'philip', '18865bfdeed2fd380316ecde609d94d7285af83f', 'Philip Boakye', '*****@*****.**', 'en', 4, 0, 0, '')"; mysql_query( $query_insert, $con ) or die(mysql_error()); $query_insert = "INSERT INTO user (user_id, username, `password`, actualname, email, lang_id, `level`, created_by, lab_config_id, phone) ". "VALUES (402, 'mercy', '18865bfdeed2fd380316ecde609d94d7285af83f', 'Mercy Maeda', '*****@*****.**', 'en', 4, 0, 0, '')"; mysql_query( $query_insert, $con ) or die(mysql_error()); */ /* BLIS 1.91 Update */ $query_alter = "ALTER table lab_config" . "ADD column country varchar(512)"; mysql_query($query_alter, $con) or die(mysql_error()); DbUtil::switchRestore($saved_db); }
function processWeeklyTrends($lab_config_id, $test_type_id, $date_from, $date_to, $test_name = null) { global $namesArray; global $stat_list; # All Tests & All Labs */ if ($test_type_id == 0 && $lab_config_id == 0) { $site_list = get_site_list($_SESSION['user_id']); $userId = $_SESSION['user_id']; $saved_db = DbUtil::switchToGlobal(); $query = "SELECT * FROM test_mapping WHERE user_id = {$userId}"; $resultset = query_associative_all($query, $row_count); foreach ($resultset as $record) { $labIdTestIds = explode(';', $record['lab_id_test_id']); foreach ($labIdTestIds as $labIdTestId) { $labIdTestId = explode(':', $labIdTestId); $labId = $labIdTestId[0]; $testId = $labIdTestId[1]; $test_type_list_all[$labId][] = $testId; $test_type_names[$labId][] = $record['test_name']; } } DbUtil::switchRestore($saved_db); foreach ($site_list as $key => $value) { $lab_config = LabConfig::getById($key); $test_type_list = array(); $test_type_list = $test_type_list_all[$key]; $testNames = $test_type_names[$key]; $saved_db = DbUtil::switchToLabConfig($lab_config->id); $testCount = -1; foreach ($test_type_list as $test_type_id) { $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )"; $record = query_associative_one($query_string); $count_all = intval($record['count_val']); $testCount++; if ($count_all == 0) { continue; } $namesArray[] = $lab_config->name . " - " . $testNames[$testCount]; getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } } } else { if ($test_type_id == 0 && count($lab_config_id) == 1) { $lab_config = LabConfig::getById($lab_config_id[0]); $test_type_list = get_discrete_value_test_types($lab_config); foreach ($test_type_list as $test_type_id) { $namesArray[] = get_test_name_by_id($test_type_id, $lab_config_id[0]); getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } } else { if ($test_type_id == 0 && count($lab_config_id) > 1) { $userId = $_SESSION['user_id']; $saved_db = DbUtil::switchToGlobal(); $query = "SELECT * FROM test_mapping WHERE user_id = {$userId}"; $resultset = query_associative_all($query, $row_count); foreach ($resultset as $record) { $labIdTestIds = explode(';', $record['lab_id_test_id']); foreach ($labIdTestIds as $labIdTestId) { $labIdTestId = explode(':', $labIdTestId); $labId = $labIdTestId[0]; $testId = $labIdTestId[1]; $test_type_list_all[$labId][] = $testId; $test_type_names[$labId][] = $record['test_name']; } } DbUtil::switchRestore($saved_db); foreach ($lab_config_id as $key) { $lab_config = LabConfig::getById($key); $test_type_list = array(); $test_type_list = $test_type_list_all[$key]; $testNames = $test_type_names[$key]; $saved_db = DbUtil::switchToLabConfig($lab_config->id); $testCount = -1; foreach ($test_type_list as $test_type_id) { $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )"; $record = query_associative_one($query_string); $count_all = intval($record['count_val']); $testCount++; if ($count_all == 0) { continue; } $namesArray[] = $lab_config->name . " - " . $testNames[$testCount]; getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } } } else { /* Build Array Map with Lab Id as Key and Test Id as corresponding Value */ $labIdTestIds = explode(";", $test_type_id); $testIds = array(); foreach ($labIdTestIds as $labIdTestId) { $labIdTestIdsSeparated = explode(":", $labIdTestId); $labId = $labIdTestIdsSeparated[0]; $testId = $labIdTestIdsSeparated[1]; $testIds[$labId] = $testId; } # Particular Test & All Labs if ($test_type_id != 0 && $lab_config_id == 0) { $site_list = get_site_list($_SESSION['user_id']); foreach ($site_list as $key => $value) { $lab_config = LabConfig::getById($key); $test_type_id = $testIds[$lab_config->id]; $namesArray[] = $lab_config->name; getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } } else { if ($test_type_id != 0 && count($lab_config_id) == 1) { $lab_config = LabConfig::getById($lab_config_id[0]); $test_type_id = $testIds[$lab_config->id]; $namesArray[] = $lab_config->name; getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } else { if ($lab_config_id != 0 && $test_type_id != 0) { foreach ($lab_config_id as $key) { $lab_config = LabConfig::getById($key); $test_type_id = $testIds[$lab_config->id]; $namesArray[] = $lab_config->name; getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } } } } } } } /* $lab_config = LabConfig::getById($lab_config_id[0]); if($lab_config) { //$test_type_list = get_discrete_value_test_types($lab_config); foreach($test_type_list as $test_type_id) { $namesArray[] = get_test_name_by_id($test_type_id, $lab_config_id[0]); getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to); } } */ }
public function login($username, $password) { print_r($_SESSION); global $con; $username = mysql_real_escape_string($username, $con); $saved_db = DbUtil::switchToGlobal(); $password = encrypt_password($password); $query_string = "SELECT * FROM user " . "WHERE username='******' " . "AND password='******' AND lab_config_id != 0 LIMIT 1"; $record = query_associative_one($query_string); # Return user profile (null if incorrect username/password) DbUtil::switchRestore($saved_db); //return User::getObject($record); if ($record == NULL) { return -1; } else { $tok = API::start_session($username, $password); return $tok; } }