Ejemplo n.º 1
0
function get_records_to_print($lab_config, $test_type_id, $date_from, $date_to)
{
    $saved_db = DbUtil::switchToLabConfig($lab_config->id);
    $retval = array();
    $query_string = "SELECT * FROM test WHERE test_type_id={$test_type_id} " . "AND specimen_id IN ( " . "SELECT specimen_id FROM specimen " . "WHERE date_collected BETWEEN '{$date_from}' AND '{$date_to}' " . ")";
    $resultset = query_associative_all($query_string, $row_count);
    foreach ($resultset as $record) {
        $test = Test::getObject($record);
        $specimen = Specimen::getById($test->specimenId);
        $patient = Patient::getById($specimen->patientId);
        $retval[] = array($test, $specimen, $patient);
    }
    DbUtil::switchRestore($saved_db);
    return $retval;
}
Ejemplo n.º 2
0
            }
            if ($report_config->useVerifiedBy == 1) {
                echo "<td><br><br></td>";
            }
            if ($report_config->useStatus == 1) {
                echo "<td><br><br></td>";
            }
            ?>
		</tr>
		<?php 
        }
    } else {
        foreach ($test_list as $test_entry) {
            $specimen_id = $test_entry->specimenId;
            $specimen = get_specimen_by_id($specimen_id);
            $patient = Patient::getById($specimen->patientId);
            $test = $test_entry;
            ?>
		<tr valign='top'>
			<?php 
            if ($report_config->usePatientId == 1) {
                ?>
				<td><?php 
                echo $patient->getSurrogateId();
                ?>
</td>
			<?php 
            }
            if ($report_config->usePatientAddlId == 1) {
                ?>
				<td><?php 
Ejemplo n.º 3
0
         }
         $date_ts = $second_day_ts;
         $i++;
     }
     DbUtil::switchRestore($saved_db);
     return $retval;
 }
 public static function getDiscreteInfectionStatsMonthly($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);
     $month_ts = mktime(0, 0, 0, $date_from_parts[1], 0, $date_from_parts[0]);
     $date_to_ts = mktime(0, 0, 0, $date_to_parts[1], 0, $date_to_parts[0]);
     # For the test type, fetch negative records
     while ($month_ts < $date_to_ts) {
         $end_of_month_ts = mktime(0, 0, 0, $date_from_parts[1] + $i, 0, $date_from_parts[0]);
         $date_fromp = date("Y-m-d", $month_ts);
         $date_top = date("Y-m-d", $end_of_month_ts);
         if ($gender == 'M' || $gender == 'F') {
             $query_string = "SELECT COUNT(*) AS count_val  FROM test t, patient p, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND p.patient_id=s.patient_id " . "AND p.sex LIKE '{$gender}' " . "AND t.specimen_id=s.specimen_id " . "AND (s.date_collected BETWEEN '{$date_fromp}' AND '{$date_top}') " . "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,%')";
         } else {
             $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_fromp}' AND '{$date_top}' )" . "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 = $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_fromp}' AND '{$date_top}' )";
         $record = query_associative_one($query_string);
         $count_all = $record['count_val'];
         # If total tests is 0, ignore
         if ($count_all != 0) {
             $retval[$month_ts] = array($count_all, $count_negative);
         }
         $month_ts = $end_of_month_ts;
