Apparently the mysqldump was not acceptable for import.
[openemr.git] / interface / patient_file / summary / stats.php
bloba57503663c6894b86d45ffd0a4f557b5d01fd590
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/lists.inc");
4 include_once("$srcdir/acl.inc");
6 // We used to present a more complex list for "medical problem" issues
7 // for athletic teams. However we decided in May 2008 to stop that.
8 // The logic remains in case minds are again changed. -- Rod
9 //
10 $fancy_stats = false; // $GLOBALS['athletic_team'];
12 <html>
14 <head>
15 <?php html_header_show();?>
16 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
17 <style>
18 .link {
19 font-family: sans-serif;
20 text-decoration: none;
21 /* color: #000000; */
22 font-size: 8pt;
24 </style>
25 </head>
27 <body class="body_bottom">
29 <div id="patient_stats_summary">
31 <?php
32 $thisauth = acl_check('patients', 'med');
33 if ($thisauth) {
34 $tmp = getPatientData($pid, "squad");
35 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
36 $thisauth = 0;
38 if (!$thisauth) {
39 echo "<p>(".xl('Issues not authorized').")</p>\n";
40 echo "</body>\n</html>\n";
41 exit();
45 <table id="patient_stats_issues">
47 <?php
48 $numcols = $fancy_stats ? '7' : '1';
49 $ix = 0;
50 foreach ($ISSUE_TYPES as $key => $arr) {
51 // $result = getListByType($pid, $key, "id,title,begdate,enddate,returndate,extrainfo", "all", "all", 0);
53 $query = "SELECT * FROM lists WHERE pid = $pid AND type = '$key' AND ";
54 if ($fancy_stats) {
55 $query .= "( enddate IS NULL OR returndate IS NULL ) ";
56 } else {
57 $query .= "enddate IS NULL ";
59 $query .= "ORDER BY begdate";
60 $pres = sqlStatement($query);
62 if (mysql_num_rows($pres) > 0 || $ix == 0) {
64 // output a header for the $ISSUE_TYPE
65 echo " <tr class='issuetitle'>\n";
66 echo " <td colspan='$numcols'>\n";
67 echo " <a href='stats_full.php?active=all' target='";
68 echo $GLOBALS['concurrent_layout'] ? "_parent" : "Main";
69 echo "' onclick='top.restoreSession()'><span class='title'>" .
70 $arr[0] . "</span> <span class='more'>$tmore</span></a>\n";
71 echo " </td>\n";
72 echo " </tr>\n";
74 // Show headers if this is a long line.
75 if ($fancy_stats && $arr[3] == 0 && mysql_num_rows($pres) > 0) {
76 echo " <tr class='issueheaders'>\n";
77 echo " <td>&nbsp;&nbsp;<b>" .xl('Title'). "</b></td>\n";
78 echo " <td>&nbsp;<b>" .xl('Diag'). "</b></td>\n";
79 echo " <td>&nbsp;<b>" .xl('Start'). "</b></td>\n";
80 echo " <td>&nbsp;<b>" .xl('Return'). "</b></td>\n";
81 echo " <td>&nbsp;<b>" .xl('Games'). "</b></td>\n";
82 echo " <td class='right'>&nbsp;<b>" .xl('Days'). "</b></td>\n";
83 echo " <td class='right'>&nbsp;<b>" .xl('Enc'). "</b></td>\n";
84 echo " </tr>\n";
87 while ($row = sqlFetchArray($pres)) {
88 // output each issue for the $ISSUE_TYPE
89 if (!$row['enddate'] && !$row['returndate'])
90 $rowclass="noend_noreturn";
91 else if (!$row['enddate'] && $row['returndate'])
92 $rowclass="noend";
93 else if ($row['enddate'] && !$row['returndate'])
94 $rowclass = "noreturn";
96 echo " <tr class='$rowclass;'>\n";
98 if ($fancy_stats && $arr[3] == 0) {
99 $endsecs = $row['returndate'] ? strtotime($row['returndate']) : time();
100 $daysmissed = round(($endsecs - strtotime($row['begdate'])) / (60 * 60 * 24));
101 $ierow = sqlQuery("SELECT count(*) AS count FROM issue_encounter " .
102 "WHERE list_id = '" . $row['id'] . "'");
103 // echo " <td><a class='link' target='Main' href='stats_full.php?active=1'>" .
104 // $row['title'] . "</a></td>\n";
105 echo " <td>&nbsp;&nbsp;" . $row['title'] . "</td>\n";
106 echo " <td>&nbsp;" . $row['diagnosis'] . "</td>\n";
107 echo " <td>&nbsp;" . $row['begdate'] . "</td>\n";
108 echo " <td>&nbsp;" . $row['returndate'] . "</td>\n";
109 echo " <td>&nbsp;" . $row['extrainfo'] . "</td>\n";
110 echo " <td class='right'>&nbsp;$daysmissed</td>\n";
111 echo " <td class='right'>&nbsp;" . $ierow['count'] . "</td>\n";
112 } else {
113 echo " <td colspan='$numcols'>&nbsp;&nbsp;" . $row['title'] . "</td>\n";
116 echo " </tr>\n";
118 // echo " </td>\n";
119 // echo " </tr>\n";
122 ++$ix;
125 </table> <!-- end patient_stats_issues -->
127 <table id="patient_stats_spreadsheets">
128 <?php
130 // Show spreadsheet forms if any are present.
132 $need_head = true;
133 foreach (array('treatment_protocols','injury_log') as $formname) {
134 if (mysql_num_rows(sqlStatement("SHOW TABLES LIKE 'form_$formname'")) > 0) {
135 $dres = sqlStatement("SELECT tp.id, tp.value FROM forms, " .
136 "form_$formname AS tp WHERE forms.pid = $pid AND " .
137 "forms.formdir = '$formname' AND tp.id = forms.form_id AND " .
138 "tp.rownbr = -1 AND tp.colnbr = -1 AND tp.value LIKE '0%' " .
139 "ORDER BY tp.value DESC");
140 if (mysql_num_rows($dres) > 0 && $need_head) {
141 $need_head = false;
142 echo " <tr>\n";
143 echo " <td colspan='$numcols' valign='top'>\n";
144 echo " <span class='title'>Injury Log</span>\n";
145 echo " </td>\n";
146 echo " </tr>\n";
148 while ($row = sqlFetchArray($dres)) {
149 list($completed, $start_date, $template_name) = explode('|', $row['value'], 3);
150 echo " <tr>\n";
151 echo " <td colspan='$numcols'>&nbsp;&nbsp;";
152 echo "<a class='link' target='_blank' ";
153 echo "href='../../forms/$formname/new.php?popup=1&id=";
154 echo $row['id'] . "' onclick='top.restoreSession()'>$start_date $template_name</a></td>\n";
155 echo " </tr>\n";
160 </table> <!-- end patient_stats_spreadsheets -->
162 <?php if (!$GLOBALS['weight_loss_clinic']) { ?>
163 <table id="patient_stats_imm">
164 <tr class='issuetitle'>
165 <td colspan='<?php echo $numcols ?>' valign='top'>
166 <a href="immunizations.php"
167 target="<?php echo $GLOBALS['concurrent_layout'] ? "_parent" : "Main"; ?>"
168 onclick="top.restoreSession()">
169 <span class="title"><?php xl('Immunizations','e'); ?></span>
170 <span class=more><?php echo $tmore;?></span></a>
171 </td></tr>
172 <tr><td>
174 <?php
175 $sql = "select i1.id as id, ".
176 " if (i1.administered_date, concat(i1.administered_date,' - ',i2.name), substring(i1.note,1,20)) as immunization_data ".
177 " from immunizations i1 ".
178 " left join immunization i2 ".
179 " on i1.immunization_id = i2.id ".
180 " where i1.patient_id = $pid ".
181 " order by i2.name, i1.administered_date desc";
183 $result = sqlStatement($sql);
185 while ($row=sqlFetchArray($result)){
186 echo "&nbsp;&nbsp;";
187 echo "<a class='link' target='";
188 echo $GLOBALS['concurrent_layout'] ? "_parent" : "Main";
189 echo "' href='immunizations.php?mode=edit&id=".$row['id']."' onclick='top.restoreSession()'>" .
190 $row{'immunization_data'} . "</a><br>\n";
193 </td>
194 </tr>
195 </table> <!-- end patient_stats_imm-->
196 <?php } ?>
199 <table id="patient_stats_prescriptions">
200 <tr><td colspan='<?php echo $numcols ?>' class='issuetitle'>
201 <span class='title'><?php echo xl('Prescriptions'); ?></span>
202 </td></tr>
203 </tr><td>
204 <?php
205 $cwd= getcwd();
206 chdir("../../../");
207 require_once("library/classes/Controller.class.php");
208 $c = new Controller();
209 echo $c->act(array("prescription" => "", "block" => "", "patient_id" => $pid));
211 </td></tr>
212 </table> <!-- end patient_stats_prescriptions -->
214 </div> <!-- end patient_stats_summary -->
216 </body>
217 </html>