Feat openemr #7982 #7983 #7984 newpatient encounter save refactors and bug fixes...
[openemr.git] / interface / reports / chart_location_activity.php
blob2441a9a2d7328b5ed698109626843b4f05333f8d
1 <?php
3 /**
4 * This reports checkins and checkouts for a specified patient's chart.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2008-2015 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
12 * @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.php");
17 require_once("$srcdir/options.inc.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
21 use OpenEMR\Services\PatientService;
23 if (!empty($_POST)) {
24 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
25 CsrfUtils::csrfNotVerified();
29 $form_patient_id = trim($_POST['form_patient_id'] ?? '');
31 <html>
32 <head>
33 <title><?php echo xlt('Chart Location Activity'); ?></title>
35 <?php Header::setupHeader(); ?>
37 <style>
38 /* specifically include & exclude from printing */
39 @media print {
40 #report_parameters {
41 visibility: hidden;
42 display: none;
44 #report_parameters_daterange {
45 visibility: visible;
46 display: inline;
48 #report_results table {
49 margin-top: 0px;
53 /* specifically exclude some from the screen */
54 @media screen {
55 #report_parameters_daterange {
56 visibility: hidden;
57 display: none;
60 </style>
62 <script>
63 $(function () {
64 var win = top.printLogSetup ? top : opener.top;
65 win.printLogSetup(document.getElementById('printbutton'));
66 });
67 </script>
68 </head>
70 <body class="body_top">
72 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Chart Location Activity'); ?></span>
74 <?php
75 $curr_pid = $pid;
76 $ptrow = array();
77 if (!empty($form_patient_id)) {
78 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
79 "pubpid = ? ORDER BY pid LIMIT 1";
80 $ptrow = sqlQuery($query, array($form_patient_id));
81 if (empty($ptrow)) {
82 $curr_pid = 0;
83 echo "<font color='red'>" . xlt('Chart ID') . " '" . text($form_patient_id) . "' " . xlt('not found!') . "</font><br />&nbsp;<br />";
84 } else {
85 $curr_pid = $ptrow['pid'];
87 } elseif (!empty($curr_pid)) {
88 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
89 "pid = ?";
90 $ptrow = sqlQuery($query, array($curr_pid));
91 $form_patient_id = $ptrow['pubpid'];
94 if (!empty($ptrow)) {
95 echo '<span class="title">' . xlt('for') . ' ';
96 echo text($ptrow['lname']) . ', ' . text($ptrow['fname']) . ' ' . text($ptrow['mname']) . ' ';
97 echo "(" . text($ptrow['pubpid']) . ")";
98 echo "</span>\n";
102 <div id="report_parameters_daterange">
103 </div>
105 <form name='theform' id='theform' method='post' action='chart_location_activity.php' onsubmit='return top.restoreSession()'>
106 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
108 <div id="report_parameters">
110 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
111 <table>
112 <tr>
113 <td width='200px'>
114 <div style='float:left'>
116 <table class='text'>
117 <tr>
118 <td class='col-form-label'>
119 <?php echo xlt('Patient ID'); ?>:
120 </td>
121 <td>
122 <input type='text' name='form_patient_id' class='form-control' size='10' maxlength='31' value='<?php echo attr($form_patient_id) ?>'
123 title='<?php echo xla('Patient ID'); ?>' />
124 </td>
125 </tr>
126 </table>
128 </div>
130 </td>
131 <td class='h-100' align='left' valign='middle'>
132 <table class='w-100 h-100' style='border-left:1px solid;'>
133 <tr>
134 <td>
135 <div class="text-center">
136 <div class="btn-group" role="group">
137 <a href='#' class='btn btn-secondary btn-save' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
138 <?php echo xlt('Submit'); ?>
139 </a>
140 <?php if (!empty($_POST['form_refresh']) || !empty($ptrow)) { ?>
141 <a href='#' class='btn btn-secondary btn-print' id='printbutton'>
142 <?php echo xlt('Print'); ?>
143 </a>
144 <?php } ?>
145 </div>
146 </div>
147 </td>
148 </tr>
149 </table>
150 </td>
151 </tr>
152 </table>
154 </div> <!-- end of parameters -->
156 <?php
157 if (!empty($_POST['form_refresh']) || !empty($ptrow)) {
159 <div id="report_results">
160 <table class='table'>
161 <thead class='thead-light'>
162 <th> <?php echo xlt('Time'); ?> </th>
163 <th> <?php echo xlt('Destination'); ?> </th>
164 </thead>
165 <tbody>
166 <?php
167 $row = array();
168 if (!empty($ptrow)) {
169 $res = PatientService::getChartTrackerInformationActivity($curr_pid);
170 while ($row = sqlFetchArray($res)) {
172 <tr>
173 <td>
174 <?php echo text(oeFormatDateTime($row['ct_when'], "global", true)); ?>
175 </td>
176 <td>
177 <?php
178 if (!empty($row['ct_location'])) {
179 echo generate_display_field(array('data_type' => '1','list_id' => 'chartloc'), $row['ct_location']);
180 } elseif (!empty($row['ct_userid'])) {
181 echo text($row['lname']) . ', ' . text($row['fname']) . ' ' . text($row['mname']);
184 </td>
185 </tr>
186 <?php
187 } // end while
188 } // end if
190 </tbody>
191 </table>
192 </div> <!-- end of results -->
193 <?php } else { ?>
194 <div class='text'>
195 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
196 </div>
197 <?php } ?>
199 </form>
200 </body>
201 </html>