} else { if ($type == 'd') { $query_string = "SELECT s.date_collected AS week ,COUNT(*) AS count_val FROM test t, patient p,specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND p.patient_id=s.patient_id " . "AND p.sex= '{$gender}' " . "AND t.result!=''" . "AND (s.date_collected BETWEEN '{$date_from}' AND '{$date_to}') " . "GROUP BY s.date_collected"; $resultset = query_associative_all($query_string, $row_count); $query_string1 = "SELECT s.date_collected AS week ,COUNT(*) AS count_val FROM test t, patient p,specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND p.patient_id=s.patient_id " . "AND p.sex= '{$gender}' " . "AND (t.result LIKE 'N,%' OR t.result LIKE 'n�gatif,%' OR t.result LIKE 'negatif,%' OR t.result LIKE 'n,%' OR t.result LIKE 'negative,%')" . "AND (s.date_collected BETWEEN '{$date_from}' AND '{$date_to}') " . "GROUP BY s.date_collected"; $resultset1 = query_associative_all($query_string1, $row_count1); } else { $query_string = "SELECT year(s.date_collected), s.date_collected AS week ,COUNT(*) AS count_val FROM test t, patient p,specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND t.result!=''" . "AND p.patient_id=s.patient_id " . "AND p.sex= '{$gender}' " . "AND (s.date_collected BETWEEN '{$date_from}' AND '{$date_to}') " . "GROUP BY year(s.date_collected), month(s.date_collected)"; $resultset = query_associative_all($query_string, $row_count); $query_string1 = "SELECT year(s.date_collected), s.date_collected AS week ,COUNT(*) AS count_val FROM test t, patient p,specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND p.patient_id=s.patient_id " . "AND p.sex= '{$gender}' " . "AND (t.result LIKE 'N,%' OR t.result LIKE 'n�gatif,%' OR t.result LIKE 'negatif,%' OR t.result LIKE 'n,%' OR t.result LIKE 'negative,%')" . "AND (s.date_collected BETWEEN '{$date_from}' AND '{$date_to}') " . "GROUP BY year(s.date_collected),month(s.date_collected)"; $resultset1 = query_associative_all($query_string1, $row_count1); } } $record_total = array(); $record_neg = array(); foreach ($resultset1 as $record) { $week = $record['week']; $record_neg[$week] = $record['count_val']; } foreach ($resultset as $record) { $week = $record['week']; $count++; $record_total[$week] = $record['count_val']; } $counter = 0; foreach ($record_total as $key => $value) { if ($record_neg[$key] == "") { $count_negative = 0; } else { $count_negative = $record_neg[$key]; } $count_all = $value; $date_from_parts = explode("-", $key); $date_ts = mktime(0, 0, 0, $date_from_parts[1] + $i, $date_from_parts[2], $date_from_parts[0]); $retval[$counter] = array($count_all, $count_negative, $date_ts); $counter++; } DbUtil::switchRestore($saved_db); return $retval; } public static function getDiscreteInfectionStatsDaily($lab_config, $test_type_id, $date_from, $date_to, $gender = null) { $i = 1; # Fetch all test types with one measure having discrete P/N range $retval = array(); $saved_db = DbUtil::switchToLabConfig($lab_config->id); $date_from_parts = explode("-", $date_from); $date_to_parts = explode("-", $date_to); $date_ts = mktime(0, 0, 0, $date_from_parts[1], $date_from_parts[2], $date_from_parts[0]); $date_to_ts = mktime(0, 0, 0, $date_to_parts[1], $date_to_parts[2], $date_to_parts[0]); while ($date_ts < $date_to_ts) { $second_day_ts = mktime(0, 0, 0, $date_from_parts[1], $date_from_parts[2] + $i, $date_from_parts[0]); $date_fromp = date("Y-m-d", $date_ts);
public function getTestTypeInfo($test_name, $show_db_name = false) { # Returns HTML for displaying test type information $test_type = get_test_type_by_name($test_name); ?> <table class='hor-minimalist-b'> <tbody> <tr> <td><?php echo LangUtil::$generalTerms['NAME']; ?> </td> <td> <?php if ($show_db_name === true) { echo $test_type->name; } else { echo $test_type->getName(); } ?> </td> </tr> <tr> <td><?php echo LangUtil::$generalTerms['LAB_SECTION']; ?> </td> <td><?php echo get_test_category_name_by_id($test_type->testCategoryId); ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['DESCRIPTION']; ?> </td> <td><?php echo $test_type->getDescription(); ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['MEASURES']; ?> </td> <td> <?php # Fetch all test measures $measure_id_list = get_test_type_measures($test_type->testTypeId); foreach ($measure_id_list as $measure_id) { $measure = get_measure_by_id($measure_id); if ($measure == NULL && count($meausre_id_list) == 1) { echo "No Measures Found!"; break; } else { if ($measure != NULL) { echo $measure->getName() . "<br>"; } } } ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['COMPATIBLE_SPECIMENS']; ?> </td> <td> <?php # Fetch list of compatible specimens $compatible_specimens = get_compatible_specimens($test_type->testTypeId); if (count($compatible_specimens) == 0) { echo "-"; } else { foreach ($compatible_specimens as $curr_specimen) { # Show test name $specimen_type = get_specimen_type_by_id($curr_specimen); echo $specimen_type->getName() . "<br>"; } } ?> </td> </tr> <tr valign='top'> <td>Hide Patient Name in Report</td> <td><?php if ($test_type->hidePatientName == 0) { echo "No"; } else { echo "Yes"; } ?> </td> </tr> <tr valign='top'> <td>Prevalence Threshold</td> <td><?php echo $test_type->prevalenceThreshold; ?> </td> </tr> <tr valign='top'> <td>Target TAT</td> <td><?php echo $test_type->targetTat; ?> </td> </tr> </tbody> </table> <?php }
public function getTestTypeInfo($test_name, $show_db_name=false) { # Returns HTML for displaying test type information $test_type = get_test_type_by_name($test_name); ?> <table class='hor-minimalist-b'> <tbody> <tr> <td><?php echo LangUtil::$generalTerms['NAME']; ?></td> <td> <?php if($show_db_name === true) echo $test_type->name; else echo $test_type->getName(); ?> </td> </tr> <tr> <td><?php echo LangUtil::$generalTerms['LAB_SECTION']; ?></td> <td><?php echo get_test_category_name_by_id($test_type->testCategoryId); ?></td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['DESCRIPTION']; ?></td> <td><?php echo $test_type->getDescription(); ?></td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['MEASURES']; ?></td> <td> <?php # Fetch all test measures $measure_id_list = get_test_type_measures($test_type->testTypeId); sort($measure_id_list); //print_r($measure_id_list); foreach($measure_id_list as $measure_id) { $measure = get_measure_by_id($measure_id); if($measure==NULL && count($meausre_id_list)==1 ) { echo "No Measures Found!"; break; } else if($measure!=NULL) { if(strpos($measure->getName(), "\$sub") !== false) { $decName = $measure->truncateSubmeasureTag(); echo "    ".$decName."<br>"; } else { echo $measure->getName()."<br>"; } } } ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['COMPATIBLE_SPECIMENS']; ?></td> <td> <?php # Fetch list of compatible specimens $compatible_specimens = get_compatible_specimens($test_type->testTypeId); if(count($compatible_specimens) == 0) { echo "-"; } else { foreach($compatible_specimens as $curr_specimen) { # Show test name $specimen_type = get_specimen_type_by_id($curr_specimen); echo $specimen_type->getName()."<br>"; } } ?> </td> </tr> <tr valign='top'> <td>Hide Patient Name in Report</td> <td><?php if( $test_type->hidePatientName == 0) { echo "No"; } else { echo "Yes"; } ?> </td> </tr> <tr valign='top'> <td>Prevalence Threshold</td> <td><?php echo $test_type->prevalenceThreshold; ?></td> </tr> <tr valign='top'> <td>Target TAT</td> <td><?php echo $test_type->targetTat; ?></td> </tr> <tr valign='top' <?php is_billing_enabled($_SESSION['lab_config_id']) ? print("") : print("style='display:none;'") ?>> <td>Cost To Patient</td> <td><?php print(format_number_to_money(get_latest_cost_of_test_type($test_type->testTypeId))); ?></td> </tr> </tbody> </table> <?php }
function add_results_sequential($user_list = array()) { # Adds random result entries for scheduled specimen global $NUM_SPECIMENS, $F_PENDING, $SPECIMEN_ID_START; $lab_config_id = $_SESSION['lab_config_id']; $saved_db = DbUtil::switchToLabConfig($lab_config_id); $num_specimens2 = query_num_rows("specimen"); $specimens_to_handle = floor($num_specimens2 * (1 - $F_PENDING)); $specimen_target_list = array(); $query_string = "SELECT * FROM specimen ORDER BY date_collected LIMIT " . $specimens_to_handle; $resultset = query_associative_all($query_string, $row_count); foreach ($resultset as $record) { $specimen_entry = Specimen::getObject($record); $specimen_target_list[] = $specimen_entry; } DbUtil::switchRestore($saved_db); $count = 0; $specimen_id_count = $SPECIMEN_ID_START; foreach ($specimen_target_list as $specimen) { if ($specimen == null) { # TODO: } $result_entry_ts = get_random_ts($specimen->dateCollected); if ($specimen == null) { # Specimen does not exist //echo "Specimen does not exist<br>"; //$count++; $specimen_id_count++; continue; } $saved_db = DbUtil::switchToLabConfig($_SESSION['lab_config_id']); $specimen_id = $specimen->specimenId; $status_code = get_specimen_status($specimen_id); DbUtil::switchRestore($saved_db); if ($status_code == Specimen::$STATUS_DONE) { # Results already entered //echo "Results already entered<br>"; $count++; $specimen_id_count++; continue; } $patientId = $specimen->patientId; $currentPatient = Patient::getById($patientId); $hashValue = $currentPatient->generateHashValue(); # Fetch tests scheduled for this specimen $test_list = get_tests_by_specimen_id($specimen_id); # For each test, fetch test measures and range from catalog foreach ($test_list as $test) { $measure_list = get_test_type_measures($test->testTypeId); $result_entry = ""; foreach ($measure_list as $measure) { $range = get_measure_range($measure); # Select random result value $result_val = get_random_range_value($range); csv_append($result_val, $result_entry); } $test_id = $test->testId; # Update result field in test entry $saved_db = DbUtil::switchToLabConfig($lab_config_id); # Select random technician as the one of entered this result $user_id = 0; if (count($user_list) != 0) { $random_user_index = rand(1, count($user_list)); $random_user = $user_list[$random_user_index - 1]; $user_id = $random_user->userId; } add_test_result($test_id, $result_entry, "", "", $user_id, $result_entry_ts, $hashValue); # Randomly this test result mark as verified or keep as unverified # null or 0 => not verified, non-zero => verified. if (with_probability(0.9)) { $is_verified = 2; $test->setVerifiedBy($is_verified); } DbUtil::switchRestore($saved_db); } $saved_db = DbUtil::switchToLabConfig($lab_config_id); # Mark specimen as 'all tests done' update_specimen_status($specimen_id); # Randomly mark this specimen as reported or keep as unreported if (with_probability(0.9)) { $date_reported = date("Y-m-d H:i:s"); $specimen->setDateReported($date_reported); } DbUtil::switchRestore($saved_db); # Update counters $count++; $specimen_id_count++; } }