minor changes to prior commit
[openemr.git] / interface / reports / charts_checked_out.php
blob0f017d36b1572192bd1296ce5b0c8b4325964766
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-2010 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");
18 use OpenEMR\Core\Header;
19 use OpenEMR\Services\PatientService;
22 <html>
23 <head>
24 <title><?php echo xlt('Charts Checked Out'); ?></title>
26 <?php Header::setupHeader(); ?>
28 <style type="text/css">
30 /* specifically include & exclude from printing */
31 @media print {
32 #report_parameters {
33 visibility: hidden;
34 display: none;
36 #report_parameters_daterange {
37 visibility: visible;
38 display: inline;
40 #report_results table {
41 margin-top: 0px;
45 /* specifically exclude some from the screen */
46 @media screen {
47 #report_parameters_daterange {
48 visibility: hidden;
49 display: none;
53 </style>
54 </head>
56 <body class="body_top">
58 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Charts Checked Out'); ?></span>
60 <div id="report_results">
61 <br/>
62 <?php
63 /*********************************************************************
64 $query = "SELECT ct.ct_when, " .
65 "u.username, u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " .
66 "p.pubpid, p.fname, p.mname, p.lname " .
67 "FROM chart_tracker AS ct " .
68 "LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
69 "LEFT OUTER JOIN patient_data AS p ON p.pid = ct.ct_pid " .
70 "WHERE (ct.ct_pid, ct.ct_when) in " .
71 "(SELECT ct_pid, MAX(ct_when) FROM chart_tracker GROUP BY ct_pid) " .
72 "AND ct.ct_userid != 0 " .
73 "ORDER BY p.pubpid";
74 *********************************************************************/
76 // Oops, the above requires MySQL 4.1 or later and so it was rewritten
77 // as follows to use a temporary table.
79 sqlStatement("DROP TEMPORARY TABLE IF EXISTS cttemp");
80 sqlStatement("CREATE TEMPORARY TABLE cttemp SELECT " .
81 "ct_pid, MAX(ct_when) AS ct_when FROM chart_tracker GROUP BY ct_pid");
82 $res = PatientService::getChartTrackerInformation();
83 $data_ctr = 0;
84 while ($row = sqlFetchArray($res)) {
85 if ($data_ctr == 0) { ?>
86 <table>
87 <thead>
88 <th> <?php echo xlt('Chart'); ?> </th>
89 <th> <?php echo xlt('Patient'); ?> </th>
90 <th> <?php echo xlt('Location'); ?> </th>
91 <th> <?php echo xlt('As Of'); ?> </th>
92 </thead>
93 <tbody>
94 <?php
95 } ?>
97 <tr>
98 <td>
99 <?php echo text($row['pubpid']); ?>
100 </td>
101 <td>
102 <?php echo text($row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname']); ?>
103 </td>
104 <td>
105 <?php echo text($row['ulname'] . ', ' . $row['ufname'] . ' ' . $row['umname']); ?>
106 </td>
107 <td>
108 <?php echo text(oeFormatDateTime($row['ct_when'], "global", true)); ?>
109 </td>
110 </tr>
111 <?php
113 $data_ctr++;
114 } // end while
116 if ($data_ctr < 1) { ?>
117 <span class='text'><?php echo xla('There are no charts checked out.'); ?></span>
118 <?php
122 </tbody>
123 </table>
124 </div> <!-- end of results -->
125 </body>
126 </html>