2 // Copyright (C) 2005-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 report shows upcoming appointments with filtering and
10 // sorting by patient, practitioner, appointment type, and date.
11 // 2012-01-01 - Added display of home and cell phone and fixed header
13 require_once("../globals.php");
14 require_once("../../library/patient.inc");
15 require_once("$srcdir/formatting.inc.php");
16 require_once "$srcdir/options.inc.php";
17 require_once "$srcdir/formdata.inc.php";
18 require_once "$srcdir/appointments.inc.php";
20 $alertmsg = ''; // not used yet but maybe later
21 $patient = $_REQUEST['patient'];
23 if ($patient && ! $_POST['form_from_date']) {
24 // If a specific patient, default to 2 years ago.
26 $from_date = date("$tmp-m-d");
28 $from_date = fixDate($_POST['form_from_date'], date('Y-m-d'));
29 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
32 $show_available_times = false;
33 if ( $_POST['form_show_available'] ) {
34 $show_available_times = true;
37 $chk_with_out_provider = false;
38 if ( $_POST['with_out_provider'] ) {
39 $chk_with_out_provider = true;
42 $chk_with_out_facility = false;
43 if ( $_POST['with_out_facility'] ) {
44 $chk_with_out_facility = true;
47 //$to_date = fixDate($_POST['form_to_date'], '');
48 $provider = $_POST['form_provider'];
49 $facility = $_POST['form_facility']; //(CHEMED) facility filter
50 $form_orderby = getComparisonOrder( $_REQUEST['form_orderby'] ) ?
$_REQUEST['form_orderby'] : 'date';
57 <?php
html_header_show();?
>
59 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
61 <title
><?php
xl('Appointments Report','e'); ?
></title
>
63 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
64 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
65 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
66 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
68 <script type
="text/javascript">
70 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
72 function dosort(orderby
) {
73 var f
= document
.forms
[0];
74 f
.form_orderby
.value
= orderby
;
79 function oldEvt(eventid
) {
80 dlgopen('../main/calendar/add_edit_event.php?eid=' + eventid
, 'blank', 550, 270);
83 function refreshme() {
85 document
.forms
[0].submit();
90 <style type
="text/css">
91 /* specifically include & exclude from printing */
97 #report_parameters_daterange {
101 #report_results table {
106 /* specifically exclude some from the screen */
108 #report_parameters_daterange {
116 <body
class="body_top">
118 <!-- Required
for the popup date selectors
-->
120 style
="position: absolute; visibility: hidden; z-index: 1000;"></div
>
122 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Appointments','e'); ?
></span
>
124 <div id
="report_parameters_daterange"><?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
127 <form method
='post' name
='theform' id
='theform' action
='appointments_report.php'>
129 <div id
="report_parameters">
134 <div style
='float: left'>
138 <td
class='label'><?php
xl('Facility','e'); ?
>:</td
>
139 <td
><?php
dropdown_facility(strip_escape_custom($facility), 'form_facility'); ?
>
141 <td
class='label'><?php
xl('Provider','e'); ?
>:</td
>
144 // Build a drop-down list of providers.
147 $query = "SELECT id, lname, fname FROM users WHERE ".
148 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
150 $ures = sqlStatement($query);
152 echo " <select name='form_provider'>\n";
153 echo " <option value=''>-- " . xl('All') . " --\n";
155 while ($urow = sqlFetchArray($ures)) {
156 $provid = $urow['id'];
157 echo " <option value='$provid'";
158 if ($provid == $_POST['form_provider']) echo " selected";
159 echo ">" . $urow['lname'] . ", " . $urow['fname'] . "\n";
165 <td
><input type
='checkbox' name
='form_show_available'
166 title
='<?php xl('Show Available Times
','e
'); ?>'
167 <?php
if ( $show_available_times ) echo ' checked'; ?
>> <?php
xl( 'Show Available Times','e' ); ?
>
171 <td
class='label'><?php
xl('From','e'); ?
>:</td
>
172 <td
><input type
='text' name
='form_from_date' id
="form_from_date"
173 size
='10' value
='<?php echo $form_from_date ?>'
174 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
175 title
='yyyy-mm-dd'> <img src
='../pic/show_calendar.gif'
176 align
='absbottom' width
='24' height
='22' id
='img_from_date'
177 border
='0' alt
='[?]' style
='cursor: pointer'
178 title
='<?php xl('Click here to choose a date
','e
'); ?>'></td
>
179 <td
class='label'><?php
xl('To','e'); ?
>:</td
>
180 <td
><input type
='text' name
='form_to_date' id
="form_to_date"
181 size
='10' value
='<?php echo $form_to_date ?>'
182 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)'
183 title
='yyyy-mm-dd'> <img src
='../pic/show_calendar.gif'
184 align
='absbottom' width
='24' height
='22' id
='img_to_date'
185 border
='0' alt
='[?]' style
='cursor: pointer'
186 title
='<?php xl('Click here to choose a date
','e
'); ?>'></td
>
190 <td
class='label'><?php
xl('Status','e'); ?
>:</td
>
191 <td
><?php
generate_form_field(array('data_type'=>1,'field_id'=>'apptstatus','list_id'=>'apptstat','empty_title'=>'All'),$_POST['form_apptstatus']);?
></td
>
192 <td colspan
="2"> 
;</td
>
196 <td colspan
="2"><input type
="checkbox" name
="with_out_provider" id
="with_out_provider" <?php
if($chk_with_out_provider) echo "checked";?
>> 
;<?php
xl('Without Provider','e'); ?
></td
>
197 <td colspan
="2"><input type
="checkbox" name
="with_out_facility" id
="with_out_facility" <?php
if($chk_with_out_facility) echo "checked";?
>> 
;<?php
xl('Without Facility','e'); ?
></td
>
205 <td align
='left' valign
='middle' height
="100%">
206 <table style
='border-left: 1px solid; width: 100%; height: 100%'>
209 <div style
='margin-left: 15px'>
210 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
211 <span
> <?php
xl('Submit','e'); ?
> </span
> </a
>
212 <?php
if ($_POST['form_refresh'] ||
$_POST['form_orderby'] ) { ?
>
213 <a href
='#' class='css_button' onclick
='window.print()'>
214 <span
> <?php
xl('Print','e'); ?
> </span
> </a
>
215 <a href
='#' class='css_button' onclick
='window.open("../patient_file/printed_fee_sheet.php?fill=2","_blank")'>
216 <span
> <?php
xl('Superbills','e'); ?
> </span
> </a
>
220 <tr
> 
; 
;<?php
xl('Most column headers can be clicked to change sort order','e') ?
></tr
>
227 <!-- end of search parameters
--> <?php
228 if ($_POST['form_refresh'] ||
$_POST['form_orderby']) {
230 <div id
="report_results">
234 <th
><a href
="nojs.php" onclick
="return dosort('doctor')"
235 <?php
if ($form_orderby == "doctor") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Provider','e'); ?
>
238 <th
><a href
="nojs.php" onclick
="return dosort('date')"
239 <?php
if ($form_orderby == "date") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Date','e'); ?
></a
>
242 <th
><a href
="nojs.php" onclick
="return dosort('time')"
243 <?php
if ($form_orderby == "time") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Time','e'); ?
></a
>
246 <th
><a href
="nojs.php" onclick
="return dosort('patient')"
247 <?php
if ($form_orderby == "patient") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Patient','e'); ?
></a
>
250 <th
><a href
="nojs.php" onclick
="return dosort('pubpid')"
251 <?php
if ($form_orderby == "pubpid") echo " style=\"color:#00cc00\"" ?
>><?php
xl('ID','e'); ?
></a
>
254 <th
><?php
xl('Home','e'); //Sorting by phone# not really useful ?></th>
256 <th
><?php
xl('Cell','e'); //Sorting by phone# not really useful ?></th>
258 <th
><a href
="nojs.php" onclick
="return dosort('type')"
259 <?php
if ($form_orderby == "type") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Type','e'); ?
></a
>
262 <th
><a href
="nojs.php" onclick
="return dosort('status')"
263 <?php
if ($form_orderby == "status") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Status','e'); ?
></a
>
266 <th
><a href
="nojs.php" onclick
="return dosort('comment')"
267 <?php
if ($form_orderby == "comment") echo " style=\"color:#00cc00\"" ?
>><?php
xl('Comment','e'); ?
></a
>
272 <!-- added
for better
print-ability
-->
276 //Appointment Status Checking
277 $form_apptstatus = $_POST['form_apptstatus'];
279 //Without provider and facility data checking
280 $with_out_provider = null;
281 $with_out_facility = null;
283 if( isset($_POST['with_out_provider']) ){
284 $with_out_provider = $_POST['with_out_provider'];
287 if( isset($_POST['with_out_facility']) ){
288 $with_out_facility = $_POST['with_out_facility'];
290 $appointments = fetchAppointments( $from_date, $to_date, $patient, $provider, $facility, $form_apptstatus, $with_out_provider, $with_out_facility );
292 if ( $show_available_times ) {
293 $availableSlots = getAvailableSlots( $from_date, $to_date, $provider, $facility );
294 $appointments = array_merge( $appointments, $availableSlots );
297 $appointments = sortAppointments( $appointments, $form_orderby );
298 $pid_list = array(); // Initialize list of PIDs for Superbill option
299 $totalAppontments = count($appointments);
301 foreach ( $appointments as $appointment ) {
302 array_push($pid_list,$appointment['pid']);
303 $patient_id = $appointment['pid'];
304 $docname = $appointment['ulname'] . ', ' . $appointment['ufname'] . ' ' . $appointment['umname'];
307 $pc_apptstatus = $appointment['pc_apptstatus'];
311 <tr bgcolor
='<?php echo $bgcolor ?>'>
312 <td
class="detail"> 
;<?php
echo ($docname == $lastdocname) ?
"" : $docname ?
>
315 <td
class="detail"><?php
echo oeFormatShortDate($appointment['pc_eventDate']) ?
>
318 <td
class="detail"><?php
echo oeFormatTime($appointment['pc_startTime']) ?
>
321 <td
class="detail"> 
;<?php
echo $appointment['fname'] . " " . $appointment['lname'] ?
>
324 <td
class="detail"> 
;<?php
echo $appointment['pubpid'] ?
></td
>
326 <td
class="detail"> 
;<?php
echo $appointment['phone_home'] ?
></td
>
328 <td
class="detail"> 
;<?php
echo $appointment['phone_cell'] ?
></td
>
330 <td
class="detail"> 
;<?php
echo xl_appt_category($appointment['pc_catname']) ?
></td
>
332 <td
class="detail"> 
;
335 if($pc_apptstatus != ""){
336 $frow['data_type']=1;
337 $frow['list_id']='apptstat';
338 generate_print_field($frow, $pc_apptstatus);
343 <td
class="detail"> 
;<?php
echo $appointment['pc_hometext'] ?
></td
>
348 $lastdocname = $docname;
350 // assign the session key with the $pid_list array - note array might be empty -- handle on the printed_fee_sheet.php page.
351 $_SESSION['pidList'] = $pid_list;
354 <td colspan
="10" align
="left"><?php
xl('Total number of appointments','e'); ?
>: 
;<?php
echo $totalAppontments;?
></td
>
359 <!-- end of search results
--> <?php
} else { ?
>
360 <div
class='text'><?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
362 <?php
} ?
> <input type
="hidden" name
="form_orderby"
363 value
="<?php echo $form_orderby ?>" /> <input type
="hidden"
364 name
="patient" value
="<?php echo $patient ?>" /> <input type
='hidden'
365 name
='form_refresh' id
='form_refresh' value
='' /></form
>
367 <script type
="text/javascript">
370 if ($alertmsg) { echo " alert('$alertmsg');\n"; }
377 <!-- stuff
for the popup calendar
-->
378 <style type
="text/css">
379 @import
url(../../library
/dynarch_calendar
.css
);
381 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
382 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
383 <script type
="text/javascript"
384 src
="../../library/dynarch_calendar_setup.js"></script
>
385 <script type
="text/javascript">
386 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
387 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});