CCR medication bug fix

rpl121 wrote on Sunday, October 30, 2011:

The CCR functionality on my installation of version 4.1 labeled medications as inactive when in fact they were active.  I found the bug in lines 79 asn 125 of the file sql-ccr.inc.  The logic looks for an end date of ‘0000-00-00’ or a future enddate.  My active medications had a NULL enddate, so I changed the

endate = ‘0000-00-00’

clause to

ISNULL(enddate)

in the two locations.

That fixed the problem in the CCR.

Ronald Leemhuis MD

cverk wrote on Sunday, October 30, 2011:

Thank you. That was kind of any annoying bug if you have to print these before the portal security thing gets worked out. First you had to explain why the government makes you print out useless stuff on paper in order to use an electronic record, then you had to explain to them why their medications listed as inactive. Your fix seems to work perfectly.

yehster wrote on Sunday, October 30, 2011:

Dr Leehmuis,
Good catch.  I posted a fix to github.
https://github.com/yehster/openemr/tree/ccr-bug
https://github.com/yehster/openemr/commit/da6cf1aa1f0a1de8d71ce57d0d40f0ecb5766b55
However, rather than changing the 00-00-0000 part of the clause, I added ISNULL(enddate)
that way if others have 00-00-0000 in their database it will still work for them.
Cverk,
The portal displays a CCR too, so it would have been worse as the patient would have seen “inactive” when you weren’t there to explain it to them!
-Kevin

rpl121 wrote on Sunday, October 30, 2011:

Actually, I did the same thing but also changed all the (very few) 0000-00-00 entries to NULL. 

Ronald Leemhuis MD

rpl121 wrote on Monday, October 31, 2011:

This correction seems to fix the patient portal display.  It also seems to fix the internal printout of medications (active vs inactive) in the CCR printing.  However, CCR printing is still buggy for the problem list.  My program prints out problems with ICD9 codes but not codes without ICD9 codes.  It prints out all such problems that have ICD9 codes regardless of whether an end date is in effect.  Hmm…

Ronald Leemhuis MD