From 406cc0214aeac35dfac7e7f4057641281f85f20d Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 5 Feb 2008 02:13:01 +0000 Subject: [PATCH] Facility option contributed by Nethanel Vilensky --- interface/reports/appointments_report.php | 474 ++++++++++++++++-------------- 1 file changed, 251 insertions(+), 223 deletions(-) diff --git a/interface/reports/appointments_report.php b/interface/reports/appointments_report.php index 3a83a0c7e..61b326b4c 100644 --- a/interface/reports/appointments_report.php +++ b/interface/reports/appointments_report.php @@ -1,223 +1,251 @@ - - // - // 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 report shows upcoming appointments with filtering and - // sorting by patient, practitioner, appointment type, and date. - - include_once("../globals.php"); - include_once("../../library/patient.inc"); - - $alertmsg = ''; // not used yet but maybe later - - // For each sorting option, specify the ORDER BY argument. - // - $ORDERHASH = array( - 'doctor' => 'lower(u.lname), lower(u.fname), pc_eventDate, pc_startTime', - 'patient' => 'lower(p.lname), lower(p.fname), pc_eventDate, pc_startTime', - 'time' => 'pc_eventDate, pc_startTime, lower(u.lname), lower(u.fname)', - 'type' => 'pc_catname, pc_eventDate, pc_startTime, lower(u.lname), lower(u.fname)' - ); - - function bucks($amount) { - if ($amount) - printf("%.2f", $amount); - } - - $patient = $_REQUEST['patient']; - - if ($patient && ! $_POST['form_from_date']) { - // If a specific patient, default to 2 years ago. - $tmp = date('Y') - 2; - $from_date = date("$tmp-m-d"); - } else { - $from_date = fixDate($_POST['form_from_date'], date('Y-m-d')); - } - $to_date = fixDate($_POST['form_to_date'], ''); - $provider = $_POST['form_provider']; - - $form_orderby = $ORDERHASH[$_REQUEST['form_orderby']] ? - $_REQUEST['form_orderby'] : 'time'; - $orderby = $ORDERHASH[$form_orderby]; - - $where = "e.pc_pid != '' AND e.pc_eventDate >= '$from_date'"; - - if ($to_date ) $where .= " AND e.pc_eventDate <= '$to_date'"; - if ($provider) $where .= " AND e.pc_aid = '$provider'"; - if ($patient ) $where .= " AND e.pc_pid = '$patient'"; - - // Get the info. - // - $query = "SELECT " . - "e.pc_eventDate, e.pc_startTime, e.pc_catid, e.pc_eid, " . - "p.fname, p.mname, p.lname, p.pid, " . - "u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " . - "c.pc_catname " . - "FROM openemr_postcalendar_events AS e " . - "LEFT OUTER JOIN patient_data AS p ON p.pid = e.pc_pid " . - "LEFT OUTER JOIN users AS u ON u.id = e.pc_aid " . - "LEFT OUTER JOIN openemr_postcalendar_categories AS c ON c.pc_catid = e.pc_catid " . - "WHERE $where ORDER BY $orderby"; - - $res = sqlStatement($query); -?> - - - -<?php xl('Appointments Report','e'); ?> - - - - - - - - - - - - - - - -
- -

- -
- - - - - - - - - - - -
- : -\n"; - echo "
-
- - - - - - - - - - - - - - - - - - -
- > - - > - - > - - > -
-   - -  )'> - - - -   - -   -
- - - - -
-
- - - + + // + // 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 report shows upcoming appointments with filtering and + // sorting by patient, practitioner, appointment type, and date. + + include_once("../globals.php"); + include_once("../../library/patient.inc"); + + $alertmsg = ''; // not used yet but maybe later + + // For each sorting option, specify the ORDER BY argument. + // + $ORDERHASH = array( + 'doctor' => 'lower(u.lname), lower(u.fname), pc_eventDate, pc_startTime', + 'patient' => 'lower(p.lname), lower(p.fname), pc_eventDate, pc_startTime', + 'time' => 'pc_eventDate, pc_startTime, lower(u.lname), lower(u.fname)', + 'type' => 'pc_catname, pc_eventDate, pc_startTime, lower(u.lname), lower(u.fname)' + ); + + function bucks($amount) { + if ($amount) + printf("%.2f", $amount); + } + + $patient = $_REQUEST['patient']; + + if ($patient && ! $_POST['form_from_date']) { + // If a specific patient, default to 2 years ago. + $tmp = date('Y') - 2; + $from_date = date("$tmp-m-d"); + } else { + $from_date = fixDate($_POST['form_from_date'], date('Y-m-d')); + } + $to_date = fixDate($_POST['form_to_date'], ''); + $provider = $_POST['form_provider']; + $facility = $_POST['form_facility']; //(CHEMED) facility filter + + $form_orderby = $ORDERHASH[$_REQUEST['form_orderby']] ? + $_REQUEST['form_orderby'] : 'time'; + $orderby = $ORDERHASH[$form_orderby]; + + $where = "e.pc_pid != '' AND e.pc_eventDate >= '$from_date'"; + + if ($to_date ) $where .= " AND e.pc_eventDate <= '$to_date'"; + if ($provider) $where .= " AND e.pc_aid = '$provider'"; + //(CHEMED) facility filter + $facility_filter = ''; + if ($facility) { + $event_facility_filter = " AND e.pc_facility = '$facility'"; + $provider_facility_filter = " AND users.facility_id = '$facility'"; + } + //END (CHEMED) + if ($patient ) $where .= " AND e.pc_pid = '$patient'"; + + // Get the info. + // + $query = "SELECT " . + "e.pc_eventDate, e.pc_startTime, e.pc_catid, e.pc_eid, " . + "p.fname, p.mname, p.lname, p.pid, " . + "u.fname AS ufname, u.mname AS umname, u.lname AS ulname, " . + "c.pc_catname " . + "FROM openemr_postcalendar_events AS e " . + "LEFT OUTER JOIN patient_data AS p ON p.pid = e.pc_pid " . + "LEFT OUTER JOIN users AS u ON u.id = e.pc_aid " . + "LEFT OUTER JOIN openemr_postcalendar_categories AS c ON c.pc_catid = e.pc_catid " . + "WHERE $where $event_facility_filter ORDER BY $orderby"; //(CHEMED) facility filter + + $res = sqlStatement($query); +?> + + + +<?php xl('Appointments Report','e'); ?> + + + + + + + + + + + + + + + +
+ +

+ +
+ + + + + + + + + + + +
+\n"; + echo "
+
+ + + + + + + + + + + + + + + + + + +
+ > + + > + + > + + > +
+   + +  )'> + + + +   + +   +
+ + + + +
+
+ + + -- 2.11.4.GIT