More "Documents" woes

mbrinson wrote on Wednesday, November 08, 2006:

Anyone have any experience with the documents section not showing files that have been uploaded?

When I do a report for a patient the uploaded images show up, but when in the documents section for the patient it does not recognize that there are files within a particular folder and does not display them.  When choosing a category I am only presented with an option to upload another file, it will not show that files have been uploaded and are in particular categories.
I’ve checked the documents table in the database and all appears correct there (otherwise the reports part wouldn’t work)

I got the most recent CVS to make sure something wasn’t out of whack, but still no dice.  I’ve also tried this on two different systems (windows and Ubuntu).

I’ve spent several hours trying to figure this out and have been unsuccessful.  Anyone else experience this and possibly know what the deal is?

Thanks!

Mike.

bo2999 wrote on Wednesday, January 10, 2007:

I ran into the same problem when tried to install openEMR 2.8.2 from CVS under Mandriva 2007 with PHP5 and MySQL5.  The Image uploaded OK but unable to view under the same category. I look in here for any answer and found none.  I then tried to install PHP5 with MySQL4.1 instead.  Voila, the Document’s Image is working under the same category when it is loaded.  I guess for some strange reason it doesn’t like MySQL5. Anybody knows how to apply the fix for it so it will work with MySQL5? ;) 

Thanks,

tekknogenius wrote on Tuesday, January 23, 2007:

It is due to a poorly formed sql statement in the CategoryTree.class.php file. I don’t know how it worked in mysql version 4, but it surely doesn’t work in mysql version 5. Anyway I’ll put in a correction tomorrow after I test it further but here is the fix in that will go in that file …

        function _get_categories_array($patient_id) {
          $categories = array();
          $sql = "SELECT c.id, c. name, d.id AS document_id, d.type, d.url"
                . " FROM categories AS c, documents AS d, categories_to_documents AS c2d"
                . "  WHERE c.id = c2d.category_id"
                . "  AND c2d.document_id = d.id";

          if (is_numeric($patient_id)) {
                        $sql .= " AND d.foreign_id = ‘" . $patient_id . "’";
          }
          //echo $sql;
          $result = $this->_db->Execute($sql);

          while ($result && !$result->EOF) {
                $categories[$result->fields[‘id’]][$result->fields[‘document_id’]] = $res
ult->fields;
                $result->MoveNext();
          }

tekknogenius wrote on Thursday, January 25, 2007:

I added the code to cvs today.

bo2999 wrote on Thursday, January 25, 2007:

Thanks TG. It works with MySQL 5 now.