revert changes and re-think
[openemr.git] / interface / patient_file / summary / stats_full.php
blob88be668eb0e38d7d40165d3b7613c1ca786fac9e
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>
84 <tr class='head'>
85 <th><?php xl('Type','e'); ?></th>
86 <th><?php xl('Title','e'); ?></th>
87 <th><?php xl('Begin','e'); ?></th>
88 <th><?php xl('End','e'); ?></th>
89 <th><?php xl('Diag','e'); ?></th>
90 <th><?php xl('Occurrence','e'); ?></th>
91 <?php if ($GLOBALS['athletic_team']) { ?>
92 <th><?php xl('Missed','e'); ?></th>
93 <?php } else { ?>
94 <th><?php xl('Referred By','e'); ?></th>
95 <?php } ?>
96 <th><?php xl('Comments','e'); ?></th>
97 <th><?php xl('Enc','e'); ?></th>
98 </tr>
100 <?php
101 $encount = 0;
102 $lasttype = "";
103 while ($row = sqlFetchArray($pres)) {
104 if ($lasttype != $row['type']) {
105 $encount = 0;
106 $lasttype = $row['type'];
108 /****
109 $disptype = $lasttype;
110 switch ($lasttype) {
111 case "allergy" : $disptype = "Allergies" ; break;
112 case "problem" :
113 case "medical_problem": $disptype = "Medical Problems"; break;
114 case "medication" : $disptype = "Medications" ; break;
115 case "surgery" : $disptype = "Surgeries" ; break;
117 ****/
118 $disptype = $ISSUE_TYPES[$lasttype][0];
120 echo " <tr class='detail'>\n";
121 echo " <td class='typehead' colspan='9'><b>$disptype</b></td>\n";
122 echo " </tr>\n";
125 $rowid = $row['id'];
127 $disptitle = trim($row['title']) ? $row['title'] : "[Missing Title]";
129 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
130 "list_id = $rowid");
132 // encount is used to toggle the color of the table-row output below
133 ++$encount;
134 $bgclass = (($encount & 1) ? "bg1" : "bg2");
136 // look up the diag codes
137 $codetext = "";
138 if ($row['diagnosis'] != "") {
139 $diags = explode(";", $row['diagnosis']);
140 foreach ($diags as $diag) {
141 $codedesc = lookup_code_descriptions($diag);
142 $codetext .= $diag." (".$codedesc.")<br>";
146 // output the TD row of info
147 echo " <tr class='$bgclass detail statrow' id='$rowid'>\n";
148 echo " <td>&nbsp;</td>\n";
149 echo " <td>$disptitle</td>\n";
150 echo " <td>" . $row['begdate'] . "&nbsp;</td>\n";
151 echo " <td>" . $row['enddate'] . "&nbsp;</td>\n";
152 echo " <td>" . $codetext . "</td>\n";
153 echo " <td class='nowrap'>";
154 echo generate_display_field(array('data_type'=>'1','list_id'=>'occurrence'), $row['occurrence']);
155 echo "</td>\n";
156 if ($GLOBALS['athletic_team']) {
157 echo " <td class='center'>" . $row['extrainfo'] . "</td>\n"; // games missed
159 else {
160 echo " <td>" . $row['referredby'] . "</td>\n";
162 echo " <td>" . $row['comments'] . "</td>\n";
163 echo " <td id='e_$rowid' class='noclick center' title='" . xl('View related encounters') . "'>";
164 echo " <input type='button' value='" . $ierow['count'] . "' class='editenc' id='".$rowid."' />";
165 echo " </td>";
166 echo " </tr>\n";
169 </table>
171 <div style="text-align:center" class="buttons">
173 <input type='button' value='<?php xl('Add Issue','e'); ?>' id='addissue' class='btn' /> &nbsp;
174 <input type='button' value='<?php xl('Add Encounter','e'); ?>' id='newencounter' class='btn' /> &nbsp;
175 <input type='button' value='<?php xl('To History','e'); ?>' id='history' class='btn' /> &nbsp;
176 <input type='button' value='<?php xl('Back','e'); ?>' id='back' class='btn' />
177 </p>
178 </div>
180 </form>
181 </div> <!-- end patient_stats -->
183 </body>
185 <script language="javascript">
186 // jQuery stuff to make the page a little easier to use
188 $(document).ready(function(){
189 $(".statrow").mouseover(function() { $(this).toggleClass("highlight"); });
190 $(".statrow").mouseout(function() { $(this).toggleClass("highlight"); });
192 $(".statrow").click(function() { dopclick(this.id); });
193 $(".editenc").click(function(event) { doeclick(this.id); event.stopPropagation(); });
194 $("#addissue").click(function() { dopclick(0); });
195 $("#newencounter").click(function() { newEncounter(); });
196 $("#history").click(function() { GotoHistory(); });
197 $("#back").click(function() { GoBack(); });
200 var GotoHistory = function() {
201 top.restoreSession();
202 <?php if ($GLOBALS['concurrent_layout']): ?>
203 parent.left_nav.setRadio(window.name,'his');
204 location.href='../history/history_full.php';
205 <?php else: ?>
206 location.href='../history/history_full.php';
207 <?php endif; ?>
210 var GoBack = function () {
211 top.restoreSession();
212 <?php if ($GLOBALS['concurrent_layout']): ?>
213 parent.left_nav.setRadio(window.name,'dem');
214 location.href='demographics.php';
215 <?php else: ?>
216 location.href="patient_summary.php";
217 <?php endif; ?>
220 </script>
222 </html>