function get_records_to_print($lab_config, $patient_id) { global $date_from, $date_to; $retval = array(); if (isset($_REQUEST['ip']) && $_REQUEST['ip'] == 0) { # Do not include pending tests $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.result <> '' " . "AND t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } else { # Include pending tests $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } $resultset = query_associative_all($query_string, $row_count); if (count($resultset) == 0 || $resultset == null) { return $retval; } foreach ($resultset as $record) { $test = Test::getObject($record); $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; }
function get_records_to_print($lab_config, $patient_id) { $retval = array(); # Include pending tests $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; $resultset = query_associative_all($query_string, $row_count); if (count($resultset) == 0 || $resultset == null) { return $retval; } foreach ($resultset as $record) { $test = Test::getObject($record); $specimen = get_specimen_by_id($test->specimenId); $retval[] = array($test, $specimen); } return $retval; }
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; }
echo "<td><br><br></td>"; } 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) { ?>
public function getSpecimenInfo($sid) { # Returns HTML table displaying specimen info $specimen = get_specimen_by_id($sid); if($specimen == null) { ?> <div class='sidetip_nopos'> <?php echo LangUtil::$generalTerms['ERROR'].": ".LangUtil::$generalTerms['SPECIMEN_ID']." ".LangUtil::$generalTerms['MSG_NOTFOUND']; ?> </div> <?php return; } ?> <table class='hor-minimalist-b'> <tbody> <tr> <td><u><?php echo LangUtil::$generalTerms['TYPE']; ?></u></td> <td><?php echo get_specimen_name_by_id($specimen->specimenTypeId); ?></td> </tr> <?php if($_SESSION['sid'] != 0) { ?> <tr valign='top' style='display:none;'> <td><u>DB Key</u></td> <td><?php echo $specimen->specimenId; ?></td> </tr> <?php } if($_SESSION['s_addl'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['SPECIMEN_ID']; ?></u></td> <td><?php $specimen->getAuxId(); ?></td> </tr> <?php } if($_SESSION['dnum'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></u></td> <td><?php echo $specimen->getDailyNum(); ?></td> </tr> <?php } ?> <tr valign='top'> <td><u><?php echo LangUtil::$generalTerms['ACCESSION_NUM']; ?></u></td> <td><?php echo $specimen->sessionNum; ?></td> </tr> <tr> <td><u><?php echo LangUtil::$generalTerms['PATIENT']; ?></u></td> <td> <?php $patient = Patient::getById($specimen->patientId); echo $patient->getName()." (".$patient->sex." ".$patient->getAge().")"; ?> <a href='patient_profile.php?pid=<?php echo $specimen->patientId?>' title='Click to go to Patient Profile'>Profile</a> </td> </tr> <tr> <td><u><?php echo LangUtil::$generalTerms['R_DATE']; ?></u></td> <td> <?php echo DateLib::mysqlToString($specimen->dateRecvd); ?> </td> </tr> <tr> <td><u><?php echo LangUtil::$generalTerms['REGD_BY']; ?></u></td> <td><?php echo get_username_by_id($specimen->userId); ?></td> </tr> <?php if($_SESSION['comm'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['COMMENTS']; ?></u></td> <td><?php echo $specimen->getComments(); ?></td> </tr> <?php } ?> <tr valign='top'> <td><u><?php echo LangUtil::$generalTerms['TESTS']; ?></u></td> <td><?php echo $specimen->getTestNames(); ?></td> </tr> <?php if($_SESSION['doctor'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['DOCTOR']; ?></u></td> <td> <?php if(trim($specimen->doctor) == "") { echo "-"; } else { echo $specimen->doctor; } ?> </td> </tr> <?php } ?> <?php # Custom fields here $custom_data_list = get_custom_data_specimen($specimen->specimenId); foreach($custom_data_list as $custom_data) { $field_name = get_custom_field_name_specimen($custom_data->fieldId); if(stripos($field_name ,"^^")==NULL) { $field_value = $custom_data->fieldValue; ?> <tr> <td><u><?php echo $field_name; ?></u></td> <td><?php echo $custom_data->getFieldValueString($_SESSION['lab_config_id'], 1); ?></td> </tr> <?php } } if($_SESSION['refout'] != 0) { # Show referred-out hospital name if specimen was referred out and/or returned back if ( $specimen->statusCodeId == Specimen::$STATUS_REFERRED || $specimen->statusCodeId == Specimen::$STATUS_RETURNED ) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['REF_TO']; ?></u></td> <td> <?php if(trim($specimen->referredToName) == "") { echo "Not Known"; } else { echo $specimen->referredToName; } ?> </td> </tr> <?php } } ?> <tr> <td><u><?php echo LangUtil::$generalTerms['SP_STATUS']; ?></u></td> <td> <?php echo $specimen->getStatus(); $result1="Completed"; $result= $specimen->getStatus(); ?> <a href='specimen_result.php?sid=<?php echo $specimen->specimenId;?>' <?php if(strcmp($result,$result1)==0){ ?> style='display:none;' <?php }?> title='Click to Enter result values for this Specimen'><?php echo LangUtil::$generalTerms['ENTER_RESULTS']; ?></a> </td> </tr> </tbody> </table> <?php }
function get_records_to_print($lab_config, $patient_id) { global $date_from, $date_to, $LIS_DOCTOR; $retval = array(); if (isset($_REQUEST['ip']) && $_REQUEST['ip'] == 0) { # Do not include pending tests $labsection = 0; if (isset($_REQUEST['labsection'])) { $labsection = $_REQUEST['labsection']; } if ($labsection == 0) { $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.result <> '' " . "AND t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; } else { $query_string = "SELECT distinct t.* FROM test t, specimen sp, test_type tt, test_category tc " . "WHERE t.specimen_id=sp.specimen_id " . "AND t.result <> '' " . "AND sp.patient_id={$patient_id} " . "AND t.test_type_id = tt.test_type_id " . "AND tt.test_type_id in (select test_type_id from test_type where test_category_id = {$labsection})"; } #Taking care of removal tests cases $query_string .= " AND t.test_id not in (select distinct r_id from removal_record where `status` = 1) "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } else { # Include pending tests $labsection = 0; if (isset($_REQUEST['labsection'])) { $labsection = $_REQUEST['labsection']; } if ($labsection == 0) { $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; } else { $query_string = "SELECT distinct t.* FROM test t, specimen sp, test_type tt, test_category tc " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} " . "AND t.test_type_id = tt.test_type_id " . "AND tt.test_type_id in (select test_type_id from test_type where test_category_id = {$labsection})"; } #Taking care of removal tests cases $query_string .= " AND t.test_id not in (select distinct r_id from removal_record where `status` = 1) "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } $resultset = query_associative_all($query_string, $row_count); if (count($resultset) == 0 || $resultset == null) { return $retval; } foreach ($resultset as $record) { $test = Test::getObject($record); if ($_SESSION['user_level'] == $LIS_DOCTOR) { if ($test->verifiedBy == 0) { continue; } } $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; }
public function getSpecimenInfo($sid) { # Returns HTML table displaying specimen info $specimen = get_specimen_by_id($sid); //print_r($rem_specs); if($specimen == null) { ?> <div class='sidetip_nopos'> <?php echo LangUtil::$generalTerms['ERROR'].": ".LangUtil::$generalTerms['SPECIMEN_ID']." ".LangUtil::$generalTerms['MSG_NOTFOUND']; ?> </div> <?php return; } $rem_recs = get_removed_specimens($_SESSION['lab_config_id'], "specimen"); $rem_specs = array(); $rem_remarks = array(); foreach($rem_recs as $rem_rec) { $rem_specs[] = $rem_rec['r_id']; $rem_remarks[] = $rem_rec['remarks']; } ?> <script type="text/javascript"> function retrieve_deleted(sid, category){ var params = "item_id="+sid+"&ret_cat="+category; $.ajax({ type: "POST", url: "ajax/retrieve_deleted.php", data: params, success: function(msg) { if(msg.indexOf("1")> -1){ location.href = location.href; } else { $("#target_div_id_del").html("Specimen cannot be Retrieved"); } } }); } </script> <table class='hor-minimalist-b'> <tbody> <tr> <td><u><?php echo LangUtil::$generalTerms['TYPE']; ?></u></td> <td><?php echo get_specimen_name_by_id($specimen->specimenTypeId); ?></td> </tr> <?php if($_SESSION['sid'] != 0) { ?> <tr valign='top' style='display:none;'> <td><u>DB Key</u></td> <td><?php echo $specimen->specimenId; ?></td> </tr> <?php } if($_SESSION['s_addl'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['SPECIMEN_ID']; ?></u></td> <td><?php $specimen->getAuxId(); ?></td> </tr> <?php } if($_SESSION['dnum'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></u></td> <td><?php echo $specimen->getDailyNum(); ?></td> </tr> <?php } ?> <tr valign='top'> <td><u><?php echo LangUtil::$generalTerms['ACCESSION_NUM']; ?></u></td> <td><?php echo $specimen->sessionNum; ?></td> </tr> <tr> <td><u><?php echo LangUtil::$generalTerms['PATIENT']; ?></u></td> <td> <?php $patient = Patient::getById($specimen->patientId); echo $patient->getName()." (".$patient->sex." ".$patient->getAge().")"; ?> <a href='patient_profile.php?pid=<?php echo $specimen->patientId?>' title='Click to go to Patient Profile'>Profile</a> </td> </tr> <tr> <td><u><?php echo LangUtil::$generalTerms['R_DATE']; ?></u></td> <td> <?php echo DateLib::mysqlToString($specimen->dateRecvd); ?> </td> </tr> <tr> <td><u><?php echo LangUtil::$generalTerms['REGD_BY']; ?></u></td> <td><?php echo get_username_by_id($specimen->userId); ?></td> </tr> <?php if($_SESSION['comm'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['COMMENTS']; ?></u></td> <td><?php echo $specimen->getComments(); ?></td> </tr> <?php } ?> <tr valign='top'> <td><u><?php echo LangUtil::$generalTerms['TESTS']; ?></u></td> <td><?php echo $specimen->getTestNames(); ?></td> </tr> <?php if($_SESSION['doctor'] != 0) { ?> <tr> <td><u><?php echo LangUtil::$generalTerms['DOCTOR']; ?></u></td> <td> <?php if(trim($specimen->doctor) == "") { echo "-"; } else { echo $specimen->doctor; } ?> </td> </tr> <?php } ?> <?php # Custom fields here $custom_data_list = get_custom_data_specimen($specimen->specimenId); foreach($custom_data_list as $custom_data) { $field_name = get_custom_field_name_specimen($custom_data->fieldId); if(stripos($field_name ,"^^")==NULL) { $field_value = $custom_data->fieldValue; ?> <tr> <td><u><?php echo $field_name; ?></u></td> <td><input type="text" value="<?php echo $custom_data->getFieldValueString($_SESSION['lab_config_id'], 1); ?>" /></td> </tr> <?php } } if($_SESSION['refout'] != 0) { # Show referred-out hospital name if specimen was referred out and/or returned back if ( $specimen->statusCodeId == Specimen::$STATUS_REFERRED || $specimen->statusCodeId == Specimen::$STATUS_RETURNED ) { if(strlen(trim($specimen->referredToName)) > 0){ ?> <tr> <td><u><?php echo LangUtil::$generalTerms['REF_TO']; ?></u></td> <td> <?php if(trim($specimen->referredToName) == "") { echo "Not Known"; } else { echo $specimen->referredToName; } ?> </td> </tr> <?php } if(strlen(trim($specimen->referredFromName)) > 0){ ?> <tr> <td><u><?php echo "Referred From "; ?></u></td> <td> <?php if(trim($specimen->referredFromName) == "") { echo "Not Known"; } else { echo $specimen->referredFromName; } ?> </td> </tr> <?php } } } ?> <tr> <td><u><?php echo LangUtil::$generalTerms['SP_STATUS']; ?></u></td> <td> <?php if(in_array($specimen->specimenId, $rem_specs) && is_admin(get_user_by_id($_SESSION['user_id']))!=1){ echo "Specimen Removed. Contact lab admin"; } else if(in_array($specimen->specimenId, $rem_specs) && is_admin(get_user_by_id($_SESSION['user_id']))==1){ ?> <a href='javascript:retrieve_deleted(<?php echo $specimen->specimenId;?>, "specimen")' title='Click to retrieve deleted Specimen'>Retrieve Specimen</a> <?php } else { echo $specimen->getStatus(); $result1="Completed"; $result= $specimen->getStatus(); ?> <a href='specimen_result.php?sid=<?php echo $specimen->specimenId;?>' <?php if(strcmp($result,$result1)==0 || $_SESSION['user_level'] == 17){ ?> style='display:none;' <?php }?> title='Click to Enter result values for this Specimen'><?php echo LangUtil::$generalTerms['ENTER_RESULTS']; ?></a> <?php } ?> </td> </tr> </tbody> </table> <?php }
public function get_specimen($specimen_id) { $spec = get_specimen_by_id($specimen_id); if (count($spec) > 0) { $ret = $spec; } else { $ret = 0; } return $ret; }
function add_results_random($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']; //$specimens_to_handle = floor($NUM_SPECIMENS * (1-$F_PENDING)); $saved_db = DbUtil::switchToLabConfig($lab_config_id); $num_specimens2 = query_num_rows("specimen"); DbUtil::switchRestore($saved_db); $specimens_to_handle = floor($num_specimens2 * (1 - $F_PENDING)); //echo $specimens_to_handle." / ".$num_specimens2."<br>"; $count = 0; $specimen_id_count = $SPECIMEN_ID_START; while ($count < $specimens_to_handle) { # Fetch random specimen //$specimen_id = rand($SPECIMEN_ID_START, $SPECIMEN_ID_START + $NUM_SPECIMENS); $specimen_id = $specimen_id_count; //echo $specimen_id."<br>"; $specimen = get_specimen_by_id($specimen_id); 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']); $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; } # 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); # 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++; } }