Ejemplo n.º 4
0
function search_patients_by_dailynum($q)
{
    global $con;
    $q = mysql_real_escape_string($q, $con);
    # Searches for patients with similar daily number
    $query_string = "SELECT DISTINCT patient_id FROM specimen WHERE daily_num LIKE '%" . $q . "' ORDER BY date_collected DESC LIMIT 20";
    $resultset = query_associative_all($query_string, $row_count);
    $patient_list = array();
    if (count($resultset) > 0) {
        foreach ($resultset as $record) {
            $patient_list[] = Patient::getById($record['patient_id']);
        }
    }
    return $patient_list;
}
Ejemplo n.º 5
0
	public function getReportResultsForm($form_name, $form_id)
	{
		$specimen_list = Specimen::getUnreported();
		if($specimen_list == null || count($specimen_list) == 0)
			return;
		?>
		<table class='tablesorter'>
			<thead>
				<tr valign='top'>
					<?php
					if($_SESSION['pid'] != 0)
					{
						?>
						<th><?php echo LangUtil::$generalTerms['PATIENT_ID']; ?></th>
						<?php
					}
					if($_SESSION['dnum'] != 0)
					{
						?>
						<th><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></th>
						<?php
					}
					if($_SESSION['s_addl'] != 0)
					{
						?>
						<th><?php echo LangUtil::$generalTerms['SPECIMEN_ID']; ?></th>
						<?php
					}
					?>
					<th><?php echo LangUtil::$generalTerms['PATIENT_NAME']; ?></th>
					<th><?php echo LangUtil::$generalTerms['SPECIMEN_TYPE']; ?></th>
					<th><?php echo LangUtil::$generalTerms['C_DATE']; ?></th>
					<th><?php echo LangUtil::$generalTerms['TESTS']; ?></th>
					<th><?php echo LangUtil::$generalTerms['REPORT_TO']; ?></th>
					<th>
						<?php echo LangUtil::$generalTerms['REPORTED']; ?>?
						<input type='checkbox' name='check_all' id='check_all' onclick='checkoruncheckall();'>
						</input>
					</th>
				</tr>
			</thead>
			<tbody>
			<?php
			foreach($specimen_list as $specimen)
			{
				$test_list = get_tests_by_specimen_id($specimen->specimenId);
				$patient = Patient::getById($specimen->patientId);
				?>
				<tr valign='top'>
					<input type='hidden' name='sid[]' value='<?php echo $specimen->specimenId; ?>'></input>
					<?php
					if($_SESSION['pid'] != 0)
					{
						?>
						<td><?php echo $specimen->getSurrogateId(); ?></td>
						<?php
					}
					if($_SESSION['dnum'] != 0)
					{
						?>
						<td><?php $specimen->getDailyNum(); ?></td>
						<?php
					}
					if($_SESSION['s_addl'] != 0)
					{
						?>
						<td><?php $specimen->getAuxId(); ?></td>
						<?php
					}
					?>
					<td><?php echo $patient->getName(); ?></td>
					<td><?php echo get_specimen_name_by_id($specimen->specimenTypeId); ?></td>
					<td><?php echo DateLib::mysqlToString($specimen->dateCollected)." ".$specimen->timeCollected; ?></td>
					<td>
						<?php 
						foreach($test_list as $test)
						{
							echo get_test_name_by_id($test->testTypeId);
							echo "<br>";
						}
						?>
					</td>
					<td><?php echo $specimen->getReportTo(); ?></td>
					<td>
						<center>
							<input type='checkbox' class='report_flag' name='mark_<?php echo $specimen->specimenId; ?>'></input>
						</center>
					</td>
				</tr>
				<?php
			}
			?>
			</tbody>
		</table>
		<?php
	}
Ejemplo n.º 6
0
<?php

include "../includes/db_lib.php";
include "../includes/script_elems.php";
$patientId = $_REQUEST['pid'];
$type = $_REQUEST['type'];
$script_elems = new ScriptElems();
$script_elems->enableTableSorter();
$script_elems->enableJQueryForm();
if ($type == 'national') {
    $user = get_user_by_id($_SESSION['user_id']);
    $country = strtolower($user->country);
    $saved_db = DbUtil::switchToCountry($country);
    $patient = Patient::getById($patientId);
    DbUtil::switchRestore($saved_db);
    $lab_config = LabConfig::getById($_SESSION['lab_config_id']);
    ?>
	<table class='hor-minimalist-b' <?php 
    if ($width != "") {
        echo " style='width:" . $width . "px;' ";
    }
    ?>
>
		<tbody>
				<tr>
					<td><u><?php 
    echo LangUtil::$generalTerms['NAME'];
    ?>
</u></td>
					<td><?php 
    echo $patient->getName();
Ejemplo n.º 7
0
			function print_bill(id, lab_id)
			{
				var url = "reports_billing_specific.php?bill_id=" + id + "&lab_config_id=" + lab_id;
				window.open(url, '_blank');
				window.focus();
			}
		</script>
		<?php 
include "../includes/styles.php";
?>
	</head>
	
	<body>
		<?php 
$bill = Bill::loadFromId($billId, $lab_config_id);
$patient = Patient::getById($bill->getPatientId());
$associations = $bill->getAllAssociationsForBill($lab_config_id);
?>
		<div class='patient_bill_title'>
			Bill <?php 
echo $bill->getId();
?>
 for <?php 
echo $patient->getName();
?>
		</div>
		<form id='payments_form' name='payments_form' action=''>
			<table class='tablesorter' id='bill_table' style="border-collapse: separate;">
				<tr valign='top'>
					<th style="width: 75px;">Test Date</th>
					<th>Test Name</th>
Ejemplo n.º 8
0
function getSpecimenFromBarcode($specimen_code)
{
    $pieces = decodeSpecimenBarcode($specimen_code);
    $specimen_id = $pieces[1];
    $patientClass = new Patient();
    $patient = $patientClass->getById($patient_id);
    return $patient;
}
Ejemplo n.º 9
0
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++;
    }
}