Permalink
Browse files

Added feature to associate patient notes (messages) with procedure or…

…ders and their results.
  • Loading branch information...
1 parent c506d3e commit 2457b1d50535530ea7326d27429db1efa19778a2 @sunsetsystems sunsetsystems committed Mar 26, 2013
@@ -293,6 +293,25 @@
echo " </td>\n";
echo " </tr>\n";
}
+ // Get the related procedure order IDs if any.
+ $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " .
+ "type1 = ? AND type2 = ? AND id2 = ?",
+ array('2', '6', $noteid));
+ if (sqlNumRows($tmp)) {
+ echo " <tr>\n";
+ echo " <td class='text'><b>";
+ echo xlt('Linked procedure order') . ":</b>\n";
+ while ($gprow = sqlFetchArray($tmp)) {
+ echo " <a href='";
+ echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
+ echo $gprow['id1'];
+ echo "' target='_blank' onclick='top.restoreSession()'>";
+ echo $gprow['id1'];
+ echo "</a>\n";
+ }
+ echo " </td>\n";
+ echo " </tr>\n";
+ }
}
?>
@@ -89,7 +89,8 @@ function myCellText($s) {
function openResults(orderid) {
top.restoreSession();
- window.open('single_order_results.php?orderid=' + orderid);
+ // window.open('single_order_results.php?orderid=' + orderid);
+ document.location.href = 'single_order_results.php?orderid=' + orderid;
}
</script>
@@ -27,6 +27,7 @@
require_once("$srcdir/formdata.inc.php");
require_once("$srcdir/options.inc.php");
require_once("$srcdir/formatting.inc.php");
+require_once("$srcdir/patient.inc");
require_once("$srcdir/classes/InsuranceCompany.class.php");
function getListItem($listid, $value) {
@@ -94,10 +94,29 @@ function generate_order_report($orderid, $input_form=false) {
<?php if ($input_form) { ?>
<script type="text/javascript" src="../../library/dialog.js"></script>
<script type="text/javascript" src="../../library/textformat.js"></script>
+<?php } // end if input form ?>
+
+<?php if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { ?>
<script language="JavaScript">
var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
+// Called to show patient notes related to this order in the "other" frame.
+function showpnotes(orderid) {
+ // Look for the top or bottom frame that contains this document, return if none.
+ var w;
+ for (w = window; w.name != 'RTop' && w.name != 'RBot'; w = w.parent) {
+ if (w.parent == w) return false;
+ }
+ var othername = (w.name == 'RTop') ? 'RBot' : 'RTop';
+ w.parent.left_nav.forceDual();
+ w.parent.left_nav.setRadio(othername, 'pno');
+ w.parent.left_nav.loadFrame('pno1', othername, 'patient_file/summary/pnotes_full.php?orderid=' + orderid);
+ return false;
+}
</script>
-<form method='post' action='single_order_results.php?orderid=<?php echo attr($orderid); ?>'>
+<?php } // end if not patient report ?>
+
+<?php if ($input_form) { ?>
+<form method='post' action='single_order_results.php?orderid=<?php echo $orderid; ?>'>
<?php } // end if input form ?>
<div class='labres'>
@@ -348,7 +367,12 @@ function generate_order_report($orderid, $input_form=false) {
?>
</td>
<td style='border-width:0px;' align='right' valign='top'>
+<?php if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { ?>
+ <input type='button' value='<?php echo xla('Related Patient Notes'); ?>'
+ onclick='showpnotes(<?php echo $orderid; ?>)' />
+<?php } ?>
<?php if ($input_form && $sign_list) { ?>
+ &nbsp;
<input type='hidden' name='form_sign_list' value='<?php echo attr($sign_list); ?>' />
<input type='submit' name='form_sign' value='<?php echo xla('Sign Results'); ?>'
title='<?php echo xla('Mark these reports as reviewed'); ?>' />
@@ -20,6 +20,9 @@
require_once("$srcdir/formdata.inc.php");
require_once(dirname(__file__) . "/../../../custom/code_types.inc.php");
+// For those who care that this is the patient report.
+$GLOBALS['PATIENT_REPORT_ACTIVE'] = true;
+
$PDF_OUTPUT = empty($_POST['pdf']) ? false : true;
if ($PDF_OUTPUT) {
@@ -16,7 +16,21 @@
require_once("$srcdir/classes/Document.class.php");
// form parameter docid can be passed to restrict the display to a document.
- $docid = empty($_REQUEST['docid']) ? 0 : 0 + $_REQUEST['docid'];
+ $docid = empty($_REQUEST['docid']) ? 0 : intval($_REQUEST['docid']);
+
+ // form parameter orderid can be passed to restrict the display to a procedure order.
+ $orderid = empty($_REQUEST['orderid']) ? 0 : intval($_REQUEST['orderid']);
+
+ $patient_id = $pid;
+ if ($docid) {
+ $row = sqlQuery("SELECT foreign_id FROM documents WHERE id = ?", array($docid));
+ $patient_id = intval($row['foreign_id']);
+ }
+ else if ($orderid) {
+ $row = sqlQuery("SELECT patient_id FROM procedure_order WHERE procedure_order_id = ?", array($orderid));
+ $patient_id = intval($row['patient_id']);
+ }
+ $urlparms = "docid=$docid&orderid=$orderid";
?>
<html>
<head>
@@ -31,7 +45,7 @@
<?php
$thisauth = acl_check('patients', 'notes');
if ($thisauth) {
- $tmp = getPatientData($pid, "squad");
+ $tmp = getPatientData($patient_id, "squad");
if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
$thisauth = 0;
}
@@ -47,18 +61,21 @@
<?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
<?php if ($GLOBALS['concurrent_layout']) { ?>
-<a href="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>" onclick="top.restoreSession()">
+<a href="pnotes_full.php?<?php echo $urlparms; ?>" onclick="top.restoreSession()">
<?php } else { ?>
-<a href="pnotes_full.php?docid=<?php echo htmlspecialchars( $docid, ENT_QUOTES); ?>" target="Main" onclick="top.restoreSession()">
+<a href="pnotes_full.php?<?php echo $urlparms; ?>" target="Main" onclick="top.restoreSession()">
<?php } ?>
<span class="title"><?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?>
<?php
if ($docid) {
- echo " " . htmlspecialchars( xl("linked to document"), ENT_NOQUOTES) . " ";
+ echo " " . xlt("linked to document") . " ";
$d = new Document($docid);
echo $d->get_url_file();
}
+ else if ($orderid) {
+ echo " " . xlt("linked to procedure order") . " $orderid";
+ }
?>
</span>
<span class=more><?php echo htmlspecialchars( $tmore, ENT_NOQUOTES);?></span>
@@ -79,15 +96,15 @@
$colorend = "";
$sql = "select genericname2, genericval2 " .
"from patient_data where pid = ? limit 1";
-$resnote = sqlQuery($sql, array($pid) );
+$resnote = sqlQuery($sql, array($patient_id) );
if($resnote && $resnote['genericname2'] == 'Billing') {
$billing_note = $resnote['genericval2'];
$colorbeg = "<span style='color:red'>";
$colorend = "</span>";
}
//Display what the patient owes
-$balance = get_patient_balance($pid);
+$balance = get_patient_balance($patient_id);
if ($balance != "0") {
$formatted = sprintf((xl('$').'%01.2f'), $balance);
echo " <tr class='text billing'>\n";
@@ -107,7 +124,7 @@
//retrieve all active notes
$result = getPnotesByDate("", 1, "id,date,body,user,title,assigned_to",
- $pid, "all", 0, '', $docid);
+ $patient_id, "all", 0, '', $docid, '', $orderid);
if ($result != null) {
$notes_count = 0;//number of notes so far displayed
@@ -119,9 +136,8 @@
echo " <td colspan='3' align='center'>\n";
echo " <a ";
if (!$GLOBALS['concurrent_layout']) echo "target='Main' ";
- echo "href='pnotes_full.php?active=1&docid=" .
- htmlspecialchars( $docid, ENT_QUOTES) .
- "' class='alert' onclick='top.restoreSession()'>";
+ echo "href='pnotes_full.php?active=1&$urlparms" .
+ "' class='alert' onclick='top.restoreSession()'>";
echo htmlspecialchars( xl('Some notes were not displayed.','','',' '), ENT_NOQUOTES) .
htmlspecialchars( xl('Click here to view all.'), ENT_NOQUOTES) . "</a>\n";
echo " </td>\n";
@@ -171,9 +187,9 @@
<?php if ( acl_check('patients', 'notes','',array('write','addonly') )): ?>
top.restoreSession();
<?php if (!$GLOBALS['concurrent_layout']): ?>
- top.Main.location.href = "pnotes_full.php?docid=<?php echo $docid; ?>&noteid=" + note.id + "&active=1";
+ top.Main.location.href = "pnotes_full.php?<?php echo $urlparms; ?>&noteid=" + note.id + "&active=1";
<?php else: ?>
- location.href = "pnotes_full.php?docid=<?php echo $docid; ?>&noteid=" + note.id + "&active=1";
+ location.href = "pnotes_full.php?<?php echo $urlparms; ?>&noteid=" + note.id + "&active=1";
<?php endif; ?>
<?php else: ?>
// no-op
Oops, something went wrong.

0 comments on commit 2457b1d

Please sign in to comment.