2 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.com>
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");
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 */
29 #report_parameters_daterange {
33 #report_results table {
38 /* specifically exclude some from the screen */
40 #report_parameters_daterange {
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">
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 " .
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 " .
85 $res = sqlStatement($query);
88 while ($row = sqlFetchArray($res)) {
90 if ( $data_ctr == 0 ) { ?
>
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
>
103 <?php
echo $row['pubpid']; ?
>
106 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname']; ?
>
109 <?php
echo $row['ulname'] . ', ' . $row['ufname'] . ' ' . $row['umname']; ?
>
112 <?php
echo oeFormatShortDate(substr($row['ct_when'], 0, 10)) . substr($row['ct_when'], 10); ?
>
120 if ( $data_ctr < 1 ) { ?
>
121 <span
class='text'><?php
xl('There are no charts checked out.','e'); ?
></span
>
128 </div
> <!-- end of results
-->