If the above just doesn’t work and no one knows how … assuming that I know how to query the openemr database directly, how to I query (SQL) for the patients who have not had an appointment (encounter) in the past 3 months?
–Ralf
Doc,
Here is the Query that you can use to get your report:
select p.fname,o.pc_pid from patient_data p inner join openemr_postcalendar_events o ON pc_pid=pid where pc_eventdate NOT BETWEEN (NOW() - INTERVAL 90 DAY) AND NOW();
However, you may want to consider using a custom report form to save time and flexibility in getting reports.
-sm/sp
-visolve OpenEMR Support
Also, when I try to create my own reminder, I get the following query error:
Query Error
ERROR: query failed: SELECT pc_eventDate FROM openemr_postcalendar_events WHERE pc_eventDate>? AND pid=? AND (date BETWEEN DATE_SUB(‘2019-07-03 10:29:05’, INTERVAL 3 MONTH) AND ‘2019-07-03 10:29:05’)
Error: Unknown column ‘pid’ in ‘where clause’
/var/www/localhost/htdocs/openemr/library/sql.inc at 171:sqlStatementNoLog
/var/www/localhost/htdocs/openemr/library/clinical_rules.php at 1961:sqlStatementCdrEngine(SELECT pc_eventDate FROM openemr_postcalendar_events WHERE pc_eventDate>? AND pid=? AND (date BETWEEN DATE_SUB(‘2019-07-03 10:29:05’, INTERVAL 3 MONTH) AND ‘2019-07-03 10:29:05’) ,Array)
/var/www/localhost/htdocs/openemr/library/clinical_rules.php at 1717:exist_database_item(307,openemr_postcalendar_events,pc_eventDate,gt,STR_TO_DATE(‘Dec 31, 2018’,’%M %d,%Y’),lt,1,month,3,2019-07-03 10:29:05)
/var/www/localhost/htdocs/openemr/library/clinical_rules.php at 1241:database_check(307,Array,Array,2019-07-03 10:29:05)
/var/www/localhost/htdocs/openemr/library/clinical_rules.php at 820:test_targets(307,rule_102,2019-07-03 10:29:05)
/var/www/localhost/htdocs/openemr/library/reminders.php at 220:test_rules_clinic(,patient_reminder,2019-04-03 10:29:05,reminders-due,307)
/var/www/localhost/htdocs/openemr/library/reminders.php at 49:update_reminders(2019-04-03 10:29:05,307)
/var/www/localhost/htdocs/openemr/interface/patient_file/summary/patient_reminders_fragment.php at 24:patient_reminder_widget(307)
My Bad…The query report shows all of the reminders which are more than 90 days old…So, you may get multiple reminder for the same patients.
Here is the correct query which will give unique patients who did not have appointments for the past 90 days…
select p.fname,p.pid from patient_data p where pid not in (select distinct pc_pid from openemr_postcalendar_events where pc_eventdate BETWEEN (CURDATE() - INTERVAL 90 DAY) AND CURDATE());
I’m going to try ViSolve’s recommendation and wait for an official patch because it is the safest approach because I only have a production system … and I’m not going to fool myself into thinking that I can maintain a development system and properly test changes that I make … Thank you so much, everyone!