convert to new security model for chart_location_activity
[openemr.git] / interface / reports / chart_location_activity.php
blobb78c8d825ade7ef68727e562d25da5a9ce476ce6
1 <?php
2 // Copyright (C) 2008-2010 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 // This reports checkins and checkouts for a specified patient's chart.
10 $fake_register_globals=false;
11 $sanitize_all_escapes=true;
13 require_once("../globals.php");
14 require_once("$srcdir/patient.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/formatting.inc.php");
18 $form_patient_id = trim($_POST['form_patient_id']);
20 <html>
21 <head>
22 <?php html_header_show(); ?>
23 <title><?php xl('Chart Location Activity','e'); ?></title>
25 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
26 <style type="text/css">
28 /* specifically include & exclude from printing */
29 @media print {
30 #report_parameters {
31 visibility: hidden;
32 display: none;
34 #report_parameters_daterange {
35 visibility: visible;
36 display: inline;
38 #report_results table {
39 margin-top: 0px;
43 /* specifically exclude some from the screen */
44 @media screen {
45 #report_parameters_daterange {
46 visibility: hidden;
47 display: none;
51 </style>
53 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
55 </head>
57 <body class="body_top">
59 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Chart Location Activity','e'); ?></span>
61 <?php
62 $curr_pid = $pid;
63 $ptrow = array();
64 if (!empty($form_patient_id)) {
65 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
66 "pubpid = ? ORDER BY pid LIMIT 1";
67 $ptrow = sqlQuery($query,array($form_patient_id));
68 if (empty($ptrow)) {
69 $curr_pid = 0;
70 echo "<font color='red'>" . xl('Chart ID') . " '" . $form_patient_id . "' " . xl('not found!') . "</font><br />&nbsp;<br />";
72 else {
73 $curr_pid = $ptrow['pid'];
76 else if (!empty($curr_pid)) {
77 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
78 "pid = ?";
79 $ptrow = sqlQuery($query,array($curr_pid));
80 $form_patient_id = $ptrow['pubpid'];
82 if (!empty($ptrow)) {
83 echo '<span class="title">' . xl('for','','',' ');
84 echo $ptrow['lname'] . ', ' . $ptrow['fname'] . ' ' . $ptrow['mname'] . ' ';
85 echo "(" . $ptrow['pubpid'] . ")";
86 echo "</span>\n";
90 <div id="report_parameters_daterange">
91 </div>
93 <form name='theform' id='theform' method='post' action='chart_location_activity.php'>
95 <div id="report_parameters">
97 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
98 <table>
99 <tr>
100 <td width='200px'>
101 <div style='float:left'>
103 <table class='text'>
104 <tr>
105 <td class='label'>
106 <?php xl('Patient ID','e'); ?>:
107 </td>
108 <td>
109 <input type='text' name='form_patient_id' size='10' maxlength='31' value='<?php echo $form_patient_id ?>'
110 title='<?php xl('Patient ID','e'); ?>' />
111 </td>
112 </tr>
113 </table>
115 </div>
117 </td>
118 <td align='left' valign='middle' height="100%">
119 <table style='border-left:1px solid; width:100%; height:100%' >
120 <tr>
121 <td>
122 <div style='margin-left:15px'>
123 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
124 <span>
125 <?php xl('Submit','e'); ?>
126 </span>
127 </a>
129 <?php if ($_POST['form_refresh'] || !empty($ptrow) ) { ?>
130 <a href='#' class='css_button' onclick='window.print()'>
131 <span>
132 <?php xl('Print','e'); ?>
133 </span>
134 </a>
135 <?php } ?>
136 </div>
137 </td>
138 </tr>
139 </table>
140 </td>
141 </tr>
142 </table>
144 </div> <!-- end of parameters -->
146 <?php
147 if ($_POST['form_refresh'] || !empty($ptrow) ) {
149 <div id="report_results">
150 <table>
151 <thead>
152 <th> <?php xl('Time','e'); ?> </th>
153 <th> <?php xl('Destination','e'); ?> </th>
154 </thead>
155 <tbody>
156 <?php
157 $row = array();
158 if (!empty($ptrow)) {
159 $query = "SELECT ct.ct_when, ct.ct_userid, ct.ct_location, " .
160 "u.username, u.fname, u.mname, u.lname " .
161 "FROM chart_tracker AS ct " .
162 "LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
163 "WHERE ct.ct_pid = '$curr_pid' " .
164 "ORDER BY ct.ct_when DESC";
165 $res = sqlStatement($query);
167 while ($row = sqlFetchArray($res)) {
169 <tr>
170 <td>
171 <?php echo oeFormatShortDate(substr($row['ct_when'], 0, 10)) . substr($row['ct_when'], 10); ?>
172 </td>
173 <td>
174 <?php
175 if (!empty($row['ct_location'])) {
176 echo generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'),$row['ct_location']);
178 else if (!empty($row['ct_userid'])) {
179 echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'];
182 </td>
183 </tr>
184 <?php
185 } // end while
186 } // end if
188 </tbody>
189 </table>
190 </div> <!-- end of results -->
191 <?php } else { ?>
192 <div class='text'>
193 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
194 </div>
195 <?php } ?>
197 </form>
198 </body>
199 </html>