Wow,
That is so cool and minimal code, so I have committed this to sourceforge. Regarding the session timeout issue, I’ll leave it open tonight and see if it timeouts (since now using this autocheck feature in both the messages.php and left_nav.php script now.
-brady
1) Just committed minor bug fix (placed a missing top.restoreSession(); call)
2) The timeout function appears to be broken by the auto refresh call. But think there is a simple work-around. Code that checks for timeout is here in library/auth.inc:
if (!isset($_SESSION["last_update"])) {
authLoginScreen();
} else {
//if page has not been updated in a given period of time, we call login screen
if ((time() - $_SESSION["last_update"]) > $timeout) {
newEvent("logout", $_SESSION['authUser'], $_SESSION['authProvider'], 0, "timeout");
authCloseSession();
authLoginScreen();
} else {
if (empty($GLOBALS['DAEMON_FLAG'])) $_SESSION["last_update"] = time();
}
}
So, I think just making a parameter called skip_timeout=1 in the script calls of the repeater functions; can then use this parameter to skip the $_SESSION = time() command. This should effectively provide a mechanism to not incorporate the auto functions into the timeout mechanism.
integrated and tested from last night’s dev tip.
First, the reminders in the message area aren’t that useful for things like !Hey! stop! you client needs a new treatment plan!. That should still be a global setting option to display high level reminders in the title bar.
Next is a real problem. I set a reminder for patient 899, but the name for patient 898 shows up!
Bug-o-licious.
Best to test this stuff against a large database.
Found the original top menu version of the code organization in the readme file…thanks for providing some documentation! This is done too seldom. I wish we could make a habit of popping “feature documentation” into the docs area, and creating a menu there.
Actually, that sounds like a really nice project in of itself….a little HTML page or php that looks for files in it’s folder and displays them as a list when you hit the “manual” button.
HA!
It wasn’t tested against a large database. It decrements PID’s over two digits! Usa a patient with ID 99 or less, and you are good to go. Try 100, and you get 99!
Seems like there are TWO files named dated_reminders.php…not fun. Didn’t realize that until I saw that it was included in a file with the same name….blew my little brain for a bit.
Looks like the issue is somewhere in library/dated_reminders.php. Table data was accurate looking, but I imagine that there might be some structure issues, since I can’t find a - or a -= looking dealie, and php sql queries with arrays make my eyes hurt to look at.
// ----- sql statement for getting uncompleted reminders (sorts by date, then by priority)
$drSQL = sqlStatement(
"SELECT
dr.pid, dr.dr_id, dr.dr_message_text,dr.dr_message_due_date,
u.fname ffname, u.mname fmname, u.lname flname
FROM `dated_reminders` dr
JOIN `users` u ON dr.dr_from_ID = u.id
JOIN `dated_reminders_link` drl ON dr.dr_id = drl.dr_id
WHERE drl.to_id = ?
AND dr.`message_processed` = 0
AND dr.`dr_message_due_date` < ADDDATE(NOW(), INTERVAL $days_to_show DAY)
ORDER BY `dr_message_due_date` ASC , `message_priority` ASC LIMIT 0,$alerts_to_show"
, array($userID)
);
// --------- loop through the results
for($i=0; $drRow=sqlFetchArray($drSQL); $i++){
// --------- need to run patient query seperately to allow for reminders not linked to a patient
$pSQL = sqlStatement("SELECT pd.title ptitle, pd.fname pfname, pd.mname pmname, pd.lname plname FROM `patient_data` pd WHERE pd.id = ?",array($drRow['pid']));
$pRow = sqlFetchArray($pSQL);
// --------- fill the $reminders array
$reminders[$i]['messageID'] = $drRow['dr_id'];
$reminders[$i]['PatientID'] = $drRow['pid'];
// ------------------------------------- if there was a patient linked, set the name, else set it to blank
$reminders[$i]['PatientName'] = (empty($pRow) ? '' : $pRow['ptitle'].' '.$pRow['pfname'].' '.$pRow['pmname'].' '.$pRow['plname']);
// -------------------------------------
$reminders[$i]['message'] = $drRow['dr_message_text'];
$reminders[$i]['dueDate'] = $drRow['dr_message_due_date'];
$reminders[$i]['fromName'] = $drRow['ffname'].' '.$drRow['fmname'].' '.$drRow['flname'];
// --------- if the message is due or overdue set $hasAlerts to true, this will stop autohiding of reminders
if(strtotime($drRow['dr_message_due_date']) <= $today) $hasAlerts = true;
}
a quick question that may be a clue to this bug, I still can’t recreate this bug.
when you linked the reminder to a patient, did you use the “linking” mechanism in the new reminder popup or did you open the patient record in OpenEMR and then send a new reminder ?
have you checked in the dated_reminders table if it is storing the patient id incorrectly ?