Past Appointment Widget, Configurable in Globals Features
authortmccormi <tony@mi-squared.com>
Thu, 8 Nov 2012 05:39:46 +0000 (7 21:39 -0800)
committertmccormi <tony@mi-squared.com>
Fri, 9 Nov 2012 05:39:53 +0000 (8 21:39 -0800)
interface/patient_file/summary/demographics.php
library/globals.inc.php

index 9b1d42e..abb2188 100644 (file)
@@ -1174,7 +1174,7 @@ expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
        if (isset($pid) && !$GLOBALS['disable_calendar']) {
         $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 " .
+         "c.pc_catname, e.pc_apptstatus " .
          "FROM openemr_postcalendar_events AS e, users AS u, " .
          "openemr_postcalendar_categories AS c WHERE " .
          "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
@@ -1182,61 +1182,117 @@ expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
          "ORDER BY e.pc_eventDate, e.pc_startTime";
         $res = sqlStatement($query, array($pid) );
 
-        if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
-          // clinical summary expand collapse widget
-         $widgetTitle = xl("Clinical Reminders");
-         $widgetLabel = "clinical_reminders";
-         $widgetButtonLabel = xl("Edit");
-         $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
-         $widgetButtonClass = "";
-         $linkMethod = "html";
-         $bodyClass = "summary_item small";
-         $widgetAuth = true;
-         $fixedWidth = false;
-         expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
-          echo "<br/>";
-          echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
-         echo "</div>";
+     if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
+        // clinical summary expand collapse widget
+        $widgetTitle = xl("Clinical Reminders");
+        $widgetLabel = "clinical_reminders";
+        $widgetButtonLabel = xl("Edit");
+        $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
+        $widgetButtonClass = "";
+        $linkMethod = "html";
+        $bodyClass = "summary_item small";
+        $widgetAuth = true;
+        $fixedWidth = false;
+        expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
+        echo "<br/>";
+        echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
+        echo "</div>";
         } // end if crw
 
        // appointments expand collapse widget
-       $widgetTitle = xl("Appointments");
-       $widgetLabel = "appointments";
-       $widgetButtonLabel = xl("Add");
-       $widgetButtonLink = "return newEvt();";
-       $widgetButtonClass = "";
-       $linkMethod = "javascript";
-       $bodyClass = "summary_item small";
-       $widgetAuth = (isset($res) && $res != null);
-       $fixedWidth = false;
-       expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
+        $widgetTitle = xl("Appointments");
+        $widgetLabel = "appointments";
+        $widgetButtonLabel = xl("Add");
+        $widgetButtonLink = "return newEvt();";
+        $widgetButtonClass = "";
+        $linkMethod = "javascript";
+        $bodyClass = "summary_item small";
+        $widgetAuth = (isset($res) && $res != null);
+        $fixedWidth = false;
+        expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
+        $count = 0;
+        while($row = sqlFetchArray($res)) {
+            $count++;
+            $dayname = date("l", strtotime($row['pc_eventDate']));
+            $dispampm = "am";
+            $disphour = substr($row['pc_startTime'], 0, 2) + 0;
+            $dispmin  = substr($row['pc_startTime'], 3, 2);
+            if ($disphour >= 12) {
+                $dispampm = "pm";
+                if ($disphour > 12) $disphour -= 12;
+            }
+            $etitle = xl('(Click to edit)');
+            if ($row['pc_hometext'] != "") {
+                $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
+            }
+            echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
+            echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") .  "(";
+            echo " " .  generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>";   // can't use special char parser on this
+            echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
+            echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
+        }
+        if (isset($res) && $res != null) {
+            if ( $count < 1 ) { 
+                echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); 
+            }
+            echo "</div>";
+      }
+    }
+            
+       // Show PAST appointments.
+       if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['num_past_appointments_to_show'] > 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 " .
+         "FROM openemr_postcalendar_events AS e, users AS u, " .
+         "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'];
+       
+     $pres = sqlStatement($query, array($pid) );
 
-                        $count = 0;
-                        while($row = sqlFetchArray($res)) {
-                         $count++;
-                         $dayname = date("l", strtotime($row['pc_eventDate']));
-                         $dispampm = "am";
-                         $disphour = substr($row['pc_startTime'], 0, 2) + 0;
-                         $dispmin  = substr($row['pc_startTime'], 3, 2);
-                         if ($disphour >= 12) {
-                          $dispampm = "pm";
-                          if ($disphour > 12) $disphour -= 12;
-                         }
-                         $etitle = xl('(Click to edit)');
-                         if ($row['pc_hometext'] != "") {
-                               $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
-                         }
-              echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
-               ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
-                         echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
-                         echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
-                         echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
-                        }
-                        if (isset($res) && $res != null) {
-                               if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); }
-                               echo "</div>";
-                        }
-                       }
+       // appointments expand collapse widget
+        $widgetTitle = xl("Past Appoinments");
+        $widgetLabel = "past_appointments";
+        $widgetButtonLabel = '';
+        $widgetButtonLink = '';
+        $widgetButtonClass = '';
+        $linkMethod = "javascript";
+        $bodyClass = "summary_item small";
+        $widgetAuth = false; //no button
+        $fixedWidth = false;
+        expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);   
+        $count = 0;
+        while($row = sqlFetchArray($pres)) {
+            $count++;
+            $dayname = date("l", strtotime($row['pc_eventDate']));
+            $dispampm = "am";
+            $disphour = substr($row['pc_startTime'], 0, 2) + 0;
+            $dispmin  = substr($row['pc_startTime'], 3, 2);
+            if ($disphour >= 12) {
+                $dispampm = "pm";
+                if ($disphour > 12) $disphour -= 12;
+            }
+            if ($row['pc_hometext'] != "") {
+                $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
+            }
+            echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
+            echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b>" . xlt("Status") .  "(";
+            echo " " .  generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>";   // can't use special char parser on this
+            echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
+            echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
+        }
+        if (isset($pres) && $res != null) {
+           if ( $count < 1 ) { 
+               echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);          
+           }
+        echo "</div>";
+        }
+    }
+// END of past appointments            
+            
                        ?>
                </div>
 
index 40c6a97..0e198ac 100644 (file)
@@ -595,6 +595,13 @@ $GLOBALS_METADATA = array(
       '0',                              // default = false
       xl('This will force the Billing Widget in the Patient Summary screen to always be open.')
     ),
+      
+    'num_past_appointments_to_show' => 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.')
+    ),      
 
     'activate_ccr_ccd_report' => array(
       xl('Activate CCR/CCD Reporting'),