restored display of the number of related encounters
[openemr.git] / interface / patient_file / summary / stats_full.php
blob63c4c9ca973e57fcb4b35b123baaeaa2909f4904
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");
14 // Check authorization.
15 $thisauth = acl_check('patients', 'med');
16 if ($thisauth) {
17 $tmp = getPatientData($pid, "squad");
18 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
19 $thisauth = 0;
21 if (!$thisauth) die("Not authorized.");
23 // get issues
24 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
25 "ORDER BY type, begdate");
27 <html>
29 <head>
30 <?php html_header_show();?>
32 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
34 <title><?php xl('Patient Issues','e'); ?></title>
36 <script type="text/javascript" src="../../../library/dialog.js"></script>
37 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
39 <script language="JavaScript">
41 // callback from add_edit_issue.php:
42 function refreshIssue(issue, title) {
43 top.restoreSession();
44 location.reload();
47 function dopclick(id) {
48 <?php if ($thisauth == 'write'): ?>
49 dlgopen('add_edit_issue.php?issue=' + id, '_blank', 550, 400);
50 <?php else: ?>
51 alert("You are not authorized to add/edit issues");
52 <?php endif; ?>
55 // Process click on number of encounters.
56 function doeclick(id) {
57 dlgopen('../problem_encounter.php?issue=' + id, '_blank', 550, 400);
60 // Add Encounter button is clicked.
61 function newEncounter() {
62 var f = document.forms[0];
63 top.restoreSession();
64 <?php if ($GLOBALS['concurrent_layout']) { ?>
65 parent.left_nav.setRadio(window.name, 'nen');
66 location.href='../../forms/newpatient/new.php?autoloaded=1&calenc=';
67 <?php } else { ?>
68 top.Title.location.href='../encounter/encounter_title.php';
69 top.Main.location.href='../encounter/patient_encounter.php?mode=new';
70 <?php } ?>
73 </script>
75 </head>
77 <body class="body_top">
78 <div id='patient_stats'>
80 <form method='post' action='stats_full.php' onsubmit='return top.restoreSession()'>
82 <table>
83 <tr class='head'>
84 <th><?php xl('Type','e'); ?></th>
85 <th><?php xl('Title','e'); ?></th>
86 <th><?php xl('Begin','e'); ?></th>
87 <th><?php xl('End','e'); ?></th>
88 <th><?php xl('Diag','e'); ?></th>
89 <th><?php xl('Occurrence','e'); ?></th>
90 <?php if ($GLOBALS['athletic_team']) { ?>
91 <th><?php xl('Missed','e'); ?></th>
92 <?php } else { ?>
93 <th><?php xl('Referred By','e'); ?></th>
94 <?php } ?>
95 <th><?php xl('Comments','e'); ?></th>
96 <th><?php xl('Enc','e'); ?></th>
97 </tr>
99 <?php
100 $encount = 0;
101 $lasttype = "";
102 while ($row = sqlFetchArray($pres)) {
103 if ($lasttype != $row['type']) {
104 $encount = 0;
105 $lasttype = $row['type'];
107 /****
108 $disptype = $lasttype;
109 switch ($lasttype) {
110 case "allergy" : $disptype = "Allergies" ; break;
111 case "problem" :
112 case "medical_problem": $disptype = "Medical Problems"; break;
113 case "medication" : $disptype = "Medications" ; break;
114 case "surgery" : $disptype = "Surgeries" ; break;
116 ****/
117 $disptype = $ISSUE_TYPES[$lasttype][0];
119 echo " <tr class='detail'>\n";
120 echo " <td class='typehead' colspan='9'><b>$disptype</b></td>\n";
121 echo " </tr>\n";
124 $rowid = $row['id'];
126 $disptitle = trim($row['title']) ? $row['title'] : "[Missing Title]";
128 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
129 "list_id = $rowid");
131 // encount is used to toggle the color of the table-row output below
132 ++$encount;
133 $bgclass = (($encount & 1) ? "bg1" : "bg2");
135 // look up the diag codes
136 $codetext = "";
137 if ($row['diagnosis'] != "") {
138 $diags = explode(";", $row['diagnosis']);
139 foreach ($diags as $diag) {
140 $codedesc = lookup_code_descriptions($diag);
141 $codetext .= $diag." (".$codedesc.")<br>";
145 // output the TD row of info
146 echo " <tr class='$bgclass detail statrow' id='$rowid'>\n";
147 echo " <td>&nbsp;</td>\n";
148 echo " <td>$disptitle</td>\n";
149 echo " <td>" . $row['begdate'] . "&nbsp;</td>\n";
150 echo " <td>" . $row['enddate'] . "&nbsp;</td>\n";
151 echo " <td>" . $codetext . "</td>\n";
152 echo " <td class='nowrap'>" . $ISSUE_OCCURRENCES[$row['occurrence']] . "</td>\n";
153 if ($GLOBALS['athletic_team']) {
154 echo " <td class='center'>" . $row['extrainfo'] . "</td>\n"; // games missed
156 else {
157 echo " <td>" . $row['referredby'] . "</td>\n";
159 echo " <td>" . $row['comments'] . "</td>\n";
160 echo " <td id='e_$rowid' class='noclick center' title='View related encounters'>";
161 echo " <input type='button' value='" . $ierow['count'] . "' class='editenc' id='".$rowid."' />";
162 echo " </td>";
163 echo " </tr>\n";
166 </table>
168 <div style="text-align:center" class="buttons">
170 <input type='button' value='<?php xl('Add Issue','e'); ?>' id='addissue' class='btn' /> &nbsp;
171 <input type='button' value='<?php xl('Add Encounter','e'); ?>' id='newencounter' class='btn' /> &nbsp;
172 <input type='button' value='<?php xl('To History','e'); ?>' id='history' class='btn' /> &nbsp;
173 <input type='button' value='<?php xl('Back','e'); ?>' id='back' class='btn' />
174 </p>
175 </div>
177 </form>
178 </div> <!-- end patient_stats -->
180 </body>
182 <script language="javascript">
183 // jQuery stuff to make the page a little easier to use
185 $(document).ready(function(){
186 $(".statrow").mouseover(function() { $(this).toggleClass("highlight"); });
187 $(".statrow").mouseout(function() { $(this).toggleClass("highlight"); });
189 $(".statrow").click(function() { dopclick(this.id); });
190 $(".editenc").click(function(event) { doeclick(this.id); event.stopPropagation(); });
191 $("#addissue").click(function() { dopclick(0); });
192 $("#newencounter").click(function() { newEncounter(); });
193 $("#history").click(function() { GotoHistory(); });
194 $("#back").click(function() { GoBack(); });
197 var GotoHistory = function() {
198 top.restoreSession();
199 <?php if ($GLOBALS['concurrent_layout']): ?>
200 parent.left_nav.setRadio(window.name,'his');
201 location.href='../history/history_full.php';
202 <?php else: ?>
203 location.href='../history/history_full.php';
204 <?php endif; ?>
207 var GoBack = function () {
208 top.restoreSession();
209 <?php if ($GLOBALS['concurrent_layout']): ?>
210 <?php if( $GLOBALS['dutchpc'] ): ?>
211 parent.left_nav.setRadio(window.name,'dem');
212 location.href='demographics_dutch.php';
213 <?php else: ?>
214 parent.left_nav.setRadio(window.name,'dem');
215 location.href='demographics.php';
216 <?php endif; ?>
217 <?php else: ?>
218 location.href="patient_summary.php";
219 <?php endif; ?>
222 </script>
224 </html>