Clinical Notes “Last Updated” timestamp changes on unrelated saves

I found a behavior in the Clinical Notes form where the displayed Last Updated timestamp for older notes can change even when that specific note was NOT edited. From a documentation and legal standpoint, this can cause some problems.

form_clinical_notes.last_updated is defined with ON UPDATE CURRENT_TIMESTAMP, and save.php appears to re-save all notes in the form. If another save changes a field such as authorized, MariaDB updates last_updated for those older rows as well.

Example:

  • Note A created earlier
  • Note B added later
  • A save by a different user changes authorized
  • Note A’s last_updated now reflects the newer save time, even though Note A itself was not edited

This makes last_updated unreliable as a user-facing indication of when that individual Clinical Note was actually created or last intentionally edited.

I noticed this only appeared recently after the 8.0.0 upgrade.

Hi @ninjatx
I seem to recall someone has a PR for notes concerning save. I’ll track author down and see where it’s at.
If not, I find this very concerning and will look into once I get caught up a little.

If I was to give you a patch would you be able to test for me? It’d save me a heck of a lot of time.

@sjpadgett Yes, of course! I will be happy to!

Thanks, about an hour or so.

Hi @ninjatx ,
I’ve tested some and appears I got it but you let me know. Just one file a service so unzip in your openemr root directory.
Here’s PR: fix(clinical-notes): preserve timestamps for unchanged notes by sjpadgett · Pull Request #14321 · openemr/openemr · GitHub

Good luck!
clinical-note-fix.zip (6.1 KB)

1 Like

Verified in production on OpenEMR 8.4.1. Saving an encounter without editing any clinical notes no longer changes their Last Updated timestamps or authorship. The fix is working correctly on my production server. Thank you so much!! @sjpadgett

1 Like

You’re welcome. Thanks for detailed report.
Be Blessed…