Committed football_injury_report.php for bug where Warning message is displayed when...
[openemr.git] / interface / reports / appointments_report.php
blob6fdafa0239159cfac9cbef9d0063fe8e512d56ed
1 <?php
2 // Copyright (C) 2005-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 report shows upcoming appointments with filtering and
10 // sorting by patient, practitioner, appointment type, and date.
12 require_once("../globals.php");
13 require_once("../../library/patient.inc");
14 require_once("$srcdir/formatting.inc.php");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/formdata.inc.php";
17 require_once "$srcdir/appointments.inc.php";
19 $alertmsg = ''; // not used yet but maybe later
20 $patient = $_REQUEST['patient'];
22 if ($patient && ! $_POST['form_from_date']) {
23 // If a specific patient, default to 2 years ago.
24 $tmp = date('Y') - 2;
25 $from_date = date("$tmp-m-d");
26 } else {
27 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
28 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
31 $show_available_times = false;
32 if ( $_POST['form_show_available'] ) {
33 $show_available_times = true;
35 //$to_date = fixDate($_POST['form_to_date'], '');
36 $provider = $_POST['form_provider'];
37 $facility = $_POST['form_facility']; //(CHEMED) facility filter
38 $form_orderby = getComparisonOrder( $_REQUEST['form_orderby'] ) ? $_REQUEST['form_orderby'] : 'date';
42 <html>
44 <head>
45 <?php html_header_show();?>
47 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
49 <title><?php xl('Appointments Report','e'); ?></title>
51 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
52 <script type="text/javascript" src="../../library/textformat.js"></script>
53 <script type="text/javascript" src="../../library/dialog.js"></script>
54 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
56 <script LANGUAGE="JavaScript">
58 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
60 function dosort(orderby) {
61 var f = document.forms[0];
62 f.form_orderby.value = orderby;
63 f.submit();
64 return false;
67 function oldEvt(eventid) {
68 dlgopen('../main/calendar/add_edit_event.php?eid=' + eventid, 'blank', 550, 270);
71 function refreshme() {
72 // location.reload();
73 document.forms[0].submit();
76 </script>
78 <style type="text/css">
79 /* specifically include & exclude from printing */
80 @media print {
81 #report_parameters {
82 visibility: hidden;
83 display: none;
85 #report_parameters_daterange {
86 visibility: visible;
87 display: inline;
89 #report_results table {
90 margin-top: 0px;
94 /* specifically exclude some from the screen */
95 @media screen {
96 #report_parameters_daterange {
97 visibility: hidden;
98 display: none;
101 </style>
102 </head>
104 <body class="body_top">
106 <!-- Required for the popup date selectors -->
107 <div id="overDiv"
108 style="position: absolute; visibility: hidden; z-index: 1000;"></div>
110 <span class='title'><?php xl('Report','e'); ?> - <?php xl('Appointments','e'); ?></span>
112 <div id="report_parameters_daterange"><?php echo date("d F Y", strtotime($form_from_date)) ." &nbsp; to &nbsp; ". date("d F Y", strtotime($form_to_date)); ?>
113 </div>
115 <form method='post' name='theform' id='theform'
116 action='appointments_report.php'>
117 <form name='theform' id='theform' method='post'
118 action='referrals_report.php'>
120 <div id="report_parameters">
122 <table>
123 <tr>
124 <td width='550px'>
125 <div style='float: left'>
127 <table class='text'>
128 <tr>
129 <td class='label'><?php xl('Facility','e'); ?>:</td>
130 <td><?php dropdown_facility(strip_escape_custom($facility), 'form_facility'); ?>
131 </td>
132 <td class='label'><?php xl('Provider','e'); ?>:</td>
133 <td><?php
135 // Build a drop-down list of providers.
138 $query = "SELECT id, lname, fname FROM users WHERE ".
139 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
141 $ures = sqlStatement($query);
143 echo " <select name='form_provider'>\n";
144 echo " <option value=''>-- " . xl('All') . " --\n";
146 while ($urow = sqlFetchArray($ures)) {
147 $provid = $urow['id'];
148 echo " <option value='$provid'";
149 if ($provid == $_POST['form_provider']) echo " selected";
150 echo ">" . $urow['lname'] . ", " . $urow['fname'] . "\n";
153 echo " </select>\n";
155 ?></td>
156 <td><input type='checkbox' name='form_show_available'
157 title='<?php xl('Show Available Times','e'); ?>'
158 <?php if ( $show_available_times ) echo ' checked'; ?>> <?php xl( 'Show Available Times','e' ); ?>
159 </td>
160 </tr>
161 <tr>
162 <td class='label'><?php xl('From','e'); ?>:</td>
163 <td><input type='text' name='form_from_date' id="form_from_date"
164 size='10' value='<?php echo $form_from_date ?>'
165 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
166 title='yyyy-mm-dd'> <img src='../pic/show_calendar.gif'
167 align='absbottom' width='24' height='22' id='img_from_date'
168 border='0' alt='[?]' style='cursor: pointer'
169 title='<?php xl('Click here to choose a date','e'); ?>'></td>
170 <td class='label'><?php xl('To','e'); ?>:</td>
171 <td><input type='text' name='form_to_date' id="form_to_date"
172 size='10' value='<?php echo $form_to_date ?>'
173 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
174 title='yyyy-mm-dd'> <img src='../pic/show_calendar.gif'
175 align='absbottom' width='24' height='22' id='img_to_date'
176 border='0' alt='[?]' style='cursor: pointer'
177 title='<?php xl('Click here to choose a date','e'); ?>'></td>
178 </tr>
179 </table>
181 </div>
183 </td>
184 <td align='left' valign='middle' height="100%">
185 <table style='border-left: 1px solid; width: 100%; height: 100%'>
186 <tr>
187 <td>
188 <div style='margin-left: 15px'><a href='#' class='css_button'
189 onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
190 <span> <?php xl('Submit','e'); ?> </span> </a> <?php if ($_POST['form_refresh'] || $_POST['form_orderby'] ) { ?>
191 <a href='#' class='css_button' onclick='window.print()'> <span> <?php xl('Print','e'); ?>
192 </span> </a> <?php } ?></div>
193 </td>
194 </tr>
195 </table>
196 </td>
197 </tr>
198 </table>
200 </div>
201 <!-- end of search parameters --> <?php
202 if ($_POST['form_refresh'] || $_POST['form_orderby']) {
204 <div id="report_results">
205 <table>
207 <thead>
208 <th><a href="nojs.php" onclick="return dosort('doctor')"
209 <?php if ($form_orderby == "doctor") echo " style=\"color:#00cc00\"" ?>><?php xl('Provider','e'); ?>
210 </a></th>
212 <th><a href="nojs.php" onclick="return dosort('date')"
213 <?php if ($form_orderby == "date") echo " style=\"color:#00cc00\"" ?>><?php xl('Date','e'); ?></a>
214 </th>
216 <th><a href="nojs.php" onclick="return dosort('time')"
217 <?php if ($form_orderby == "time") echo " style=\"color:#00cc00\"" ?>><?php xl('Time','e'); ?></a>
218 </th>
220 <th><a href="nojs.php" onclick="return dosort('patient')"
221 <?php if ($form_orderby == "patient") echo " style=\"color:#00cc00\"" ?>><?php xl('Patient','e'); ?></a>
222 </th>
224 <th><a href="nojs.php" onclick="return dosort('pubpid')"
225 <?php if ($form_orderby == "pubpid") echo " style=\"color:#00cc00\"" ?>><?php xl('ID','e'); ?></a>
226 </th>
228 <th><a href="nojs.php" onclick="return dosort('type')"
229 <?php if ($form_orderby == "type") echo " style=\"color:#00cc00\"" ?>><?php xl('Type','e'); ?></a>
230 </th>
232 <th><a href="nojs.php" onclick="return dosort('comment')"
233 <?php if ($form_orderby == "comment") echo " style=\"color:#00cc00\"" ?>><?php xl('Comment','e'); ?></a>
234 </th>
236 </thead>
237 <tbody>
238 <!-- added for better print-ability -->
239 <?php
241 $lastdocname = "";
242 $appointments = fetchAppointments( $from_date, $to_date, $patient, $provider, $facility );
244 if ( $show_available_times ) {
245 $availableSlots = getAvailableSlots( $from_date, $to_date, $provider, $facility );
246 $appointments = array_merge( $appointments, $availableSlots );
249 $appointments = sortAppointments( $appointments, $form_orderby );
251 foreach ( $appointments as $appointment ) {
252 $patient_id = $appointment['pid'];
253 $docname = $appointment['ulname'] . ', ' . $appointment['ufname'] . ' ' . $appointment['umname'];
254 $errmsg = "";
259 <tr bgcolor='<?php echo $bgcolor ?>'>
260 <td class="detail">&nbsp;<?php echo ($docname == $lastdocname) ? "" : $docname ?>
261 </td>
263 <td class="detail"><?php echo oeFormatShortDate($appointment['pc_eventDate']) ?>
264 </td>
266 <td class="detail"><?php echo oeFormatTime($appointment['pc_startTime']) ?>
267 </td>
269 <td class="detail">&nbsp;<?php echo $appointment['fname'] . " " . $appointment['lname'] ?>
270 </td>
272 <td class="detail">&nbsp;<?php echo $appointment['pubpid'] ?></td>
274 <td class="detail">&nbsp;<?php echo xl_appt_category($appointment['pc_catname']) ?>
275 </td>
277 <td class="detail">&nbsp;<?php echo $appointment['pc_hometext'] ?></td>
279 </tr>
281 <?php
282 $lastdocname = $docname;
286 </tbody>
287 </table>
288 </div>
289 <!-- end of search results --> <?php } else { ?>
290 <div class='text'><?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
291 </div>
292 <?php } ?> <input type="hidden" name="form_orderby"
293 value="<?php echo $form_orderby ?>" /> <input type="hidden"
294 name="patient" value="<?php echo $patient ?>" /> <input type='hidden'
295 name='form_refresh' id='form_refresh' value='' /></form>
297 <script>
299 <?php
300 if ($alertmsg) { echo " alert('$alertmsg');\n"; }
303 </script>
305 </body>
307 <!-- stuff for the popup calendar -->
308 <style type="text/css">
309 @import url(../../library/dynarch_calendar.css);
310 </style>
311 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
312 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
313 <script type="text/javascript"
314 src="../../library/dynarch_calendar_setup.js"></script>
315 <script language="Javascript">
316 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
317 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
318 </script>
320 </html>