Patient Summary Screen Modifications:
[openemr.git] / interface / patient_file / summary / stats.php
blobe2e16ec4bf37af3512ec1db72063ddf6537fa4b5
1 <?php
3 //SANITIZE ALL ESCAPES
4 $sanitize_all_escapes=true;
5 //
7 //STOP FAKE REGISTER GLOBALS
8 $fake_register_globals=false;
9 //
11 include_once("../../globals.php");
12 include_once("$srcdir/lists.inc");
13 include_once("$srcdir/acl.inc");
14 include_once("$srcdir/options.inc.php");
15 include_once("$srcdir/formdata.inc.php");
19 <div id="patient_stats_summary">
21 <?php
22 $thisauth = acl_check('patients', 'med');
23 if ($thisauth) {
24 $tmp = getPatientData($pid, "squad");
25 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
26 $thisauth = 0;
28 if (!$thisauth) {
29 echo "<p>(".htmlspecialchars(xl('Issues not authorized'),ENT_NOQUOTES).")</p>\n";
30 echo "</body>\n</html>\n";
31 exit();
35 <script type='text/javascript'>
36 function load_location( location ) {
37 top.restoreSession();
38 if ( !top.frames["RTop"] ) {
39 document.location=location;
40 } else {
41 top.frames["RTop"].location=location;
44 </script>
46 <table id="patient_stats_issues">
48 <?php
49 $numcols = '1';
50 $ix = 0;
51 foreach ($ISSUE_TYPES as $key => $arr) {
52 // $result = getListByType($pid, $key, "id,title,begdate,enddate,returndate,extrainfo", "all", "all", 0);
54 $query = "SELECT * FROM lists WHERE pid = ? AND type = ? AND ";
55 $query .= "enddate IS NULL ";
56 $query .= "ORDER BY begdate";
57 $pres = sqlStatement($query, array($pid, $key) );
59 if (sqlNumRows($pres) > 0 || $ix == 0) {
61 // output a header for the $ISSUE_TYPE
62 echo " <tr class='issuetitle'>\n";
63 echo " <td colspan='$numcols'>\n";
66 <span class="text"><b><?php echo htmlspecialchars($arr[0],ENT_NOQUOTES); ?></b></span>
67 <a href="javascript:;" class="small" onclick="load_location('stats_full.php?active=all')">
68 (<b><?php echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES); ?></b>)
69 </a>
70 <?php
72 echo " </td>\n";
73 echo " </tr>\n";
75 while ($row = sqlFetchArray($pres)) {
76 // output each issue for the $ISSUE_TYPE
77 if (!$row['enddate'] && !$row['returndate'])
78 $rowclass="noend_noreturn";
79 else if (!$row['enddate'] && $row['returndate'])
80 $rowclass="noend";
81 else if ($row['enddate'] && !$row['returndate'])
82 $rowclass = "noreturn";
84 echo " <tr class='text $rowclass;'>\n";
86 echo " <td colspan='$numcols'>&nbsp;&nbsp;" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</td>\n";
88 echo " </tr>\n";
92 ++$ix;
95 </table> <!-- end patient_stats_issues -->
97 <table id="patient_stats_spreadsheets">
98 <?php
100 // Show spreadsheet forms if any are present.
102 $need_head = true;
103 foreach (array('treatment_protocols','injury_log') as $formname) {
104 if (sqlNumRows(sqlStatement("SHOW TABLES LIKE ?", array("form_".$formname) )) > 0) {
105 $dres = sqlStatement("SELECT tp.id, tp.value FROM forms, " .
106 "form_" . add_escape_custom($formname) .
107 " AS tp WHERE forms.pid = ? AND " .
108 "forms.formdir = ? AND tp.id = forms.form_id AND " .
109 "tp.rownbr = -1 AND tp.colnbr = -1 AND tp.value LIKE '0%' " .
110 "ORDER BY tp.value DESC", array($pid, $formname) );
111 if (sqlNumRows($dres) > 0 && $need_head) {
112 $need_head = false;
113 echo " <tr>\n";
114 echo " <td colspan='$numcols' valign='top'>\n";
115 echo " <span class='title'>Injury Log</span>\n";
116 echo " </td>\n";
117 echo " </tr>\n";
119 while ($row = sqlFetchArray($dres)) {
120 list($completed, $start_date, $template_name) = explode('|', $row['value'], 3);
121 echo " <tr>\n";
122 echo " <td colspan='$numcols'>&nbsp;&nbsp;";
123 echo "<a class='link' href='javascript:;' ";
124 echo "onclick='load_location(\"../../forms/$formname/new.php?popup=1&id=";
125 echo htmlspecialchars($row['id'],ENT_QUOTES) . "\")'>" .
126 htmlspecialchars($start_date,ENT_NOQUOTES) . " " .
127 htmlspecialchars($template_name,ENT_NOQUOTES) . "</a></td>\n";
128 echo " </tr>\n";
133 </table> <!-- end patient_stats_spreadsheets -->
135 <?php if (!$GLOBALS['disable_immunizations'] && !$GLOBALS['weight_loss_clinic']) { ?>
136 <div>
137 <table id="patient_stats_imm">
138 <tr>
139 <td colspan='<?php echo $numcols ?>' valign='top'>
140 <span class="text"><b><?php echo htmlspecialchars(xl('Immunizations', 'e'),ENT_NOQUOTES); ?></b></span>
141 <a href="javascript:;" class="small" onclick="javascript:load_location('immunizations.php')">
142 (<b><?php echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES) ?></b>)
143 </a>
144 </td></tr>
145 <tr><td>
147 <?php
148 $sql = "select i1.id as id, i1.immunization_id as immunization_id,".
149 " if (i1.administered_date, concat(i1.administered_date,' - '), substring(i1.note,1,20)) as immunization_data ".
150 " from immunizations i1 ".
151 " where i1.patient_id = ? ".
152 " order by i1.immunization_id, i1.administered_date desc";
154 $result = sqlStatement($sql, array($pid) );
156 while ($row=sqlFetchArray($result)){
157 echo "&nbsp;&nbsp;";
158 echo "<a class='link'";
159 echo "' href='javascript:;' onclick='javascript:load_location(\"immunizations.php?mode=edit&id=".htmlspecialchars($row['id'],ENT_QUOTES) . "\")'>" .
160 htmlspecialchars($row{'immunization_data'},ENT_NOQUOTES) .
161 generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']) .
162 "</a><br>\n";
165 </td>
166 </tr>
167 </table> <!-- end patient_stats_imm-->
168 </div>
169 <?php } ?>
171 <?php if (!$GLOBALS['disable_prescriptions']) { ?>
172 <div>
173 <table id="patient_stats_prescriptions">
174 <tr><td colspan='<?php echo $numcols ?>' class='issuetitle'>
175 <span class='text'><b><?php echo htmlspecialchars(xl('Prescriptions'),ENT_NOQUOTES); ?></b></span>
176 <?php if ($_POST['embeddedScreen']) { ?>
177 <a href="rx_frameset.php" class='iframe rx_modal small' onclick='top.restoreSession()'>
178 (<b><?php echo htmlspecialchars(xl('Manage'),ENT_NOQUOTES); ?>)</b></a>
179 <?php } ?>
180 </td></tr>
181 </tr><td>
182 <?php
183 $cwd= getcwd();
184 chdir("../../../");
185 require_once("library/classes/Controller.class.php");
186 $c = new Controller();
187 echo $c->act(array("prescription" => "", "fragment" => "", "patient_id" => $pid));
189 </td></tr>
190 </table> <!-- end patient_stats_prescriptions -->
191 </div>
192 <?php } ?>
194 </div> <!-- end patient_stats_summary -->