Fixed multiple bugs in linking patient notes to documents.
Merge branch 'master' of git://github.com/openemr/openemr