minor changes to prior commit
[openemr.git] / interface / reports / chart_location_activity.php
blob7e7119d6c6698d0387660b1fa02f71fe29be3595
1 <?php
2 /**
3 * This reports checkins and checkouts for a specified patient's chart.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2008-2015 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/options.inc.php");
19 use OpenEMR\Core\Header;
20 use OpenEMR\Services\PatientService;
22 $form_patient_id = trim($_POST['form_patient_id']);
24 <html>
25 <head>
26 <title><?php echo xlt('Chart Location Activity'); ?></title>
28 <?php Header::setupHeader(); ?>
30 <style type="text/css">
31 /* specifically include & exclude from printing */
32 @media print {
33 #report_parameters {
34 visibility: hidden;
35 display: none;
37 #report_parameters_daterange {
38 visibility: visible;
39 display: inline;
41 #report_results table {
42 margin-top: 0px;
46 /* specifically exclude some from the screen */
47 @media screen {
48 #report_parameters_daterange {
49 visibility: hidden;
50 display: none;
53 </style>
55 <script language="JavaScript">
56 $(document).ready(function() {
57 var win = top.printLogSetup ? top : opener.top;
58 win.printLogSetup(document.getElementById('printbutton'));
59 });
60 </script>
61 </head>
63 <body class="body_top">
65 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Chart Location Activity'); ?></span>
67 <?php
68 $curr_pid = $pid;
69 $ptrow = array();
70 if (!empty($form_patient_id)) {
71 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
72 "pubpid = ? ORDER BY pid LIMIT 1";
73 $ptrow = sqlQuery($query, array($form_patient_id));
74 if (empty($ptrow)) {
75 $curr_pid = 0;
76 echo "<font color='red'>" . xlt('Chart ID') . " '" . text($form_patient_id) . "' " . xlt('not found!') . "</font><br />&nbsp;<br />";
77 } else {
78 $curr_pid = $ptrow['pid'];
80 } else if (!empty($curr_pid)) {
81 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
82 "pid = ?";
83 $ptrow = sqlQuery($query, array($curr_pid));
84 $form_patient_id = $ptrow['pubpid'];
87 if (!empty($ptrow)) {
88 echo '<span class="title">' . xlt('for') . ' ';
89 echo text($ptrow['lname']) . ', ' . text($ptrow['fname']) . ' ' . text($ptrow['mname']) . ' ';
90 echo "(" . text($ptrow['pubpid']) . ")";
91 echo "</span>\n";
95 <div id="report_parameters_daterange">
96 </div>
98 <form name='theform' id='theform' method='post' action='chart_location_activity.php' onsubmit='return top.restoreSession()'>
100 <div id="report_parameters">
102 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
103 <table>
104 <tr>
105 <td width='200px'>
106 <div style='float:left'>
108 <table class='text'>
109 <tr>
110 <td class='control-label'>
111 <?php echo xlt('Patient ID'); ?>:
112 </td>
113 <td>
114 <input type='text' name='form_patient_id' class='form-control' size='10' maxlength='31' value='<?php echo attr($form_patient_id) ?>'
115 title='<?php echo xla('Patient ID'); ?>' />
116 </td>
117 </tr>
118 </table>
120 </div>
122 </td>
123 <td align='left' valign='middle' height="100%">
124 <table style='border-left:1px solid; width:100%; height:100%' >
125 <tr>
126 <td>
127 <div class="text-center">
128 <div class="btn-group" role="group">
129 <a href='#' class='btn btn-default btn-save' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
130 <?php echo xlt('Submit'); ?>
131 </a>
132 <?php if ($_POST['form_refresh'] || !empty($ptrow)) { ?>
133 <a href='#' class='btn btn-default btn-print' id='printbutton'>
134 <?php echo xlt('Print'); ?>
135 </a>
136 <?php } ?>
137 </div>
138 </div>
139 </td>
140 </tr>
141 </table>
142 </td>
143 </tr>
144 </table>
146 </div> <!-- end of parameters -->
148 <?php
149 if ($_POST['form_refresh'] || !empty($ptrow)) {
151 <div id="report_results">
152 <table>
153 <thead>
154 <th> <?php echo xlt('Time'); ?> </th>
155 <th> <?php echo xlt('Destination'); ?> </th>
156 </thead>
157 <tbody>
158 <?php
159 $row = array();
160 if (!empty($ptrow)) {
161 $res = PatientService::getChartTrackerInformationActivity($curr_pid);
162 while ($row = sqlFetchArray($res)) {
164 <tr>
165 <td>
166 <?php echo text(oeFormatDateTime($row['ct_when'], "global", true)); ?>
167 </td>
168 <td>
169 <?php
170 if (!empty($row['ct_location'])) {
171 echo generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'), $row['ct_location']);
172 } else if (!empty($row['ct_userid'])) {
173 echo text($row['lname']) . ', ' . text($row['fname']) . ' ' . text($row['mname']);
176 </td>
177 </tr>
178 <?php
179 } // end while
180 } // end if
182 </tbody>
183 </table>
184 </div> <!-- end of results -->
185 <?php } else { ?>
186 <div class='text'>
187 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
188 </div>
189 <?php } ?>
191 </form>
192 </body>
193 </html>