From 8278e2cb08875734b5028a3ad5affe8b6ba95cd3 Mon Sep 17 00:00:00 2001 From: teryhill Date: Tue, 12 Aug 2014 13:55:19 -0700 Subject: [PATCH] Allows display of appointments in descending order, take 2. --- interface/patient_file/summary/demographics.php | 17 ++++++++++++++--- library/globals.inc.php | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/interface/patient_file/summary/demographics.php b/interface/patient_file/summary/demographics.php index d631dcfed..75e5828fa 100644 --- a/interface/patient_file/summary/demographics.php +++ b/interface/patient_file/summary/demographics.php @@ -1354,7 +1354,18 @@ expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, } // Show PAST appointments. - if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['num_past_appointments_to_show'] > 0) { + // added by Terry Hill to allow reverse sorting of the appointments + $direction = "ASC"; + if ($GLOBALS['num_past_appointments_to_show'] < 0) { + $direction = "DESC"; + ($showpast = -1 * $GLOBALS['num_past_appointments_to_show'] ); + } + else + { + $showpast = $GLOBALS['num_past_appointments_to_show']; + } + + if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0) { $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " . "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " . "c.pc_catname, e.pc_apptstatus " . @@ -1362,8 +1373,8 @@ expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, "openemr_postcalendar_categories AS c WHERE " . "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " . "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " . - "ORDER BY e.pc_eventDate, e.pc_startTime DESC " . - "LIMIT " . $GLOBALS['num_past_appointments_to_show']; + "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " . + "LIMIT " . $showpast; $pres = sqlStatement($query, array($pid) ); diff --git a/library/globals.inc.php b/library/globals.inc.php index ff95af3c7..8419f7cf6 100644 --- a/library/globals.inc.php +++ b/library/globals.inc.php @@ -638,7 +638,7 @@ $GLOBALS_METADATA = array( xl('Past Appointment Display Widget'), 'num', // data type '0', // default = false - xl('A positive number will show that many past appointments on a Widget in the Patient Summary screen.') + xl('A positive number will show that many past appointments on a Widget in the Patient Summary screen (a negative number will show the past appointments in descending order)') ), 'activate_ccr_ccd_report' => array( @@ -695,6 +695,7 @@ $GLOBALS_METADATA = array( xl('This specifies whether to include date in Box 31.') ), + ), // E-Sign Tab // -- 2.11.4.GIT