Skip to content

Commit

Permalink
Configurable display of the SpecimenID format in defaults.php (SPEC_I…
Browse files Browse the repository at this point in the history
…D_FORMAT). Closes #43
  • Loading branch information
mapesa committed Jun 26, 2014
1 parent 7f4cac9 commit 1f88b6f
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 2,257 deletions.
3 changes: 2 additions & 1 deletion htdocs/ajax/result_entry_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@
if($_SESSION['sid'] != 0)
{
?>
<td style='width:75px;'><?php echo $test->getLabSectionByTest(); ?></td>
<td style='width:75px;'>
<?php echo (isset($test->specimenId)?get_sequential_specimen_id($test->specimenId):""); ?></td>
<?php
}
?>
Expand Down
46 changes: 42 additions & 4 deletions htdocs/ajax/tat_ttype_daily.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,44 @@
});
new Highcharts.Chart(options);

function specimen_info(specimen_id)
{
var el = jQuery('.portlet .tools a.reload').parents(".portlet");
App.blockUI(el);
var url = 'search/specimen_info.php';
var target_div = "specimen_info";
$("#"+target_div).load(url,
{sid: specimen_id, modal:1},
function()
{
$('#'+target_div).modal('show');
if(status==<?php echo Specimen::$STATUS_VERIFIED;?>){
$('#verifybtn'+test_id).remove();
$('#verifydby'+test_id).removeClass('label-warning');
$('#verifydby'+test_id).addClass('label-success');
}
App.unblockUI(el);
}
);
}

function close_modal(this_element){

var el = $('#' + this_element).closest('.modal');
el.empty();
el.modal('hide');
}

</script>

<div id="trendsDiv"></div>
<div id="specimen_info" class="modal hide fade" data-backdrop="static" data-keyboard="true" style="width:900px;">
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn" onclick='javascript:cancel_hide()'>No</button>
</div>
</div>

<?php

