Exemple #1
0
        $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;
            }
        }
        echo LangUtil::$generalTerms['TEST_TYPE'] . ": " . $testName . "<br>";
Exemple #2
0
                        }
                        ?>
						</table>
						<?php 
                    }
                    ?>
				<br><br>
				<?php 
                } else {
                    $bullet = 1;
                    foreach ($data_list as $key => $value) {
                        echo $bullet++;
                        ?>
). <b>Test Name:</b>
					<?php 
                        echo get_test_name_by_id($key);
                        ?>
					<br><b>
					Clinical Data:
					</b>
					<?php 
                        if (stripos($value, "!#!") === 0) {
                            $data = substr($value, 3);
                            $dat = explode("%%%", $value);
                            $text = substr($dat[0], 3);
                            $table = $dat[1];
                        } else {
                            if (stripos($value, "%%%") === 0) {
                                $table = substr($value, 3);
                                $text = "";
                            } else {
$date_from = $_REQUEST['date_from'];
$date_from_array = explode("-", $date_from);
$date_to_array = explode("-", $date_to);
$test_type = TestType::getById($test_type_id);
$lab_config = LabConfig::getById($_SESSION['lab_config_id']);
$worksheet_config = $lab_config->getWorkSheetConfig($test_type_id);
# Fetch all measures for this test type
$measure_list = $test_type->getMeasures();
# Create a table with specimen ID field and these measures
# Fetch currently pending tests for this test type
$pending_tests = get_pending_tests_by_type_date($test_type_id, $date_from, $date_to);
if (count($pending_tests) == 0 || $pending_tests == null) {
    ?>
	<div class='sidetip_nopos'>
		<?php 
    echo get_test_name_by_id($test_type_id) . " " . LangUtil::$pageTerms['MSG_PENDINGNOTFOUND'];
    ?>
.
	</div>
	<?php 
    return;
}
?>
<small><?php 
echo count($pending_tests) . " " . LangUtil::$generalTerms['SPECIMENS'];
?>
</small><br>
<form id='batch_form' name='batch_form' action='results_batch_add.php' method='post'>
<?php 
# Hidden field for tracking test type
?>
Exemple #4
0
    if ($count_all != 0) {
        $infection_rate = round(($count_all - $count_negative) / $count_all * 100, 2);
    }
    echo "d.push([{$x_val}*1000, {$infection_rate}]);";
    $count++;
    //$x_val += 2;
}
?>
	});
 </script>
		<?php 
