I’m having trouble isolation a problem I am having with the “Prescriptions” section of the patient data window. This is what I see:

The other panels (e.g. Medications) seem to work well, but I get this error message in the prescription panel. Opening the panel shows the same error:
If I drive on anyway and try to enter a prescription, then I get the following error message:
I’ve been trying to debug with both a PHP IDE and Chrome Javascript tools, but I haven’t been able to figure out what’s wrong. It seems like there might be an error in Prescription.class.php of using a patient id instead of pid, but this doesn’t seem to be the root cause of the problem.
Has anyone come across this before and, if so, found a solution?
you’re on the right track @Greg_Zancewicz, see how pid doesn’t have a value in the query?
so why isn’t it being populated?
could you check your php error log and report back? thanks
@stephenwaite - Thanks for the suggestion. Looking at the error log also pointed me to some other errors I wasn’t aware of.
The problem/bug/feature is in openemr/interface/patient_file/summary/demographics.php, around lines 105-119:
function get_document_by_catg($pid,$doc_catg) {
$result = array();
if ($pid and $doc_catg) {
$result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
"documents AS d, categories_to_documents AS cd, categories AS c " .
"WHERE d.foreign_id = ? " .
"AND cd.document_id = d.id " .
"AND c.id = cd.category_id " .
"AND c.name LIKE ? " .
"ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
}
return($result['id']);
}
Unfortunately I had been banging my head against the wall with the very first test patient I entered who, of course, was given a $pid of 0. The query never got issued and $result never got assigned a value because the result of (0 and anything) is false. Everything functioned fine for patient $pid=1.
There was something else going on that I haven’t bothered to troubleshoot, because even if I fix the comparison I still get a bogus result for $result (it evaluates to false). So I’m just deleting the patient with $pid=0 for now.
(I ran into another issue in all this: I can’t seem to delete a patient from within the phpAdmin instance brought up by Administration->Other->Database)
Hello @Greg_Zancewicz,
Can you please share the screen shot of the error message, when you try to delete a patient from phpMyadmin?
By-default, PId value starts with 1 in OpenEMR .So it would be better if we receive your apache error log file for further analysis.
Thanks,
ViSolve
Hi @visolveemr,
I fixed the issue in my instance so I can’t generate the error.
It may be that I set the pid manually in MySQL when I was playing around. That would explain things. I just installed a fresh instance on Azure and I don’t have any problems.
Even so, it might be good to fix the if ($pid and $doc_catg)
statement to something that doesn’t presume $pid
will never be zero. Maybe:
if (is_null($pid) and is_null($doc_catg))
?
Hello Greg_Zancewicz,
Sounds good that your issue has been fixed. Since OpenEMR allows the pid value to start with 1, the condition if($pid and $doc_catg) is used to avoid 0 and null values. But in your statement you have used if(is_null($pid) and is_null($doc_catg)) which allows only null values to execute. Hence the condition mismatches. Can you please give more detail why you should include another condition rather than existing one.
Thanks,
ViSolve