fix to immun expiration date print on shot record
[openemr.git] / interface / patient_file / summary / stats_full.php
blob4a43f418581639c996cc55d062f653aafbc3aa11
1 <?php
2 /**
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.
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'];
39 <html>
41 <head>
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) {
55 top.restoreSession();
56 location.reload();
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);
63 <?php else: ?>
64 alert("<?php echo addslashes( xl('You are not authorized to add/edit issues') ); ?>");
65 <?php endif; ?>
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];
76 top.restoreSession();
77 <?php if ($GLOBALS['concurrent_layout']) { ?>
78 parent.left_nav.setRadio(window.name, 'nen');
79 location.href='../../forms/newpatient/new.php?autoloaded=1&calenc=';
80 <?php } else { ?>
81 top.Title.location.href='../encounter/encounter_title.php';
82 top.Main.location.href='../encounter/patient_encounter.php?mode=new';
83 <?php } ?>
86 </script>
88 </head>
90 <body class="body_top">
92 <br>
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>
95 </div>
96 <br>
97 <br>
99 <div id='patient_stats'>
101 <form method='post' action='stats_full.php' onsubmit='return top.restoreSession()'>
103 <table>
105 <?php
106 $encount = 0;
107 $lasttype = "";
108 $first = 1; // flag for first section
109 foreach ($ISSUE_TYPES as $focustype => $focustitles) {
111 if ($category) {
112 // Only show this category
113 if ($focustype != $category) continue;
116 if ($first) {
117 $first = 0;
119 else {
120 echo "</table>";
123 // Show header
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";
127 else
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'>";
132 <tr class='head'>
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>
141 <?php } ?>
142 <?php if ($GLOBALS['athletic_team']) { ?>
143 <th><?php echo htmlspecialchars( xl('Missed'), ENT_NOQUOTES); ?></th>
144 <?php } else { ?>
145 <th><?php echo htmlspecialchars( xl('Referred By'), ENT_NOQUOTES); ?></th>
146 <?php } ?>
147 <th><?php echo htmlspecialchars( xl('Comments'), ENT_NOQUOTES); ?></th>
148 <th><?php echo htmlspecialchars( xl('Enc'), ENT_NOQUOTES); ?></th>
149 </tr>
150 <?php
152 // collect issues
153 $condition = '';
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>";
165 else {
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>";
171 // display issues
172 while ($row = sqlFetchArray($pres)) {
174 $rowid = $row['id'];
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
182 ++$encount;
183 $bgclass = (($encount & 1) ? "bg1" : "bg2");
185 // look up the diag codes
186 $codetext = "";
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) {
197 // Resolved
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);
203 else {
204 $statusCompute = htmlspecialchars( xl("Inactive") ,ENT_NOQUOTES);
206 $click_class='statrow';
207 if($row['erx_source']==1 && $focustype=='allergy')
208 $click_class='';
209 elseif($row['erx_uploaded']==1 && $focustype=='medication')
210 $click_class='';
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";
215 else {
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) . "&nbsp;</td>\n";
220 echo " <td>" . htmlspecialchars($row['enddate'],ENT_NOQUOTES) . "&nbsp;</td>\n";
221 // both codetext and statusCompute have already been escaped above with htmlspecialchars)
222 echo " <td>" . $codetext . "</td>\n";
223 echo " <td>" . $statusCompute . "&nbsp;</td>\n";
224 echo " <td class='nowrap'>";
225 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
226 echo "</td>\n";
227 if ($focustype == "allergy") {
228 echo " <td>" . htmlspecialchars($row['reaction'],ENT_NOQUOTES) . "&nbsp;</td>\n";
230 if ($GLOBALS['athletic_team']) {
231 echo " <td class='center'>" . $row['extrainfo'] . "</td>\n"; // games missed
233 else {
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) . "' />";
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); 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); ?> });
269 $(this).hide();
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';
278 <?php else: ?>
279 location.href='../history/history_full.php';
280 <?php endif; ?>
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';
288 <?php else: ?>
289 location.href="patient_summary.php";
290 <?php endif; ?>
293 </script>
295 </html>