3a23177b71fe736b605a0ad66819d48b32978944
[openemr.git] / interface / reports / chart_location_activity.php
blob3a23177b71fe736b605a0ad66819d48b32978944
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/options.inc.php");
14 require_once("$srcdir/formatting.inc.php");
16 $form_patient_id = trim($_POST['form_patient_id']);
18 <html>
19 <head>
20 <?php html_header_show(); ?>
21 <title><?php xl('Chart Location Activity','e'); ?></title>
23 <link rel='stylesheet' href='<?php echo $css_header ?>' type='text/css'>
24 <style type="text/css">
26 /* specifically include & exclude from printing */
27 @media print {
28 #report_parameters {
29 visibility: hidden;
30 display: none;
32 #report_parameters_daterange {
33 visibility: visible;
34 display: inline;
36 #report_results table {
37 margin-top: 0px;
41 /* specifically exclude some from the screen */
42 @media screen {
43 #report_parameters_daterange {
44 visibility: hidden;
45 display: none;
49 </style>
51 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
53 </head>
55 <body class="body_top">
57 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Chart Location Activity','e'); ?></span>
59 <?php
60 $curr_pid = $pid;
61 $ptrow = array();
62 if (!empty($form_patient_id)) {
63 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
64 "pubpid = '$form_patient_id' ORDER BY pid LIMIT 1";
65 $ptrow = sqlQuery($query);
66 if (empty($ptrow)) {
67 $curr_pid = 0;
68 echo "<font color='red'>" . xl('Chart ID') . " '" . $form_patient_id . "' " . xl('not found!') . "</font><br />&nbsp;<br />";
70 else {
71 $curr_pid = $ptrow['pid'];
74 else if (!empty($curr_pid)) {
75 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
76 "pid = '$curr_pid'";
77 $ptrow = sqlQuery($query);
78 $form_patient_id = $ptrow['pubpid'];
80 if (!empty($ptrow)) {
81 echo '<span class="title">' . xl('for','','',' ');
82 echo $ptrow['lname'] . ', ' . $ptrow['fname'] . ' ' . $ptrow['mname'] . ' ';
83 echo "(" . $ptrow['pubpid'] . ")";
84 echo "</span>\n";
88 <div id="report_parameters_daterange">
89 </div>
91 <form name='theform' id='theform' method='post' action='chart_location_activity.php'>
93 <div id="report_parameters">
95 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
96 <table>
97 <tr>
98 <td width='200px'>
99 <div style='float:left'>
101 <table class='text'>
102 <tr>
103 <td class='label'>
104 <?php xl('Patient ID','e'); ?>:
105 </td>
106 <td>
107 <input type='text' name='form_patient_id' size='10' maxlength='31' value='<?php echo $form_patient_id ?>'
108 title='<?php xl('Patient ID','e'); ?>' />
109 </td>
110 </tr>
111 </table>
113 </div>
115 </td>
116 <td align='left' valign='middle' height="100%">
117 <table style='border-left:1px solid; width:100%; height:100%' >
118 <tr>
119 <td>
120 <div style='margin-left:15px'>
121 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
122 <span>
123 <?php xl('Submit','e'); ?>
124 </span>
125 </a>
127 <?php if ($_POST['form_refresh'] || !empty($ptrow) ) { ?>
128 <a href='#' class='css_button' onclick='window.print()'>
129 <span>
130 <?php xl('Print','e'); ?>
131 </span>
132 </a>
133 <?php } ?>
134 </div>
135 </td>
136 </tr>
137 </table>
138 </td>
139 </tr>
140 </table>
142 </div> <!-- end of parameters -->
144 <?php
145 if ($_POST['form_refresh'] || !empty($ptrow) ) {
147 <div id="report_results">
148 <table>
149 <thead>
150 <th> <?php xl('Time','e'); ?> </th>
151 <th> <?php xl('Destination','e'); ?> </th>
152 </thead>
153 <tbody>
154 <?php
155 $row = array();
156 if (!empty($ptrow)) {
157 $query = "SELECT ct.ct_when, ct.ct_userid, ct.ct_location, " .
158 "u.username, u.fname, u.mname, u.lname " .
159 "FROM chart_tracker AS ct " .
160 "LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid " .
161 "WHERE ct.ct_pid = '$curr_pid' " .
162 "ORDER BY ct.ct_when DESC";
163 $res = sqlStatement($query);
165 while ($row = sqlFetchArray($res)) {
167 <tr>
168 <td>
169 <?php echo oeFormatShortDate(substr($row['ct_when'], 0, 10)) . substr($row['ct_when'], 10); ?>
170 </td>
171 <td>
172 <?php
173 if (!empty($row['ct_location'])) {
174 echo generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'),$row['ct_location']);
176 else if (!empty($row['ct_userid'])) {
177 echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'];
180 </td>
181 </tr>
182 <?php
183 } // end while
184 } // end if
186 </tbody>
187 </table>
188 </div> <!-- end of results -->
189 <?php } else { ?>
190 <div class='text'>
191 <?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
192 </div>
193 <?php } ?>
195 </form>
196 </body>
197 </html>