Clean up of Issues and made Issues compliant with NIST.
[openemr.git] / interface / patient_file / summary / stats_full.php
blob4480a94e6239ca7e0c1de7b78d5ccc23400f0a28
1 <?php
2 // Copyright (C) 2005-2009 Rod Roark <rod@sunsetsystems.com>
3 //
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.
9 require_once("../../globals.php");
10 require_once("$srcdir/lists.inc");
11 require_once("$srcdir/acl.inc");
12 require_once("../../../custom/code_types.inc.php");
13 require_once("$srcdir/options.inc.php");
15 // Check authorization.
16 $thisauth = acl_check('patients', 'med');
17 if ($thisauth) {
18 $tmp = getPatientData($pid, "squad");
19 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
20 $thisauth = 0;
22 if (!$thisauth) die(xl('Not authorized'));
24 // get issues
25 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
26 "ORDER BY type, begdate");
28 <html>
30 <head>
31 <?php html_header_show();?>
33 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
35 <title><?php xl('Patient Issues','e'); ?></title>
37 <script type="text/javascript" src="../../../library/dialog.js"></script>
38 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
40 <script language="JavaScript">
42 // callback from add_edit_issue.php:
43 function refreshIssue(issue, title) {
44 top.restoreSession();
45 location.reload();
48 function dopclick(id) {
49 <?php if ($thisauth == 'write'): ?>
50 dlgopen('add_edit_issue.php?issue=' + id, '_blank', 550, 400);
51 <?php else: ?>
52 alert("<?php xl('You are not authorized to add/edit issues','e'); ?>");
53 <?php endif; ?>
56 // Process click on number of encounters.
57 function doeclick(id) {
58 dlgopen('../problem_encounter.php?issue=' + id, '_blank', 550, 400);
61 // Add Encounter button is clicked.
62 function newEncounter() {
63 var f = document.forms[0];
64 top.restoreSession();
65 <?php if ($GLOBALS['concurrent_layout']) { ?>
66 parent.left_nav.setRadio(window.name, 'nen');
67 location.href='../../forms/newpatient/new.php?autoloaded=1&calenc=';
68 <?php } else { ?>
69 top.Title.location.href='../encounter/encounter_title.php';
70 top.Main.location.href='../encounter/patient_encounter.php?mode=new';
71 <?php } ?>
74 </script>
76 </head>
78 <body class="body_top">
79 <div id='patient_stats'>
81 <form method='post' action='stats_full.php' onsubmit='return top.restoreSession()'>
83 <table>
85 <?php
86 $encount = 0;
87 $lasttype = "";
88 $first = 1; // flag for first section
89 $something = 0; // flag that there is data to show
90 // If empty
91 if (sqlNumRows($pres) < 1) {
92 echo "<b>" . htmlspecialchars( xl("No Issues"), ENT_NOQUOTES) . "</b><br>";
94 while ($row = sqlFetchArray($pres)) {
95 $something = 1;
96 if ($lasttype != $row['type']) {
97 $encount = 0;
98 $lasttype = $row['type'];
100 $disptype = $ISSUE_TYPES[$lasttype][0];
102 if ($first) {
103 $first = 0;
105 else {
106 echo "</table>";
109 echo " <b>$disptype</b>\n";
111 echo " <table style='margin-bottom:1em;text-align:center'>";
112 // Show header for each category
114 <tr class='head'>
115 <th><?php xl('Title','e'); ?></th>
116 <th><?php xl('Begin','e'); ?></th>
117 <th><?php xl('End','e'); ?></th>
118 <th><?php xl('Diag','e'); ?></th>
119 <th><?php echo htmlspecialchars(xl('Status'),ENT_NOQUOTES); ?></th>
120 <th><?php xl('Occurrence','e'); ?></th>
121 <?php if ($lasttype == "allergy") { ?>
122 <th><?php echo htmlspecialchars( xl('Reaction'), ENT_NOQUOTES); ?></th>
123 <?php } ?>
124 <?php if ($GLOBALS['athletic_team']) { ?>
125 <th><?php xl('Missed','e'); ?></th>
126 <?php } else { ?>
127 <th><?php xl('Referred By','e'); ?></th>
128 <?php } ?>
129 <th><?php xl('Comments','e'); ?></th>
130 <th><?php xl('Enc','e'); ?></th>
131 </tr>
132 <?php
136 $rowid = $row['id'];
138 $disptitle = trim($row['title']) ? $row['title'] : "[Missing Title]";
140 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
141 "list_id = $rowid");
143 // encount is used to toggle the color of the table-row output below
144 ++$encount;
145 $bgclass = (($encount & 1) ? "bg1" : "bg2");
147 // look up the diag codes
148 $codetext = "";
149 if ($row['diagnosis'] != "") {
150 $diags = explode(";", $row['diagnosis']);
151 foreach ($diags as $diag) {
152 $codedesc = lookup_code_descriptions($diag);
153 $codetext .= $diag." (".$codedesc.")<br>";
157 // calculate the status
158 if ($row['outcome'] == "1" && $row['enddate'] != NULL) {
159 // Resolved
160 $statusCompute = generate_display_field(array('data_type'=>'1','list_id'=>'outcome'), $row['outcome']);
162 else if($row['enddate'] == NULL) {
163 $statusCompute = xl("Active");
165 else {
166 $statusCompute = xl("Inactive");
169 // output the TD row of info
170 if ($row['enddate'] == NULL) {
171 echo " <tr class='$bgclass detail statrow' style='color:red;font-weight:bold' id='$rowid'>\n";
173 else {
174 echo " <tr class='$bgclass detail statrow' id='$rowid'>\n";
176 echo " <td style='text-align:left'>$disptitle</td>\n";
177 echo " <td>" . $row['begdate'] . "&nbsp;</td>\n";
178 echo " <td>" . $row['enddate'] . "&nbsp;</td>\n";
179 echo " <td>" . $codetext . "</td>\n";
180 echo " <td>" . htmlspecialchars($statusCompute,ENT_NOQUOTES) . "&nbsp;</td>\n";
181 echo " <td class='nowrap'>";
182 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
183 echo "</td>\n";
184 if ($lasttype == "allergy") {
185 echo " <td>" . htmlspecialchars($row['reaction'],ENT_NOQUOTES) . "&nbsp;</td>\n";
187 if ($GLOBALS['athletic_team']) {
188 echo " <td class='center'>" . $row['extrainfo'] . "</td>\n"; // games missed
190 else {
191 echo " <td>" . $row['referredby'] . "</td>\n";
193 echo " <td>" . $row['comments'] . "</td>\n";
194 echo " <td id='e_$rowid' class='noclick center' title='" . xl('View related encounters') . "'>";
195 echo " <input type='button' value='" . $ierow['count'] . "' class='editenc' id='".$rowid."' />";
196 echo " </td>";
197 echo " </tr>\n";
199 if ($something) echo "</table>";
202 </table>
204 <div style="text-align:center" class="buttons">
206 <input type='button' value='<?php xl('Add Issue','e'); ?>' id='addissue' class='btn' /> &nbsp;
207 <input type='button' value='<?php xl('Add Encounter','e'); ?>' id='newencounter' class='btn' /> &nbsp;
208 <input type='button' value='<?php xl('To History','e'); ?>' id='history' class='btn' /> &nbsp;
209 <input type='button' value='<?php xl('Back','e'); ?>' id='back' class='btn' />
210 </p>
211 </div>
213 </form>
214 </div> <!-- end patient_stats -->
216 </body>
218 <script language="javascript">
219 // jQuery stuff to make the page a little easier to use
221 $(document).ready(function(){
222 $(".statrow").mouseover(function() { $(this).toggleClass("highlight"); });
223 $(".statrow").mouseout(function() { $(this).toggleClass("highlight"); });
225 $(".statrow").click(function() { dopclick(this.id); });
226 $(".editenc").click(function(event) { doeclick(this.id); event.stopPropagation(); });
227 $("#addissue").click(function() { dopclick(0); });
228 $("#newencounter").click(function() { newEncounter(); });
229 $("#history").click(function() { GotoHistory(); });
230 $("#back").click(function() { GoBack(); });
233 var GotoHistory = function() {
234 top.restoreSession();
235 <?php if ($GLOBALS['concurrent_layout']): ?>
236 parent.left_nav.setRadio(window.name,'his');
237 location.href='../history/history_full.php';
238 <?php else: ?>
239 location.href='../history/history_full.php';
240 <?php endif; ?>
243 var GoBack = function () {
244 top.restoreSession();
245 <?php if ($GLOBALS['concurrent_layout']): ?>
246 parent.left_nav.setRadio(window.name,'dem');
247 location.href='demographics.php';
248 <?php else: ?>
249 location.href="patient_summary.php";
250 <?php endif; ?>
253 </script>
255 </html>