Focus the search term on load
[openemr.git] / interface / reports / charts_checked_out.php
blob7e907ff6b3cd291333807963b538074991033b1f
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.
11 require_once("../globals.php");
12 require_once("$srcdir/patient.inc");
13 require_once("$srcdir/formatting.inc.php");
15 <html>
16 <head>
17 <?php html_header_show(); ?>
18 <title><?php xl('Charts Checked Out','e'); ?></title>
20 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
21 <style type="text/css">
23 /* specifically include & exclude from printing */
24 @media print {
25 #report_parameters {
26 visibility: hidden;
27 display: none;
29 #report_parameters_daterange {
30 visibility: visible;
31 display: inline;
33 #report_results table {
34 margin-top: 0px;
38 /* specifically exclude some from the screen */
39 @media screen {
40 #report_parameters_daterange {
41 visibility: hidden;
42 display: none;
46 </style>
47 </head>
49 <body class="body_top">
51 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Charts Checked Out','e'); ?></span>
53 <div id="report_results">
54 <br/>
55 <?php
56 /*********************************************************************
57 $query = "SELECT ct.ct_when, " .
58 "u.username, u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " .
59 "p.pubpid, p.fname, p.mname, p.lname " .
60 "FROM chart_tracker AS ct " .
61 "LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
62 "LEFT OUTER JOIN patient_data AS p ON p.pid = ct.ct_pid " .
63 "WHERE (ct.ct_pid, ct.ct_when) in " .
64 "(SELECT ct_pid, MAX(ct_when) FROM chart_tracker GROUP BY ct_pid) " .
65 "AND ct.ct_userid != 0 " .
66 "ORDER BY p.pubpid";
67 *********************************************************************/
69 // Oops, the above requires MySQL 4.1 or later and so it was rewritten
70 // as follows to use a temporary table.
72 sqlStatement("DROP TEMPORARY TABLE IF EXISTS cttemp");
73 sqlStatement("CREATE TEMPORARY TABLE cttemp SELECT " .
74 "ct_pid, MAX(ct_when) AS ct_when FROM chart_tracker GROUP BY ct_pid");
75 $query = "SELECT ct.ct_when, " .
76 "u.username, u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " .
77 "p.pubpid, p.fname, p.mname, p.lname " .
78 "FROM chart_tracker AS ct " .
79 "JOIN cttemp ON cttemp.ct_pid = ct.ct_pid AND cttemp.ct_when = ct.ct_when " .
80 "LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
81 "LEFT OUTER JOIN patient_data AS p ON p.pid = ct.ct_pid " .
82 "WHERE ct.ct_userid != 0 " .
83 "ORDER BY p.pubpid";
85 $res = sqlStatement($query);
87 $data_ctr = 0;
88 while ($row = sqlFetchArray($res)) {
90 if ( $data_ctr == 0 ) { ?>
91 <table>
92 <thead>
93 <th> <?php xl('Chart','e'); ?> </th>
94 <th> <?php xl('Patient','e'); ?> </th>
95 <th> <?php xl('Location','e'); ?> </th>
96 <th> <?php xl('As Of','e'); ?> </th>
97 </thead>
98 <tbody>
99 <?php } ?>
101 <tr>
102 <td>
103 <?php echo $row['pubpid']; ?>
104 </td>
105 <td>
106 <?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname']; ?>
107 </td>
108 <td>
109 <?php echo $row['ulname'] . ', ' . $row['ufname'] . ' ' . $row['umname']; ?>
110 </td>
111 <td>
112 <?php echo oeFormatShortDate(substr($row['ct_when'], 0, 10)) . substr($row['ct_when'], 10); ?>
113 </td>
114 </tr>
115 <?php
117 $data_ctr++;
118 } // end while
120 if ( $data_ctr < 1 ) { ?>
121 <span class='text'><?php xl('There are no charts checked out.','e'); ?></span>
122 <?php
126 </tbody>
127 </table>
128 </div> <!-- end of results -->
129 </body>
130 </html>