Remove concurrent_layout and clarify layout and themes selections (#272)
[openemr.git] / interface / patient_file / summary / stats_full.php
blobd31e626653cc856fb8c3ba29ccdefdf5eb6c322a
1 <?php
2 /**
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.
9 */
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) );
31 else {
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'];
42 <html>
44 <head>
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) {
58 top.restoreSession();
59 location.reload();
62 function dopclick(id,category) {
63 <?php if (acl_check('patients','med','','write')): ?>
64 if (category == 0) category = '';
65 dlgopen('add_edit_issue.php?issue=' + encodeURIComponent(id) + '&thistype=' + encodeURIComponent(category), '_blank', 550, 400);
66 <?php else: ?>
67 alert("<?php echo addslashes( xl('You are not authorized to add/edit issues') ); ?>");
68 <?php endif; ?>
71 // Process click on number of encounters.
72 function doeclick(id) {
73 dlgopen('../problem_encounter.php?issue=' + id, '_blank', 550, 400);
76 // Process click on diagnosis for patient education popup.
77 function educlick(codetype, codevalue) {
78 dlgopen('../education.php?type=' + encodeURIComponent(codetype) +
79 '&code=' + encodeURIComponent(codevalue) +
80 '&language=<?php echo urlencode($language); ?>',
81 '_blank', 1024, 750,true); // Force a new window instead of iframe to address cross site scripting potential
84 // Add Encounter button is clicked.
85 function newEncounter() {
86 var f = document.forms[0];
87 top.restoreSession();
88 location.href='../../forms/newpatient/new.php?autoloaded=1&calenc=';
91 </script>
93 </head>
95 <body class="body_top">
97 <br>
98 <div style="text-align:center" class="buttons">
99 <a href='javascript:;' class='css_button' id='back'><span><?php echo htmlspecialchars( xl('Back'), ENT_NOQUOTES); ?></span></a>
100 </div>
101 <br>
102 <br>
104 <div id='patient_stats'>
106 <form method='post' action='stats_full.php' onsubmit='return top.restoreSession()'>
108 <table>
110 <?php
111 $encount = 0;
112 $lasttype = "";
113 $first = 1; // flag for first section
114 foreach ($ISSUE_TYPES as $focustype => $focustitles) {
116 if ($category) {
117 // Only show this category
118 if ($focustype != $category) continue;
121 if ($first) {
122 $first = 0;
124 else {
125 echo "</table>";
128 // Show header
129 $disptype = $focustitles[0];
130 if(($focustype=='allergy' || $focustype=='medication') && $GLOBALS['erx_enable'])
131 echo "<a href='../../eRx.php?page=medentry' class='css_button_small' onclick='top.restoreSession()' ><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES) . "</span></a>\n";
132 else
133 echo "<a href='javascript:;' class='css_button_small' onclick='dopclick(0,\"" . htmlspecialchars($focustype,ENT_QUOTES) . "\")'><span>" . htmlspecialchars( xl('Add'), ENT_NOQUOTES) . "</span></a>\n";
134 echo " <span class='title'>" . htmlspecialchars($disptype,ENT_NOQUOTES) . "</span>\n";
135 // echo " <table style='margin-bottom:1em;text-align:center'>";
136 echo " <table style='margin-bottom:1em;'>";
138 <tr class='head'>
139 <th style='text-align:left'><?php echo xlt('Title'); ?></th>
140 <th style='text-align:left'><?php echo xlt('Begin'); ?></th>
141 <th style='text-align:left'><?php echo xlt('End'); ?></th>
142 <th style='text-align:left'><?php echo xlt('Coding (click for education)'); ?></th>
143 <th style='text-align:left'><?php echo xlt('Status'); ?></th>
144 <th style='text-align:left'><?php echo xlt('Occurrence'); ?></th>
145 <?php if ($focustype == "allergy") { ?>
146 <th style='text-align:left'><?php echo xlt('Reaction'); ?></th>
147 <?php } ?>
148 <th style='text-align:left'><?php echo xlt('Referred By'); ?></th>
149 <th style='text-align:left'><?php echo xlt('Modify Date'); ?></th>
150 <th style='text-align:left'><?php echo xlt('Comments'); ?></th>
151 <th><?php echo xlt('Enc'); ?></th>
152 </tr>
153 <?php
155 // collect issues
156 $condition = '';
157 if($GLOBALS['erx_enable'] && $GLOBALS['erx_medication_display'] && $focustype=='medication')
158 $condition .= "and erx_uploaded != '1' ";
159 $pres = sqlStatement("SELECT * FROM lists WHERE pid = ? AND type = ? $condition" .
160 "ORDER BY begdate", array($pid,$focustype) );
162 // if no issues (will place a 'None' text vs. toggle algorithm here)
163 if (sqlNumRows($pres) < 1) {
164 if ( getListTouch($pid,$focustype) ) {
165 // Data entry has happened to this type, so can display an explicit None.
166 echo "<tr><td class='text'><b>" . xlt("None") . "</b></td></tr>";
168 else {
169 // Data entry has not happened to this type, so can show the none selection option.
170 echo "<tr><td class='text'><input type='checkbox' class='noneCheck' name='" .
171 attr($focustype) . "' value='none' /><b>" . xlt("None") . "</b></td></tr>";
175 // display issues
176 while ($row = sqlFetchArray($pres)) {
178 $rowid = $row['id'];
180 $disptitle = trim($row['title']) ? $row['title'] : "[Missing Title]";
182 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
183 "list_id = ?", array($rowid) );
185 // encount is used to toggle the color of the table-row output below
186 ++$encount;
187 $bgclass = (($encount & 1) ? "bg1" : "bg2");
189 $colorstyle = empty($row['enddate']) ? "style='color:red'" : "";
191 // look up the diag codes
192 $codetext = "";
193 if ($row['diagnosis'] != "") {
194 $diags = explode(";", $row['diagnosis']);
195 foreach ($diags as $diag) {
196 $codedesc = lookup_code_descriptions($diag);
197 list($codetype, $code) = explode(':', $diag);
198 if ($codetext) $codetext .= "<br />";
199 $codetext .= "<a href='javascript:educlick(\"$codetype\",\"$code\")' $colorstyle>" .
200 text($diag . " (" . $codedesc . ")") . "</a>";
204 // calculate the status
205 if ($row['outcome'] == "1" && $row['enddate'] != NULL) {
206 // Resolved
207 $statusCompute = generate_display_field(array('data_type'=>'1','list_id'=>'outcome'), $row['outcome']);
209 else if($row['enddate'] == NULL) {
210 $statusCompute = xlt("Active");
212 else {
213 $statusCompute = xlt("Inactive");
215 $click_class='statrow';
216 if($row['erx_source']==1 && $focustype=='allergy') $click_class='';
217 elseif($row['erx_uploaded']==1 && $focustype=='medication') $click_class='';
219 echo " <tr class='$bgclass detail' $colorstyle>\n";
220 echo " <td style='text-align:left' class='$click_class' id='$rowid'>" . text($disptitle) . "</td>\n";
221 echo " <td>" . text($row['begdate']) . "&nbsp;</td>\n";
222 echo " <td>" . text($row['enddate']) . "&nbsp;</td>\n";
223 // both codetext and statusCompute have already been escaped above with htmlspecialchars)
224 echo " <td>" . $codetext . "</td>\n";
225 echo " <td>" . $statusCompute . "&nbsp;</td>\n";
226 echo " <td class='nowrap'>";
227 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
228 echo "</td>\n";
229 if ($focustype == "allergy") {
230 echo " <td>";
231 echo generate_display_field(array('data_type'=>'1','list_id'=>'reaction'), $row['reaction']);
232 echo "</td>\n";
234 echo " <td>" . text($row['referredby']) . "</td>\n";
235 echo " <td>" . text($row['modifydate']) . "</td>\n";
236 echo " <td>" . text($row['comments']) . "</td>\n";
237 echo " <td id='e_$rowid' class='noclick center' title='" . xla('View related encounters') . "'>";
238 echo " <input type='button' value='" . attr($ierow['count']) . "' class='editenc' id='" . attr($rowid) . "' />";
239 echo " </td>";
240 echo " </tr>\n";
243 echo "</table>";
246 </table>
248 </form>
249 </div> <!-- end patient_stats -->
251 </body>
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); });
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); ?> });
269 $(this).hide();
273 var GotoHistory = function() {
274 top.restoreSession();
275 location.href='../history/history_full.php';
278 var GoBack = function () {
279 top.restoreSession();
280 location.href='demographics.php';
283 </script>
285 </html>