Situation
When I try to add a prescription I get this error:
SQL Statement failed on preparation: SELECT lists.* ,medications.lists_medication_id ,medications.list_id ,medications.usage_category ,medications.usage_category_title ,medications.drug_dosage_instructions ,medications.request_intent ,medications.request_intent_title ,medications.medication_adherence_information_source ,medications.medication_adherence ,medications.medication_adherence_date_asserted ,medications.is_primary_record ,medications.reporting_source_record_id ,medications.reporting_source_uuid ,medications.reporting_source_type FROM lists LEFT JOIN ( SELECT lists_medication.id AS lists_medication_id ,list_id ,usage_category ,usage_category_title ,drug_dosage_instructions ,request_intent ,request_intent_title ,medication_adherence_information_source ,medication_adherence ,medication_adherence_date_asserted ,is_primary_record ,reporting_source_record_id ,users.uuid AS reporting_source_uuid ,‘user’ AS reporting_source_type FROM lists_medication LEFT JOIN users ON users.id = lists_medication.reporting_source_record_id ) medications ON medications.list_id = lists.id WHERE ((enddate IS NULL OR enddate = ‘’) OR enddate > ?) AND pid = ? ORDER BY lists.begdate ’
OpenEMR Version
I’m using OpenEMR version - 7.0.4
Browser:
I’m using: Firefox and Chrome
Operating System
I’m using: Linux, Ubuntu
Search
Did you search the forum for similar questions? yes
Logs
Did you check the logs? Yes
[Tue Feb 17 12:59:42.699440 2026] [php:notice] [pid 446252] [client 71.40.67.126:57900] DEBUG fragment: [ WHERE ((enddate IS NULL OR enddate = ‘’) OR enddate > ?) AND pid = ?], referer: http://71.40.67.126/controller.php?prescription&list&id=846
[Tue Feb 17 12:59:42.699461 2026] [php:notice] [pid 446252] [client 71.40.67.126:57900] DEBUG bindArray: Array
(
[0] => 2000-01-01 23:59:59.099900
[1] => 846
), referer: http://71.40.67.126/controller.php?prescription&list&id=846
[Tue Feb 17 12:59:42.711498 2026] [php:error] [pid 446252] [client 71.40.67.126:57900] PHP Fatal error: Uncaught OpenEMR\Common\Database\SqlQueryException: Failed to execute statement. Error: Incorrect DATETIME value: ‘’ Statement: SELECT lists.*
,medications.lists_medication_id
,medications.list_id
,medications.usage_category
,medications.usage_category_title
,medications.drug_dosage_instructions
,medications.request_intent
,medications.request_intent_title
,medications.medication_adherence_information_source
,medications.medication_adherence
,medications.medication_adherence_date_asserted
,medications.is_primary_record
,medications.reporting_source_record_id
,medications.reporting_source_uuid
,medications.reporting_source_type
FROM lists
LEFT JOIN (
SELECT
lists_medication.id AS lists_medication_id
,list_id
,usage_category
,usage_category_title
,drug_dosage_instructions
,request_intent
,request_intent_title
,medication_adherence_information_source
,medication_adherence
,medication_adherence_date_asserted
,is_primary_record
,reporting_source_record_id
,users.uuid AS reporting_source_uuid
,‘user’ AS reporting_source_type
FROM lists_medication
LEFT JOIN users ON users.id = lists_medication.reporting_source_record_id
) medications ON medications.list_id = lists.id WHERE ((enddate IS NULL OR enddate = ‘’) OR enddate > ?) AND pid = ? ORDER BY lists.begdate in /var/www/html/openemr/library/sql.inc.php:188
Stack trace:
#0 /var/www/html/openemr/src/Common/Database/QueryUtils.php(162): sqlStatementThrowException()
#1 /var/www/html/openemr/src/Services/PatientIssuesService.php(214): OpenEMR\Common\Database\QueryUtils::sqlStatementThrowException()
#2 /var/www/html/openemr/src/Services/PatientIssuesService.php(97): OpenEMR\Services\PatientIssuesService->search()
#3 /var/www/html/openemr/controllers/C_Prescription.class.php(1223): OpenEMR\Services\PatientIssuesService->getActiveIssues()
#4 /var/www/html/openemr/controllers/C_Prescription.class.php(152): C_Prescription->getDiagnosisCodesList()
#5 /var/www/html/openemr/library/classes/Controller.class.php(157): C_Prescription->edit_action()
#6 /var/www/html/openemr/controller.php(6): Controller->act()
#7 {main}
thrown in /var/www/html/openemr/library/sql.inc.php on line 188
The debug logs show the correct date value (2000-01-01 23:59:59.099900) is being passed in the bind array, but MySQL is still receiving an empty string for the DATETIME comparison. This occurs in PatientIssuesService->getActiveIssues() when trying to load the prescription form.