3 * Copyright (C) 2005-2009 Rod Roark <rod@sunsetsystems.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
11 //SANITIZE ALL ESCAPES
12 $sanitize_all_escapes=true;
15 //STOP FAKE REGISTER GLOBALS
16 $fake_register_globals=false;
19 require_once('../../globals.php');
20 require_once($GLOBALS['srcdir'].'/lists.inc');
21 require_once($GLOBALS['srcdir'].'/acl.inc');
22 require_once($GLOBALS['fileroot'].'/custom/code_types.inc.php');
23 require_once($GLOBALS['srcdir'].'/options.inc.php');
25 // Check authorization.
26 if (acl_check('patients','med')) {
27 $tmp = getPatientData($pid, "squad");
28 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
29 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES
) );
32 die(htmlspecialchars( xl('Not authorized'), ENT_NOQUOTES
) );
35 // Collect parameter(s)
36 $category = empty($_REQUEST['category']) ?
'' : $_REQUEST['category'];
42 <?php
html_header_show();?
>
44 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
46 <title
><?php
echo htmlspecialchars( xl('Patient Issues'), ENT_NOQUOTES
) ; ?
></title
>
48 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js"></script
>
49 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot']; ?>/library/js/jquery.js"></script
>
51 <script language
="JavaScript">
53 // callback from add_edit_issue.php:
54 function refreshIssue(issue
, title
) {
59 function dopclick(id
,category
) {
60 <?php
if (acl_check('patients','med','','write')): ?
>
61 if (category
== 0) category
= '';
62 dlgopen('add_edit_issue.php?issue=' +
encodeURIComponent(id
) +
'&thistype=' +
encodeURIComponent(category
), '_blank', 550, 400);
64 alert("<?php echo addslashes( xl('You are not authorized to add/edit issues') ); ?>");
68 // Process click on number of encounters.
69 function doeclick(id
) {
70 dlgopen('../problem_encounter.php?issue=' + id
, '_blank', 550, 400);
73 // Add Encounter button is clicked.
74 function newEncounter() {
75 var f
= document
.forms
[0];
77 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
78 parent
.left_nav
.setRadio(window
.name
, 'nen');
79 location
.href
='../../forms/newpatient/new.php?autoloaded=1&calenc=';
81 top
.Title
.location
.href
='../encounter/encounter_title.php';
82 top
.Main
.location
.href
='../encounter/patient_encounter.php?mode=new';
90 <body
class="body_top">
93 <div style
="text-align:center" class="buttons">
94 <a href
='javascript:;' class='css_button' id
='back'><span
><?php
echo htmlspecialchars( xl('Back'), ENT_NOQUOTES
); ?
></span
></a
>
99 <div id
='patient_stats'>
101 <form method
='post' action
='stats_full.php' onsubmit
='return top.restoreSession()'>
108 $first = 1; // flag for first section
109 foreach ($ISSUE_TYPES as $focustype => $focustitles) {
112 // Only show this category
113 if ($focustype != $category) continue;
124 $disptype = $focustitles[0];
125 if(($focustype=='allergy' ||
$focustype=='medication') && $GLOBALS['erx_enable'])
126 echo "<a href='../../eRx.php?page=medentry' class='css_button_small' onclick='top.restoreSession()' ><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES
) . "</span></a>\n";
128 echo "<a href='javascript:;' class='css_button_small' onclick='dopclick(0,\"" . htmlspecialchars($focustype,ENT_QUOTES
) . "\")'><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES
) . "</span></a>\n";
129 echo " <span class='title'>" . htmlspecialchars($disptype,ENT_NOQUOTES
) . "</span>\n";
130 echo " <table style='margin-bottom:1em;text-align:center'>";
133 <th
><?php
echo htmlspecialchars( xl('Title'), ENT_NOQUOTES
); ?
></th
>
134 <th
><?php
echo htmlspecialchars( xl('Begin'), ENT_NOQUOTES
); ?
></th
>
135 <th
><?php
echo htmlspecialchars( xl('End'), ENT_NOQUOTES
); ?
></th
>
136 <th
><?php
echo htmlspecialchars( xl('Diag'), ENT_NOQUOTES
); ?
></th
>
137 <th
><?php
echo htmlspecialchars(xl('Status'),ENT_NOQUOTES
); ?
></th
>
138 <th
><?php
echo htmlspecialchars( xl('Occurrence'), ENT_NOQUOTES
); ?
></th
>
139 <?php
if ($focustype == "allergy") { ?
>
140 <th
><?php
echo htmlspecialchars( xl('Reaction'), ENT_NOQUOTES
); ?
></th
>
142 <?php
if ($GLOBALS['athletic_team']) { ?
>
143 <th
><?php
echo htmlspecialchars( xl('Missed'), ENT_NOQUOTES
); ?
></th
>
145 <th
><?php
echo htmlspecialchars( xl('Referred By'), ENT_NOQUOTES
); ?
></th
>
147 <th
><?php
echo htmlspecialchars( xl('Comments'), ENT_NOQUOTES
); ?
></th
>
148 <th
><?php
echo htmlspecialchars( xl('Enc'), ENT_NOQUOTES
); ?
></th
>
154 if($GLOBALS['erx_enable'] && $GLOBALS['erx_medication_display'] && $focustype=='medication')
155 $condition .= "and erx_uploaded != '1' ";
156 $pres = sqlStatement("SELECT * FROM lists WHERE pid = ? AND type = ? $condition" .
157 "ORDER BY begdate", array($pid,$focustype) );
159 // if no issues (will place a 'None' text vs. toggle algorithm here)
160 if (sqlNumRows($pres) < 1) {
161 if ( getListTouch($pid,$focustype) ) {
162 // Data entry has happened to this type, so can display an explicit None.
163 echo "<tr><td class='text'><b>" . htmlspecialchars( xl("None"), ENT_NOQUOTES
) . "</b></td></tr>";
166 // Data entry has not happened to this type, so can show the none selection option.
167 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>";
172 while ($row = sqlFetchArray($pres)) {
176 $disptitle = trim($row['title']) ?
$row['title'] : "[Missing Title]";
178 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
179 "list_id = ?", array($rowid) );
181 // encount is used to toggle the color of the table-row output below
183 $bgclass = (($encount & 1) ?
"bg1" : "bg2");
185 // look up the diag codes
187 if ($row['diagnosis'] != "") {
188 $diags = explode(";", $row['diagnosis']);
189 foreach ($diags as $diag) {
190 $codedesc = lookup_code_descriptions($diag);
191 $codetext .= htmlspecialchars($diag,ENT_NOQUOTES
) . " (" . htmlspecialchars($codedesc,ENT_NOQUOTES
) . ")<br>";
195 // calculate the status
196 if ($row['outcome'] == "1" && $row['enddate'] != NULL) {
198 $statusCompute = generate_display_field(array('data_type'=>'1','list_id'=>'outcome'), $row['outcome']);
200 else if($row['enddate'] == NULL) {
201 $statusCompute = htmlspecialchars( xl("Active") ,ENT_NOQUOTES
);
204 $statusCompute = htmlspecialchars( xl("Inactive") ,ENT_NOQUOTES
);
206 $click_class='statrow';
207 if($row['erx_source']==1 && $focustype=='allergy')
209 elseif($row['erx_uploaded']==1 && $focustype=='medication')
211 // output the TD row of info
212 if ($row['enddate'] == NULL) {
213 echo " <tr class='$bgclass detail $click_class' style='color:red;font-weight:bold' id='$rowid'>\n";
216 echo " <tr class='$bgclass detail $click_class' id='$rowid'>\n";
218 echo " <td style='text-align:left'>" . htmlspecialchars($disptitle,ENT_NOQUOTES
) . "</td>\n";
219 echo " <td>" . htmlspecialchars($row['begdate'],ENT_NOQUOTES
) . " </td>\n";
220 echo " <td>" . htmlspecialchars($row['enddate'],ENT_NOQUOTES
) . " </td>\n";
221 // both codetext and statusCompute have already been escaped above with htmlspecialchars)
222 echo " <td>" . $codetext . "</td>\n";
223 echo " <td>" . $statusCompute . " </td>\n";
224 echo " <td class='nowrap'>";
225 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
227 if ($focustype == "allergy") {
228 echo " <td>" . htmlspecialchars($row['reaction'],ENT_NOQUOTES
) . " </td>\n";
230 if ($GLOBALS['athletic_team']) {
231 echo " <td class='center'>" . $row['extrainfo'] . "</td>\n"; // games missed
234 echo " <td>" . htmlspecialchars($row['referredby'],ENT_NOQUOTES
) . "</td>\n";
236 echo " <td>" . htmlspecialchars($row['comments'],ENT_NOQUOTES
) . "</td>\n";
237 echo " <td id='e_$rowid' class='noclick center' title='" . htmlspecialchars( xl('View related encounters'), ENT_QUOTES
) . "'>";
238 echo " <input type='button' value='" . htmlspecialchars($ierow['count'],ENT_QUOTES
) . "' class='editenc' id='" . htmlspecialchars($rowid,ENT_QUOTES
) . "' />";
249 </div
> <!-- end patient_stats
-->
253 <script language
="javascript">
254 // jQuery stuff to make the page a little easier to use
256 $
(document
).ready(function(){
257 $
(".statrow").mouseover(function() { $
(this
).toggleClass("highlight"); });
258 $
(".statrow").mouseout(function() { $
(this
).toggleClass("highlight"); });
260 $
(".statrow").click(function() { dopclick(this
.id
,0); });
261 $
(".editenc").click(function(event
) { doeclick(this
.id
); event
.stopPropagation(); });
262 $
("#newencounter").click(function() { newEncounter(); });
263 $
("#history").click(function() { GotoHistory(); });
264 $
("#back").click(function() { GoBack(); });
266 $
(".noneCheck").click(function() {
267 top
.restoreSession();
268 $
.post( "../../../library/ajax/lists_touch.php", { type
: this
.name
, patient_id
: <?php
echo htmlspecialchars($pid,ENT_QUOTES
); ?
> });
273 var GotoHistory
= function() {
274 top
.restoreSession();
275 <?php
if ($GLOBALS['concurrent_layout']): ?
>
276 parent
.left_nav
.setRadio(window
.name
,'his');
277 location
.href
='../history/history_full.php';
279 location
.href
='../history/history_full.php';
283 var GoBack
= function () {
284 top
.restoreSession();
285 <?php
if ($GLOBALS['concurrent_layout']): ?
>
286 parent
.left_nav
.setRadio(window
.name
,'dem');
287 location
.href
='demographics.php';
289 location
.href
="patient_summary.php";