if($test_type_id != 0) {
Expand Down Expand Up @@ -252,7 +287,8 @@ function graph_data_table(page, itemsPerPage){
var gdate = (new Date(time_c*1000)).toISOString().replace("T", " ").substr(0,19); //The date

graph_data += "<tr><td>"+counter+"</td>";
graph_data += "<td>"+spec_id+"</td>";
graph_data += "<td><a href='javascript:void(0);' onclick='specimen_info("+datum.specimen_id;
graph_data += ");' title='More Details'>"+spec_id+"</a></td>";
graph_data += "<td>"+datum['specimen_type']+"</td>";
graph_data += "<td>"+datum['test_name']+"</td>";
graph_data += "<td>"+gdate+"</td>";
Expand Down Expand Up @@ -288,7 +324,7 @@ function graph_data_table(page, itemsPerPage){
<?php
}

function graph_data_table($stats_array, $page = 1, $number_per_page = 50){
function graph_data_table($stats_array, $page = 1, $number_per_page = 25){
# Displays the graph source data in tabular form

$counter = 0;
Expand Down Expand Up @@ -325,10 +361,12 @@ function graph_data_table($stats_array, $page = 1, $number_per_page = 50){

if ($counter <= $page*$number_per_page && $counter > ($page-1)*$number_per_page) {

$spec_id = get_sequential_specimen_id($datum['specimen_id']);
$sid = $datum['specimen_id'];
$spec_id = get_sequential_specimen_id($sid);

$graph_data .= "<tr><td>$counter</td>";
$graph_data .= "<td>$spec_id</td>";
$graph_data .= "<td><a href='javascript:void(0);' onclick='specimen_info($sid);' ";
$graph_data .= "title='More Details'>$spec_id</a></td>";
$graph_data .= "<td>".$datum['specimen_type']."</td>";
$graph_data .= "<td>".$datum['test_name']."</td>";
$graph_data .= "<td>".date("Y-m-d H:i:s", $time_c)."</td>";
Expand Down
46 changes: 42 additions & 4 deletions htdocs/ajax/tat_ttype_monthly.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,44 @@
});
new Highcharts.Chart(options);

function specimen_info(specimen_id)
{
var el = jQuery('.portlet .tools a.reload').parents(".portlet");
App.blockUI(el);
var url = 'search/specimen_info.php';
var target_div = "specimen_info";
$("#"+target_div).load(url,
{sid: specimen_id, modal:1},
function()
{
$('#'+target_div).modal('show');
if(status==<?php echo Specimen::$STATUS_VERIFIED;?>){
$('#verifybtn'+test_id).remove();
$('#verifydby'+test_id).removeClass('label-warning');
$('#verifydby'+test_id).addClass('label-success');
}
App.unblockUI(el);
}
);
}

function close_modal(this_element){

var el = $('#' + this_element).closest('.modal');
el.empty();
el.modal('hide');
}

</script>

<div id="trendsDiv"></div>
<div id="specimen_info" class="modal hide fade" data-backdrop="static" data-keyboard="true" style="width:900px;">
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn" onclick='javascript:cancel_hide()'>No</button>
</div>
</div>

<?php

if($test_type_id != 0) {
Expand Down Expand Up @@ -252,7 +287,8 @@ function graph_data_table(page, itemsPerPage){
var gdate = (new Date(time_c*1000)).toISOString().replace("T", " ").substr(0,19); //The date

graph_data += "<tr><td>"+counter+"</td>";
graph_data += "<td>"+spec_id+"</td>";
graph_data += "<td><a href='javascript:void(0);' onclick='specimen_info("+datum.specimen_id;
graph_data += ");' title='More Details'>"+spec_id+"</a></td>";
graph_data += "<td>"+datum['specimen_type']+"</td>";
graph_data += "<td>"+datum['test_name']+"</td>";
graph_data += "<td>"+gdate+"</td>";
Expand Down Expand Up @@ -288,7 +324,7 @@ function graph_data_table(page, itemsPerPage){
<?php
}

function graph_data_table($stats_array, $page = 1, $number_per_page = 50){
function graph_data_table($stats_array, $page = 1, $number_per_page = 25){
# Displays the graph source data in tabular form

$counter = 0;
Expand Down Expand Up @@ -325,10 +361,12 @@ function graph_data_table($stats_array, $page = 1, $number_per_page = 50){

if ($counter <= $page*$number_per_page && $counter > ($page-1)*$number_per_page) {

$spec_id = get_sequential_specimen_id($datum['specimen_id']);
$sid = $datum['specimen_id'];
$spec_id = get_sequential_specimen_id($sid);

$graph_data .= "<tr><td>$counter</td>";
$graph_data .= "<td>$spec_id</td>";
$graph_data .= "<td><a href='javascript:void(0);' onclick='specimen_info($sid);' ";
$graph_data .= "title='More Details'>$spec_id</a></td>";
$graph_data .= "<td>".$datum['specimen_type']."</td>";
$graph_data .= "<td>".$datum['test_name']."</td>";
$graph_data .= "<td>".date("Y-m-d H:i:s", $time_c)."</td>";
Expand Down
47 changes: 42 additions & 5 deletions htdocs/ajax/tat_ttype_weekly.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
#
# Main page for creating Weekly TAT progression charts
# Main page for creating Weelly TAT progression charts
# Called via Ajax from reports_tat.php
# We only handle one lab (No multiple labs)
#
Expand Down Expand Up @@ -176,9 +176,43 @@
});
new Highcharts.Chart(options);

function specimen_info(specimen_id)
{
var el = jQuery('.portlet .tools a.reload').parents(".portlet");
App.blockUI(el);
var url = 'search/specimen_info.php';
var target_div = "specimen_info";
$("#"+target_div).load(url,
{sid: specimen_id, modal:1},
function()
{
$('#'+target_div).modal('show');
if(status==<?php echo Specimen::$STATUS_VERIFIED;?>){
$('#verifybtn'+test_id).remove();
$('#verifydby'+test_id).removeClass('label-warning');
$('#verifydby'+test_id).addClass('label-success');
}
App.unblockUI(el);
}
);
}

function close_modal(this_element){

var el = $('#' + this_element).closest('.modal');
el.empty();
el.modal('hide');
}
</script>

<div id="trendsDiv"></div>
<div id="specimen_info" class="modal hide fade" data-backdrop="static" data-keyboard="true" style="width:900px;">
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn" onclick='javascript:cancel_hide()'>No</button>
</div>
</div>

<?php

if($test_type_id != 0) {
Expand Down Expand Up @@ -252,7 +286,8 @@ function graph_data_table(page, itemsPerPage){
var gdate = (new Date(time_c*1000)).toISOString().replace("T", " ").substr(0,19); //The date

graph_data += "<tr><td>"+counter+"</td>";
graph_data += "<td>"+spec_id+"</td>";
graph_data += "<td><a href='javascript:void(0);' onclick='specimen_info("+datum.specimen_id;
graph_data += ");' title='More Details'>"+spec_id+"</a></td>";
graph_data += "<td>"+datum['specimen_type']+"</td>";
graph_data += "<td>"+datum['test_name']+"</td>";
graph_data += "<td>"+gdate+"</td>";
Expand Down Expand Up @@ -288,7 +323,7 @@ function graph_data_table(page, itemsPerPage){
<?php
}

function graph_data_table($stats_array, $page = 1, $number_per_page = 50){
function graph_data_table($stats_array, $page = 1, $number_per_page = 25){
# Displays the graph source data in tabular form

$counter = 0;
Expand Down Expand Up @@ -325,10 +360,12 @@ function graph_data_table($stats_array, $page = 1, $number_per_page = 50){

if ($counter <= $page*$number_per_page && $counter > ($page-1)*$number_per_page) {

$spec_id = get_sequential_specimen_id($datum['specimen_id']);
$sid = $datum['specimen_id'];
$spec_id = get_sequential_specimen_id($sid);

$graph_data .= "<tr><td>$counter</td>";
$graph_data .= "<td>$spec_id</td>";
$graph_data .= "<td><a href='javascript:void(0);' onclick='specimen_info($sid);' ";
$graph_data .= "title='More Details'>$spec_id</a></td>";
$graph_data .= "<td>".$datum['specimen_type']."</td>";
$graph_data .= "<td>".$datum['test_name']."</td>";
$graph_data .= "<td>".date("Y-m-d H:i:s", $time_c)."</td>";
Expand Down
9 changes: 9 additions & 0 deletions htdocs/includes/db_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17385,6 +17385,10 @@ function time_elapsed_pretty($datetime = null, $full = false) {

function get_sequential_specimen_id($specimen_id){
#Returns sequential specimen_ids (eg. MIC-2310) given a numeric specimen_id (id field of the specimen table)
global $SPEC_ID_FORMAT;

if(strcmp($SPEC_ID_FORMAT, "AUTO") == 0) return $specimen_id;

$saved_db = DbUtil::switchToLabConfig($_SESSION['lab_config_id']);

// 1. Get the test_category_id and the 3 letter category abbreviation
Expand All @@ -17395,6 +17399,11 @@ function get_sequential_specimen_id($specimen_id){
$tcid = $record['test_category_id'];
$tcname = $record['tcn'];

if(strcmp($SPEC_ID_FORMAT, "CATAUTO") == 0){
DbUtil::switchRestore($saved_db);
return $tcname."-".$specimen_id;
}

// 2. Get the position of this specimen in its category
$query = "SELECT COUNT(DISTINCT s.specimen_id) AS hits FROM specimen s INNER JOIN test t ON ".
"s.specimen_id = t.specimen_id INNER JOIN test_type tt ON t.test_type_id = tt.test_type_id ".
Expand Down
6 changes: 6 additions & 0 deletions htdocs/includes/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
# Can be modified by lab admin on config/lab_config_home.php
$DEFAULT_PENDING_TAT = 2;

# SPECIMEN_ID Format [CATSEQUENTIAL|CATAUTO|AUTO]
# CATSEQUENTIAL - Each category maintains its own sequence of numbers PAR-1...PAR-n (Default)
# CATAUTO - The ID is composed of the category prefix and the specimen_id field of the specimen table
# AUTO - The specimen_id field of the specimen table
$SPEC_ID_FORMAT = 'CATSEQUENTIAL';

# Auto logout after user inactivity
# Session times out and redirects to login page
# Refer to js/auto_logout.js
Expand Down
39 changes: 20 additions & 19 deletions htdocs/includes/page_elems.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ public function getTestCategorySelect($lab_config_id=null)
{
# Returns a set of drop down options for test categories in catalog
$cat_list = get_test_categories($lab_config_id);
if($cat_list) {
if(asort($cat_list)) {
foreach($cat_list as $key => $value)
echo "<option value='$key'>$value</option>";
return 1;
Expand Down Expand Up @@ -2522,7 +2522,7 @@ public function getPatientTestInfo($pid, $sid, $tid)
?>
<tr>
<td><u><?php echo LangUtil::$generalTerms['SPECIMEN_ID']; ?></u></td>
<td><?php $specimen->getAuxId(); ?></td>
<td><?php echo $specimen->getAuxId(); ?></td>
</tr>
<?php
}
Expand All @@ -2531,7 +2531,7 @@ public function getPatientTestInfo($pid, $sid, $tid)
?>
<tr>
<td><u><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></u></td>
<td><div style=" font-weight:bold;"><?php echo $specimen->getLabSection(); ?></div></td>
<td><div style=" font-weight:bold;"><?php echo get_sequential_specimen_id($sid); ?></div></td>
</tr>
<?php
}
Expand Down Expand Up @@ -3072,21 +3072,21 @@ public function getSpecimenInfoRow($specimen, $rem_specs, $admin, $is_result_for
</td>
<td>
<?php if($admin == 1)
{
if(in_array($specimen->specimenId, $rem_specs))
{
echo "Removed";
}
else
{
echo $specimen->getStatus();
}
}
else
{
echo $specimen->getStatus();
}
?>
{
if(in_array($specimen->specimenId, $rem_specs))
{
echo "Removed";
}
else
{
echo $specimen->getStatus();
}
}
else
{
echo $specimen->getStatus();
}
?>
</td>
<td>
<?php if ($is_result_form){?>
Expand Down Expand Up @@ -3438,7 +3438,8 @@ public function getSpecimenInfo($sid)
?>
<tr>
<td><u><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></u></td>
<td><div style="padding:5px; font-size:20px; font-weight:bold; color:#900;"><?php echo $specimen->getLabSection(); ?></div></td>
<td><div style="padding:5px; font-size:20px; font-weight:bold; color:#900;">
<?php echo get_sequential_specimen_id($sid) ?></div></td>
</tr>
<?php
}
Expand Down
Loading

0 comments on commit 1f88b6f

Please sign in to comment.