3 * Copyright (C) 2005-2014 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'];
38 // Get patient's preferred language for the patient education URL.
39 $tmp = getPatientData($pid, 'language');
40 $language = $tmp['language'];
45 <?php
html_header_show();?
>
47 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
49 <title
><?php
echo xlt('Patient Issues'); ?
></title
>
51 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js"></script
>
52 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script
>
54 <script language
="JavaScript">
56 // callback from add_edit_issue.php:
57 function refreshIssue(issue
, title
) {
62 function dopclick(id
,category
) {
63 <?php
if (acl_check('patients','med','','write')): ?
>
65 if (category
== 0) category
= '';
66 dlgopen('add_edit_issue.php?issue=' +
encodeURIComponent(id
) +
'&thistype=' +
encodeURIComponent(category
), '_blank', 550, 400);
68 alert("<?php echo addslashes( xl('You are not authorized to add/edit issues') ); ?>");
72 // Process click on number of encounters.
73 function doeclick(id
) {
75 dlgopen('../problem_encounter.php?issue=' + id
, '_blank', 550, 400);
78 // Process click on diagnosis for patient education popup.
79 function educlick(codetype
, codevalue
) {
81 dlgopen('../education.php?type=' +
encodeURIComponent(codetype
) +
82 '&code=' +
encodeURIComponent(codevalue
) +
83 '&language=<?php echo urlencode($language); ?>',
84 '_blank', 1024, 750,true); // Force a new window instead of iframe to address cross site scripting potential
87 // Add Encounter button is clicked.
88 function newEncounter() {
89 var f
= document
.forms
[0];
91 location
.href
='../../forms/newpatient/new.php?autoloaded=1&calenc=';
98 <body
class="body_top">
101 <div style
="text-align:center" class="buttons">
102 <a href
='javascript:;' class='css_button' id
='back'><span
><?php
echo htmlspecialchars( xl('Back'), ENT_NOQUOTES
); ?
></span
></a
>
107 <div id
='patient_stats'>
109 <form method
='post' action
='stats_full.php' onsubmit
='return top.restoreSession()'>
116 $first = 1; // flag for first section
117 foreach ($ISSUE_TYPES as $focustype => $focustitles) {
120 // Only show this category
121 if ($focustype != $category) continue;
132 $disptype = $focustitles[0];
133 if(($focustype=='allergy' ||
$focustype=='medication') && $GLOBALS['erx_enable'])
134 echo "<a href='../../eRx.php?page=medentry' class='css_button_small' onclick='top.restoreSession()' ><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES
) . "</span></a>\n";
136 echo "<a href='javascript:;' class='css_button_small' onclick='dopclick(0,\"" . htmlspecialchars($focustype,ENT_QUOTES
) . "\")'><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES
) . "</span></a>\n";
137 echo " <span class='title'>" . htmlspecialchars($disptype,ENT_NOQUOTES
) . "</span>\n";
138 // echo " <table style='margin-bottom:1em;text-align:center'>";
139 echo " <table style='margin-bottom:1em;'>";
142 <th style
='text-align:left'><?php
echo xlt('Title'); ?
></th
>
143 <th style
='text-align:left'><?php
echo xlt('Begin'); ?
></th
>
144 <th style
='text-align:left'><?php
echo xlt('End'); ?
></th
>
145 <th style
='text-align:left'><?php
echo xlt('Coding (click for education)'); ?
></th
>
146 <th style
='text-align:left'><?php
echo xlt('Status'); ?
></th
>
147 <th style
='text-align:left'><?php
echo xlt('Occurrence'); ?
></th
>
148 <?php
if ($focustype == "allergy") { ?
>
149 <th style
='text-align:left'><?php
echo xlt('Reaction'); ?
></th
>
151 <th style
='text-align:left'><?php
echo xlt('Referred By'); ?
></th
>
152 <th style
='text-align:left'><?php
echo xlt('Modify Date'); ?
></th
>
153 <th style
='text-align:left'><?php
echo xlt('Comments'); ?
></th
>
154 <th
><?php
echo xlt('Enc'); ?
></th
>
160 if($GLOBALS['erx_enable'] && $GLOBALS['erx_medication_display'] && $focustype=='medication')
161 $condition .= "and erx_uploaded != '1' ";
162 $pres = sqlStatement("SELECT * FROM lists WHERE pid = ? AND type = ? $condition" .
163 "ORDER BY begdate", array($pid,$focustype) );
165 // if no issues (will place a 'None' text vs. toggle algorithm here)
166 if (sqlNumRows($pres) < 1) {
167 if ( getListTouch($pid,$focustype) ) {
168 // Data entry has happened to this type, so can display an explicit None.
169 echo "<tr><td class='text'><b>" . xlt("None") . "</b></td></tr>";
172 // Data entry has not happened to this type, so can show the none selection option.
173 echo "<tr><td class='text'><input type='checkbox' class='noneCheck' name='" .
174 attr($focustype) . "' value='none' /><b>" . xlt("None") . "</b></td></tr>";
179 while ($row = sqlFetchArray($pres)) {
183 $disptitle = trim($row['title']) ?
$row['title'] : "[Missing Title]";
185 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
186 "list_id = ?", array($rowid) );
188 // encount is used to toggle the color of the table-row output below
190 $bgclass = (($encount & 1) ?
"bg1" : "bg2");
192 $colorstyle = empty($row['enddate']) ?
"style='color:red'" : "";
194 // look up the diag codes
196 if ($row['diagnosis'] != "") {
197 $diags = explode(";", $row['diagnosis']);
198 foreach ($diags as $diag) {
199 $codedesc = lookup_code_descriptions($diag);
200 list($codetype, $code) = explode(':', $diag);
201 if ($codetext) $codetext .= "<br />";
202 $codetext .= "<a href='javascript:educlick(\"$codetype\",\"$code\")' $colorstyle>" .
203 text($diag . " (" . $codedesc . ")") . "</a>";
207 // calculate the status
208 if ($row['outcome'] == "1" && $row['enddate'] != NULL) {
210 $statusCompute = generate_display_field(array('data_type'=>'1','list_id'=>'outcome'), $row['outcome']);
212 else if($row['enddate'] == NULL) {
213 $statusCompute = xlt("Active");
216 $statusCompute = xlt("Inactive");
218 $click_class='statrow';
219 if($row['erx_source']==1 && $focustype=='allergy') $click_class='';
220 elseif($row['erx_uploaded']==1 && $focustype=='medication') $click_class='';
222 echo " <tr class='$bgclass detail' $colorstyle>\n";
223 echo " <td style='text-align:left' class='$click_class' id='$rowid'>" . text($disptitle) . "</td>\n";
224 echo " <td>" . text($row['begdate']) . " </td>\n";
225 echo " <td>" . text($row['enddate']) . " </td>\n";
226 // both codetext and statusCompute have already been escaped above with htmlspecialchars)
227 echo " <td>" . $codetext . "</td>\n";
228 echo " <td>" . $statusCompute . " </td>\n";
229 echo " <td class='nowrap'>";
230 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
232 if ($focustype == "allergy") {
234 echo generate_display_field(array('data_type'=>'1','list_id'=>'reaction'), $row['reaction']);
237 echo " <td>" . text($row['referredby']) . "</td>\n";
238 echo " <td>" . text($row['modifydate']) . "</td>\n";
239 echo " <td>" . text($row['comments']) . "</td>\n";
240 echo " <td id='e_$rowid' class='noclick center' title='" . xla('View related encounters') . "'>";
241 echo " <input type='button' value='" . attr($ierow['count']) . "' class='editenc' id='" . attr($rowid) . "' />";
252 </div
> <!-- end patient_stats
-->
256 <script language
="javascript">
257 // jQuery stuff to make the page a little easier to use
259 $
(document
).ready(function(){
260 $
(".statrow").mouseover(function() { $
(this
).toggleClass("highlight"); });
261 $
(".statrow").mouseout(function() { $
(this
).toggleClass("highlight"); });
263 $
(".statrow").click(function() { dopclick(this
.id
,0); });
264 $
(".editenc").click(function(event
) { doeclick(this
.id
); });
265 $
("#newencounter").click(function() { newEncounter(); });
266 $
("#history").click(function() { GotoHistory(); });
267 $
("#back").click(function() { GoBack(); });
269 $
(".noneCheck").click(function() {
270 top
.restoreSession();
271 $
.post( "../../../library/ajax/lists_touch.php", { type
: this
.name
, patient_id
: <?php
echo htmlspecialchars($pid,ENT_QUOTES
); ?
> });
276 var GotoHistory
= function() {
277 top
.restoreSession();
278 location
.href
='../history/history_full.php';
281 var GoBack
= function () {
282 top
.restoreSession();
283 location
.href
='demographics.php';