コード例 #1
0
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);
    	}
    }
    */
}
コード例 #2
0
ファイル: process_aggregation.php プロジェクト: caseyi/BLIS
        publishDates($date_from, $date_to);
        $stat_list = array();
        $retval = array();
        $existing_stat_list = array();
        $testName = null;
        for ($i = 0; $i < count($lab_config_id_array); $i++) {
            $labIdTestTypeIdSeparated = explode(":", $lab_config_id_array[$i]);
            $lab_config_id = $labIdTestTypeIdSeparated[0];
            $test_type_id = $labIdTestTypeIdSeparated[1];
            $retval = StatsLib::getDiscreteInfectionStatsAggregate($lab_config_id, $date_from, $date_to, $test_type_id);
            $existing_stat_list = $stat_list;
            $stat_list = array_merge($existing_stat_list, $retval);
            $lab_config = LabConfig::getById($lab_config_id);
            $labName = $lab_config->name;
            $labNamesArray[] = $labName;
            getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to);
            if (!$testName) {
                $saved_db = DbUtil::switchToLabConfig($lab_config_id);
                $testName = get_test_name_by_id($test_type_id);
                DbUtil::switchRestore($saved_db);
            }
            if (count($stat_list) == 0) {
                ?>
				<div class='sidetip_nopos'>
				<?php 
                echo LangUtil::$pageTerms['TIPS_NODISCRETE'];
                ?>
				</div>
				<?php 
                include "includes/footer.php";
                return;
コード例 #3
0
ファイル: reports_infection.php プロジェクト: caseyi/BLIS
function processWeeklyTrends($lab_config_id, $test_type_id, $date_from, $date_to, $test_name = null)
{
    global $namesArray;
    global $stat_list;
    $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);
    }
}