forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
charts_checked_out.php
130 lines (113 loc) · 3.51 KB
/
charts_checked_out.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
// Copyright (C) 2008-2010 Rod Roark <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This reports checkins and checkouts for a specified patient's chart.
require_once("../globals.php");
require_once("$srcdir/patient.inc");
require_once("$srcdir/formatting.inc.php");
?>
<html>
<head>
<?php html_header_show(); ?>
<title><?php xl('Charts Checked Out','e'); ?></title>
<link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
<style type="text/css">
/* specifically include & exclude from printing */
@media print {
#report_parameters {
visibility: hidden;
display: none;
}
#report_parameters_daterange {
visibility: visible;
display: inline;
}
#report_results table {
margin-top: 0px;
}
}
/* specifically exclude some from the screen */
@media screen {
#report_parameters_daterange {
visibility: hidden;
display: none;
}
}
</style>
</head>
<body class="body_top">
<span class='title'><?php xl('Report','e'); ?> - <?php xl('Charts Checked Out','e'); ?></span>
<div id="report_results">
<br/>
<?php
/*********************************************************************
$query = "SELECT ct.ct_when, " .
"u.username, u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " .
"p.pubpid, p.fname, p.mname, p.lname " .
"FROM chart_tracker AS ct " .
"LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
"LEFT OUTER JOIN patient_data AS p ON p.pid = ct.ct_pid " .
"WHERE (ct.ct_pid, ct.ct_when) in " .
"(SELECT ct_pid, MAX(ct_when) FROM chart_tracker GROUP BY ct_pid) " .
"AND ct.ct_userid != 0 " .
"ORDER BY p.pubpid";
*********************************************************************/
// Oops, the above requires MySQL 4.1 or later and so it was rewritten
// as follows to use a temporary table.
//
sqlStatement("DROP TEMPORARY TABLE IF EXISTS cttemp");
sqlStatement("CREATE TEMPORARY TABLE cttemp SELECT " .
"ct_pid, MAX(ct_when) AS ct_when FROM chart_tracker GROUP BY ct_pid");
$query = "SELECT ct.ct_when, " .
"u.username, u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " .
"p.pubpid, p.fname, p.mname, p.lname " .
"FROM chart_tracker AS ct " .
"JOIN cttemp ON cttemp.ct_pid = ct.ct_pid AND cttemp.ct_when = ct.ct_when " .
"LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
"LEFT OUTER JOIN patient_data AS p ON p.pid = ct.ct_pid " .
"WHERE ct.ct_userid != 0 " .
"ORDER BY p.pubpid";
$res = sqlStatement($query);
$data_ctr = 0;
while ($row = sqlFetchArray($res)) {
if ( $data_ctr == 0 ) { ?>
<table>
<thead>
<th> <?php xl('Chart','e'); ?> </th>
<th> <?php xl('Patient','e'); ?> </th>
<th> <?php xl('Location','e'); ?> </th>
<th> <?php xl('As Of','e'); ?> </th>
</thead>
<tbody>
<?php } ?>
<tr>
<td>
<?php echo $row['pubpid']; ?>
</td>
<td>
<?php echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname']; ?>
</td>
<td>
<?php echo $row['ulname'] . ', ' . $row['ufname'] . ' ' . $row['umname']; ?>
</td>
<td>
<?php echo oeFormatShortDate(substr($row['ct_when'], 0, 10)) . substr($row['ct_when'], 10); ?>
</td>
</tr>
<?php
$data_ctr++;
} // end while
if ( $data_ctr < 1 ) { ?>
<span class='text'><?php xl('There are no charts checked out.','e'); ?></span>
<?php
}
?>
</tbody>
</table>
</div> <!-- end of results -->
</body>
</html>