Example #1
0
function get_test_record($specimen_id, $test_type_id)
{
    $query_string = "SELECT * FROM test " . "WHERE specimen_id={$specimen_id} AND test_type_id={$test_type_id} ";
    $record = query_associative_one($query_string);
    $test_entry = Test::getObject($record);
    return $test_entry;
}
Example #2
0
function query_num_rows($table_name)
{
    global $con;
    $query_string = "SELECT COUNT(*) AS val FROM {$table_name}";
    $record = query_associative_one($query_string);
    //if($LOG_QUERIES == true)
    DebugLib::logQuery($query_string, db_get_current(), $_SESSION['username']);
    DebugLib::logDBUpdates($query, db_get_current());
    return $record['val'];
}
function generate_worksheet_config($lab_config_id)
{
    $lab_config = LabConfig::getById($lab_config_id);
    $test_ids = $lab_config->getTestTypeIds();
    $saved_db = DbUtil::switchToLabConfig($lab_config_id);
    foreach ($test_ids as $test_id) {
        $test_entry = TestType::getById($test_id);
        $query_string = "SELECT * FROM report_config WHERE test_type_id={$test_id} LIMIT 1";
        $record = query_associative_one($query_string);
        if ($record == null) {
            # Add new entry
            $query_string_add = "INSERT INTO report_config (" . "test_type_id, header, footer, margins, " . "p_fields, s_fields, t_fields, p_custom_fields, s_custom_fields " . ") VALUES (" . "'{$test_id}', 'Worksheet - " . $test_entry->name . "', '', '5,0,5,0', " . "'0,1,0,1,1,0,0', '0,0,1,1,0,0', '1,0,1,0,0,0,0,1', '', '' " . ")";
            query_insert_one($query_string_add);
        }
    }
    DbUtil::switchRestore($saved_db);
}
Example #4
0
function get_records_to_print($lab_config, $patient_id, $specimen_id)
{
    $retval = array();
    $query_string = "SELECT * FROM test,specimen " . "WHERE specimen.specimen_id={$specimen_id} and test.specimen_id=specimen.specimen_id and specimen.patient_id={$patient_id}";
    $resultset = query_associative_one($query_string);
    if ($resultset == null) {
        echo "hiral";
    }
    $test = Test::getObject($resultset);
    $hide_patient_name = TestType::toHidePatientName($test->testTypeId);
    if ($hide_patient_name == 1) {
        $hidePatientName = 1;
    }
    $specimen = get_specimen_by_id($test->specimenId);
    $retval[] = array($test, $specimen, $hide_patient_name);
    return $retval;
}
Example #5
0
function verify_and_update($test_type_id, $verified_entry, $hash_value)
{
    $specimen_id = $verified_entry->specimenId;
    $query_string = "SELECT * FROM test " . "WHERE specimen_id={$specimen_id} " . "AND test_type_id={$test_type_id} LIMIT 1";
    $record = query_associative_one($query_string);
    $existing_entry = Test::getObject($record);
    $test_id = $existing_entry->testId;
    $verified_result_value = $verified_entry->result . $hash_value;
    $query_verify = "";
    if ($existing_entry->result == $verified_result_value && $existing_entry->comments == $verified_entry->comments) {
        # No changes or corrections after verification
        $query_verify = "UPDATE test " . "SET verified_by={$verified_entry->verifiedBy}, " . "date_verified='{$verified_entry->dateVerified}' " . "WHERE test_id={$test_id}";
    } else {
        # Update with corrections and mark as verified
        $query_verify = "UPDATE test " . "SET result='{$verified_result_value}', " . "comments='{$verified_entry->comments}', " . "verified_by={$verified_entry->verifiedBy}, " . "date_verified='{$verified_entry->dateVerified}' " . "WHERE test_id={$test_id}";
    }
    query_blind($query_verify);
}
Example #6
0
     } 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);
<?php

include "../includes/db_lib.php";
$attrib_value = $_REQUEST['q'];
$count = 0;
$query_string = "SELECT COUNT(specimen_id) AS val FROM test WHERE result='' " . "AND test_type_id IN (SELECT test_type_id FROM test_type WHERE test_category_id={$attrib_value}) AND specimen_id NOT IN (select r_id from removal_record where status='1' AND category='specimen')";
$resultset = query_associative_one($query_string);
$count = $resultset['val'];
echo $count;
Example #8
0
 public function getDailyNum()
 {
     # Returns daily number ("patient number")
     # Fetches value from the latest specimen which was assigned to this patient
     $query_string = "SELECT s.daily_num FROM specimen s, patient p " . "WHERE s.patient_id=p.patient_id " . "AND p.patient_id={$this->patientId} " . "ORDER BY s.date_collected DESC";
     $record = query_associative_one($query_string);
     $retval = "";
     if ($record == null || trim($record['daily_num']) == "") {
         $retval = "-";
     } else {
         $retval = $record['daily_num'];
     }
     return $retval;
 }
