Query Error when attempting to add a recall for a patient

Situation
Query error when trying to add a recall for a patient.

OpenEMR Version
I’m using OpenEMR version 5.0.1(7)

Browser:
I’m using: Firefox or Chrome - reproducible with both

Operating System
I’m using:

Logs
Yes


ERROR: query failed: SELECT * FROM openemr_postcalendar_events AS cal LEFT JOIN patient_data AS pat ON cal.pc_pid=pat.pid WHERE cal.pc_eventDate = curdate() - interval 0 daycal.pc_eventDate <= curdate() - INTERVAL 0 DAY AND cal.pc_eventDate > (curdate() - INTERVAL '3' DAY) AND cal.pc_apptstatus in (?) AND cal.pc_aid in (?) AND cal.pc_facility in (?) AND cal.pc_pid NOT in ( SELECT msg_pid from medex_outgoing where campaign_uid =? and msg_date >= curdate() ) AND cal.pc_eid NOT IN ( SELECT DISTINCT msg_pc_eid from medex_outgoing where campaign_uid=? and msg_date >= curdate() ) ORDER BY cal.pc_eventDate,cal.pc_startTime

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'daycal.pc_eventDate <= curdate() - INTERVAL 0 DAY AND ' at line 5

/var/www/localhost/htdocs/openemr/library/MedEx/API.php at 1020:sqlStatement
/var/www/localhost/htdocs/openemr/library/MedEx/API.php at 3545:generate(KcMVk8KfjA1QQfUtYa3oivnX5TupszI9,Array)
/var/www/localhost/htdocs/openemr/library/MedEx/API.php at 3579:just_login(Array)
/var/www/localhost/htdocs/openemr/interface/main/messages/messages.php at 50:login()```

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'daycal.pc_eventDate <= curdate() - INTERVAL 0 DAY AND ’ at line 5

This is a bug. PR pending.

API.php - change line 937:

$target_dates .= "cal.pc_eventDate <= curdate() - INTERVAL “.$timing.” DAY AND

to

$target_dates .= " AND cal.pc_eventDate <= curdate() - INTERVAL “.$timing.” DAY AND

1 Like

Hello Ray,

That’s not what my API.php line 937 looks like … I will email you my current API.php to take a look at …

Thank you,
–Ralf

it’s line 1002 in your copy:

$target_dates .= " AND cal.pc_eventDate <= curdate() - INTERVAL “.$timing.” DAY AND

1 Like

Okay. Corrected.
Thank you,
–Ralf