2 // Copyright (C) 2005-2009 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
10 $sanitize_all_escapes=true;
13 //STOP FAKE REGISTER GLOBALS
14 $fake_register_globals=false;
17 require_once("../../globals.php");
18 require_once("$srcdir/lists.inc");
19 require_once("$srcdir/acl.inc");
20 require_once("../../../custom/code_types.inc.php");
21 require_once("$srcdir/options.inc.php");
23 // Check authorization.
24 $thisauth = acl_check('patients', 'med');
26 $tmp = getPatientData($pid, "squad");
27 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
30 if (!$thisauth) die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES
) );
32 // Collect parameter(s)
33 $category = empty($_REQUEST['category']) ?
'' : $_REQUEST['category'];
39 <?php
html_header_show();?
>
41 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
43 <title
><?php
echo htmlspecialchars( xl('Patient Issues'), ENT_NOQUOTES
) ; ?
></title
>
45 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
46 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
48 <script language
="JavaScript">
50 // callback from add_edit_issue.php:
51 function refreshIssue(issue
, title
) {
56 function dopclick(id
,category
) {
57 <?php
if ($thisauth == 'write'): ?
>
58 if (category
== 0) category
= '';
59 dlgopen('add_edit_issue.php?issue=' +
encodeURIComponent(id
) +
'&thistype=' +
encodeURIComponent(category
), '_blank', 550, 400);
61 alert("<?php echo addslashes( xl('You are not authorized to add/edit issues') ); ?>");
65 // Process click on number of encounters.
66 function doeclick(id
) {
67 dlgopen('../problem_encounter.php?issue=' + id
, '_blank', 550, 400);
70 // Add Encounter button is clicked.
71 function newEncounter() {
72 var f
= document
.forms
[0];
74 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
75 parent
.left_nav
.setRadio(window
.name
, 'nen');
76 location
.href
='../../forms/newpatient/new.php?autoloaded=1&calenc=';
78 top
.Title
.location
.href
='../encounter/encounter_title.php';
79 top
.Main
.location
.href
='../encounter/patient_encounter.php?mode=new';
87 <body
class="body_top">
90 <div style
="text-align:center" class="buttons">
91 <a href
='javascript:;' class='css_button' id
='back'><span
><?php
echo htmlspecialchars( xl('Back'), ENT_NOQUOTES
); ?
></span
></a
>
96 <div id
='patient_stats'>
98 <form method
='post' action
='stats_full.php' onsubmit
='return top.restoreSession()'>
105 $first = 1; // flag for first section
106 foreach ($ISSUE_TYPES as $focustype => $focustitles) {
109 // Only show this category
110 if ($focustype != $category) continue;
121 $disptype = $focustitles[0];
122 if(($focustype=='allergy' ||
$focustype=='medication') && $GLOBALS['erx_enable'])
123 echo "<a href='../../eRx.php?page=medentry' class='css_button_small' onclick='top.restoreSession()' ><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES
) . "</span></a>\n";
125 echo "<a href='javascript:;' class='css_button_small' onclick='dopclick(0,\"" . htmlspecialchars($focustype,ENT_QUOTES
) . "\")'><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES
) . "</span></a>\n";
126 echo " <span class='title'>" . htmlspecialchars($disptype,ENT_NOQUOTES
) . "</span>\n";
127 echo " <table style='margin-bottom:1em;text-align:center'>";
130 <th
><?php
echo htmlspecialchars( xl('Title'), ENT_NOQUOTES
); ?
></th
>
131 <th
><?php
echo htmlspecialchars( xl('Begin'), ENT_NOQUOTES
); ?
></th
>
132 <th
><?php
echo htmlspecialchars( xl('End'), ENT_NOQUOTES
); ?
></th
>
133 <th
><?php
echo htmlspecialchars( xl('Diag'), ENT_NOQUOTES
); ?
></th
>
134 <th
><?php
echo htmlspecialchars(xl('Status'),ENT_NOQUOTES
); ?
></th
>
135 <th
><?php
echo htmlspecialchars( xl('Occurrence'), ENT_NOQUOTES
); ?
></th
>
136 <?php
if ($focustype == "allergy") { ?
>
137 <th
><?php
echo htmlspecialchars( xl('Reaction'), ENT_NOQUOTES
); ?
></th
>
139 <?php
if ($GLOBALS['athletic_team']) { ?
>
140 <th
><?php
echo htmlspecialchars( xl('Missed'), ENT_NOQUOTES
); ?
></th
>
142 <th
><?php
echo htmlspecialchars( xl('Referred By'), ENT_NOQUOTES
); ?
></th
>
144 <th
><?php
echo htmlspecialchars( xl('Comments'), ENT_NOQUOTES
); ?
></th
>
145 <th
><?php
echo htmlspecialchars( xl('Enc'), ENT_NOQUOTES
); ?
></th
>
150 $pres = sqlStatement("SELECT * FROM lists WHERE pid = ? AND type = ? " .
151 "ORDER BY begdate", array($pid,$focustype) );
153 // if no issues (will place a 'None' text vs. toggle algorithm here)
154 if (sqlNumRows($pres) < 1) {
155 if ( getListTouch($pid,$focustype) ) {
156 // Data entry has happened to this type, so can display an explicit None.
157 echo "<tr><td class='text'><b>" . htmlspecialchars( xl("None"), ENT_NOQUOTES
) . "</b></td></tr>";
160 // Data entry has not happened to this type, so can show the none selection option.
161 echo "<tr><td class='text'><input type='checkbox' class='noneCheck' name='" . htmlspecialchars($focustype,ENT_QUOTES
) . "' value='none' /><b>" . htmlspecialchars( xl("None"), ENT_NOQUOTES
) . "</b></td></tr>";
166 while ($row = sqlFetchArray($pres)) {
170 $disptitle = trim($row['title']) ?
$row['title'] : "[Missing Title]";
172 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
173 "list_id = ?", array($rowid) );
175 // encount is used to toggle the color of the table-row output below
177 $bgclass = (($encount & 1) ?
"bg1" : "bg2");
179 // look up the diag codes
181 if ($row['diagnosis'] != "") {
182 $diags = explode(";", $row['diagnosis']);
183 foreach ($diags as $diag) {
184 $codedesc = lookup_code_descriptions($diag);
185 $codetext .= htmlspecialchars($diag,ENT_NOQUOTES
) . " (" . htmlspecialchars($codedesc,ENT_NOQUOTES
) . ")<br>";
189 // calculate the status
190 if ($row['outcome'] == "1" && $row['enddate'] != NULL) {
192 $statusCompute = generate_display_field(array('data_type'=>'1','list_id'=>'outcome'), $row['outcome']);
194 else if($row['enddate'] == NULL) {
195 $statusCompute = htmlspecialchars( xl("Active") ,ENT_NOQUOTES
);
198 $statusCompute = htmlspecialchars( xl("Inactive") ,ENT_NOQUOTES
);
201 // output the TD row of info
202 if ($row['enddate'] == NULL) {
203 echo " <tr class='$bgclass detail statrow' style='color:red;font-weight:bold' id='$rowid'>\n";
206 echo " <tr class='$bgclass detail statrow' id='$rowid'>\n";
208 echo " <td style='text-align:left'>" . htmlspecialchars($disptitle,ENT_NOQUOTES
) . "</td>\n";
209 echo " <td>" . htmlspecialchars($row['begdate'],ENT_NOQUOTES
) . " </td>\n";
210 echo " <td>" . htmlspecialchars($row['enddate'],ENT_NOQUOTES
) . " </td>\n";
211 // both codetext and statusCompute have already been escaped above with htmlspecialchars)
212 echo " <td>" . $codetext . "</td>\n";
213 echo " <td>" . $statusCompute . " </td>\n";
214 echo " <td class='nowrap'>";
215 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
217 if ($focustype == "allergy") {
218 echo " <td>" . htmlspecialchars($row['reaction'],ENT_NOQUOTES
) . " </td>\n";
220 if ($GLOBALS['athletic_team']) {
221 echo " <td class='center'>" . $row['extrainfo'] . "</td>\n"; // games missed
224 echo " <td>" . htmlspecialchars($row['referredby'],ENT_NOQUOTES
) . "</td>\n";
226 echo " <td>" . htmlspecialchars($row['comments'],ENT_NOQUOTES
) . "</td>\n";
227 echo " <td id='e_$rowid' class='noclick center' title='" . htmlspecialchars( xl('View related encounters'), ENT_QUOTES
) . "'>";
228 echo " <input type='button' value='" . htmlspecialchars($ierow['count'],ENT_QUOTES
) . "' class='editenc' id='" . htmlspecialchars($rowid,ENT_QUOTES
) . "' />";
239 </div
> <!-- end patient_stats
-->
243 <script language
="javascript">
244 // jQuery stuff to make the page a little easier to use
246 $
(document
).ready(function(){
247 $
(".statrow").mouseover(function() { $
(this
).toggleClass("highlight"); });
248 $
(".statrow").mouseout(function() { $
(this
).toggleClass("highlight"); });
250 $
(".statrow").click(function() { dopclick(this
.id
,0); });
251 $
(".editenc").click(function(event
) { doeclick(this
.id
); event
.stopPropagation(); });
252 $
("#newencounter").click(function() { newEncounter(); });
253 $
("#history").click(function() { GotoHistory(); });
254 $
("#back").click(function() { GoBack(); });
256 $
(".noneCheck").click(function() {
257 top
.restoreSession();
258 $
.post( "../../../library/ajax/lists_touch.php", { type
: this
.name
, patient_id
: <?php
echo htmlspecialchars($pid,ENT_QUOTES
); ?
> });
263 var GotoHistory
= function() {
264 top
.restoreSession();
265 <?php
if ($GLOBALS['concurrent_layout']): ?
>
266 parent
.left_nav
.setRadio(window
.name
,'his');
267 location
.href
='../history/history_full.php';
269 location
.href
='../history/history_full.php';
273 var GoBack
= function () {
274 top
.restoreSession();
275 <?php
if ($GLOBALS['concurrent_layout']): ?
>
276 parent
.left_nav
.setRadio(window
.name
,'dem');
277 location
.href
='demographics.php';
279 location
.href
="patient_summary.php";