Example #9
0
	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'];?>
					&nbsp;
					<input type='text' name='margin_top' id='margin_top' value='<?php echo $worksheet->margins[ReportConfig::$TOP]; ?>' size='2'></input>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['BOTTOM'];?>
					&nbsp;
					<input type='text' name='margin_bottom' id='margin_bottom' value='<?php echo $worksheet->margins[ReportConfig::$BOTTOM]; ?>' size='2'></input>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['LEFT'];?>
					&nbsp;
					<input type='text' name='margin_left' id='margin_left' value='<?php echo $worksheet->margins[ReportConfig::$LEFT]; ?>' size='2'></input>
					&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['RIGHT'];?>
					&nbsp;
					<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']; ?>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<?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']; ?>&raquo;</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>
		&nbsp;&nbsp;&nbsp;
		<small>
		<a href='lab_config_home.php?id=<?php echo $lab_config->id; ?>'>
			<?php echo LangUtil::$generalTerms['CMD_CANCEL']; ?>
		</a>
		</small>
		&nbsp;&nbsp;&nbsp;
		<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
	}
<?php

include "../includes/db_lib.php";
$userId = $_SESSION['user_id'];
$testCategoryName = $_REQUEST['testCategoryName'];
$labIdTestCategoryId = $_REQUEST['labIdTestCategoryId'];
$saved_db = DbUtil::switchToGlobal();
$queryString = "SELECT MAX(test_category_id) AS test_category_id FROM test_category_mapping " . "WHERE user_id={$userId}";
$record = query_associative_one($queryString);
$testCategoryId = intval($record['test_category_id']) + 1;
$queryString = "INSERT INTO TEST_CATEGORY_MAPPING (user_id, test_category_name, lab_id_test_category_id, test_category_id) " . "VALUES (" . $userId . ",'" . $testCategoryName . "','" . $labIdTestCategoryId . "'," . $testCategoryId . ")";
query_insert_one($queryString) or die(mysql_error());
DbUtil::switchRestore($saved_db);
echo "true";
Example #11
0
	</ul>
	</div>

<div id='new_help' style='display:none'>
<small>
<u>Add New</u> lets you add new registration fields as required for the lab.
</small>
</div>

<?php 
$lab_config_id = $_REQUEST['id'];
$user = get_user_by_id($_SESSION['user_id']);
if (!(is_country_dir($user) || is_super_admin($user))) {
    $saved_db = DbUtil::switchToGlobal();
    $query = "SELECT lab_config_id FROM lab_config WHERE admin_user_id = " . $_SESSION['user_id'];
    $record = query_associative_one($query);
    $labId = $record['lab_config_id'];
    if ($labId != $lab_config_id) {
        echo "You are not authorized to access the configuration";
        include "includes/footer.php";
        die;
    }
    DbUtil::switchRestore($saved_db);
}
//echo "Lab Config Id ".$lab_config_id;
$lab_config = LabConfig::getById($lab_config_id);
//echo "specimen Id ".$lab_config->sid;
if ($lab_config == null) {
    ?>
	<br><br>
	<div class='sidetip_nopos'>
Example #12
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);
    	}
    }
    */
}
Example #13
0
            $labIdTestIdsSeparated = explode(":", $labIdTestId);
            $labId = $labIdTestIdsSeparated[0];
            $testId = $labIdTestIdsSeparated[1];
            $testIds[$labId] = $testId;
        }
        foreach ($testRecords as $testRecord) {
            if ($testIds[$labConfigId] == $testRecord->testTypeId) {
                $testRecord->testTypeId = $testIds[$importLabConfigId];
            }
        }
    }
}
DbUtil::switchRestore($saved_db);
$saved_db = DbUtil::switchToLabConfig($importLabConfigId);
$querySelect = "SELECT * FROM patient " . "WHERE patient_id={$importPatientId}";
$record = query_associative_one($querySelect);
$patientName = $record['name'];
$patient = Patient::getObject($record);
$patient->createdBy = $_SESSION['user_id'];
DbUtil::switchRestore($saved_db);
add_patient($patient, true);
/*
$querySelect =
	"SELECT patient_id FROM patient ".
	"WHERE name like '$patientName' ";
$record = query_associative_one($querySelect);
$newPatientId = $record['patient_id'];
*/
/* Create New Specimen & Test Records */
$i = 0;
foreach ($specimenRecords as $specimenRecord) {
Example #14
0
 public function get_test_cost($tid)
 {
     if ($_SESSION['level'] < 2 || $_SESSION['level'] > 4) {
         $user = get_user_by_id($_SESSION['user_id']);
         $lid = $user->labConfigId;
     }
     if ($lid == null) {
         $lid = get_lab_config_id_admin($_SESSION['user_id']);
     }
     //$stocks_list = Inventory::getStocksList($lid, $r_id);
     $lab_config_id = $lid;
     $saved_db = DbUtil::switchToLabConfig($lab_config_id);
     $query_string = "SELECT * from test_type_costs WHERE test_type_id = {$tid} ORDER BY earliest_date_valid DESC LIMIT 1";
     $record = query_associative_one($query_string);
     DbUtil::switchRestore($saved_db);
     if ($record != null) {
         $ret = $record['amount'];
     } else {
         $ret = -1;
     }
     return $ret;
 }
Example #15
0
 public function getReagentUnit($lid, $id)
 {
     $lab_config_id = $lid;
     $saved_db = DbUtil::switchToLabConfig($lab_config_id);
     $query_string = "SELECT unit from inv_reagent WHERE id={$id}";
     $recordset = query_associative_one($query_string);
     DbUtil::switchRestore($saved_db);
     return $recordset['unit'];
 }