if ($count != 0) {
    ?>
	<center>
<?php 
    echo get_test_name_by_id($test_type_id);
    ?>
 - <?php 
    echo LangUtil::$pageTerms['PROGRESSION_M'];
    ?>
</center>
<table>
	<tbody>
	<tr valign='top'>
		<td>
			<span id="<?php 
    echo $ylabel_id;
    ?>
" class='flipv_up' style="width:30px;height:30px;"><?php 
    echo LangUtil::$generalTerms['MENU_INFECTIONSUMMARY'];
    ?>
Exemple #5
0
 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;
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #6
0
?>
. <br><br>
<?php 
if ($_SESSION['sid'] != 0) {
    echo LangUtil::$generalTerms['SPECIMEN_ID'] . ": ";
    $specimen->getAuxId();
    echo "<br>";
}
//if($_SESSION['pnamehide'] == 0)
if ($_SESSION['user_level'] == $LIS_TECH_SHOWPNAME) {
    echo LangUtil::$generalTerms['PATIENT'] . ": {$patient->name} ({$patient->sex} " . $patient->getAgeNumber() . ") <br>";
} else {
    echo LangUtil::$generalTerms['GENDER'] . "/" . LangUtil::$generalTerms['AGE'] . ": {$patient->sex} /" . $patient->getAgeNumber() . "<br>";
}
foreach ($test_list as $test) {
    $test_name = get_test_name_by_id($test->testTypeId);
    echo "<b>{$test_name}</b>&nbsp;";
    if ($test->isPending() === true) {
        echo LangUtil::$generalTerms['PENDING_RESULTS'];
    } else {
        echo $test->decodeResult();
    }
    echo "<br>";
}
?>
<br>
<a href='specimen_info.php?sid=<?php 
echo $specimen_id;
?>
'><?php 
echo LangUtil::$generalTerms['DETAILS'];
Exemple #7
0
	public function getGetGoalTatTable($lab_config_id)
	{
		# Returns HTML table showing existing goal TAT values
		$lab_config = get_lab_config_by_id($lab_config_id);
		$tat_list = $lab_config->getGoalTatValues();
		?>
		<table class='tablesorter' style='width:600px;'>
			<thead>
				<tr valign='top'>
					<th><?php echo LangUtil::$generalTerms['TEST_TYPE']; ?></th>
					<th><?php echo LangUtil::$generalTerms['TAT']; ?></th>
				</tr>
			</thead>
			<tbody>
			<?php
			foreach($tat_list as $key=>$value)
			{
				?>
				<tr valign='top'>
					<td>
						<?php 
						if($key != 0)
						{
							echo get_test_name_by_id($key, $lab_config_id); 
						}
						else
						{
							echo LangUtil::$pageTerms['MSG_PENDINGTAT'];
						}
						?>
					</td>
					<td>
						<?php
						echo "$value ".LangUtil::$generalTerms['HOURS'];
						/*
						if($value < 24)
							echo "$value hours";
						else
						{
							$value_days = round($value/24, 2);
							echo "$value_days days";
						}
						*/
						?>
					</td>
				</tr>
				<?php
			}
			?>
			</tbody>
		</table>
		<?php
	}
Exemple #8
0
 public function getAssociatedTests()
 {
     if ($this->patientId == "") {
         return " - ";
     } else {
         $query_string = "SELECT t.test_type_id FROM test t, specimen sp " . "WHERE t.result <> '' " . "AND t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$this->patientId}";
         $recordset = query_associative_all($query_string, $row_count);
         foreach ($recordset as $record) {
             $testName = get_test_name_by_id($record['test_type_id']);
             $result .= $testName . "<br>";
         }
         return $result;
     }
 }
<b><?php 
echo LangUtil::$generalTerms['REGD_BY'];
?>
</b>: <?php 
echo get_username_by_id($specimen->userId);
?>
<br>
<b><?php 
echo LangUtil::$generalTerms['TESTS'];
?>
</b>:
<br>
<?php 
$test_list = get_tests_by_specimen_id($specimen_id);
foreach ($test_list as $test) {
    echo get_test_name_by_id($test->testTypeId) . " :- <br>";
    if ($test->isPending()) {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;" . LangUtil::$generalTerms['PENDING_RESULTS'];
    } else {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;" . LangUtil::$generalTerms['ENTERED_BY'] . ": " . get_username_by_id($test->userId) . " on: " . $test->timestamp;
    }
    echo "<br>";
    if ($test->isVerified()) {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;" . LangUtil::$generalTerms['VERIFIED_BY'] . ": " . get_username_by_id($test->verifiedBy) . " on: " . $test->getDateVerified();
    } else {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;" . LangUtil::$generalTerms['PENDING_VER'];
    }
    echo "<br>";
    if ($specimen->isReported()) {
        echo "&nbsp;&nbsp;&nbsp;&nbsp;" . LangUtil::$generalTerms['REPORTED'] . ": " . $specimen->getDateReported();
        echo "<br>";
	<tbody>
	<?php 
    $all_entries = $ust->getResultEntryLog($user_id, $lab_config_id, $date_from, $date_to);
    foreach ($all_entries as $entry) {
        ?>
            <tr>
                    <td>
                        <?php 
        $count++;
        echo $count;
        ?>
                    </td>
                    
                    <td>
                        <?php 
        $tname = get_test_name_by_id($entry->testTypeId);
        if ($tname != '') {
            echo $tname;
        } else {
            echo '-';
        }
        ?>
                    </td>
                    <td>
                        <?php 
        if ($entry->testId != '') {
            echo $entry->testId;
        } else {
            echo '-';
        }
        ?>
         echo "<td>";
         $custom_data = get_custom_data_specimen_bytype($specimen->specimenId, $custom_field->id);
         if ($custom_data == null) {
             echo "-";
         } else {
             $field_value = $custom_data->getFieldValueString($lab_config->id, 1);
             if ($field_value == "" or $field_value == null) {
                 $field_value = "-";
             }
             echo $field_value;
         }
         echo "</td>";
     }
 }
 if ($report_config->useTestName == 1) {
     echo "<td>" . get_test_name_by_id($test->testTypeId) . "</td>";
 }
 if ($report_config->useComments == 1) {
     echo "<td>";
     echo $specimen->getComments();
     echo "</td>";
 }
 if ($report_config->useReferredTo == 1) {
     echo "<td>" . $specimen->getReferredToName() . "</td>";
 }
 if ($report_config->useReferredToHospital == 1) {
     echo "<td>" . $specimen->getReferredFromName() . "</td>";
 }
 if ($report_config->useDoctor == 1) {
     echo "<td>" . $specimen->getDoctor() . "</td>";
 }
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);
    	}
    }
    */
}
Exemple #13
0
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);
    }
}