Document module improvements, take 3.

 -Can now store more than one level of directory structure within the documents directory.
  (this information is stored in the new path_depth field in the documents sql table entry)
 -Incorporated into Rod's pdf report creation in custom report and in the Document module
  CCD/CCR document viewer.
 -Also will use/create random directories (0-10000) when importing a document that is not
  mapped to a patient to avoid all the documents being placed into one directory.
 -Also created some document functions (such as addNewDocument()) in library/documents.php
  to ease importing new documents in API etc.
 -Incorporated addNewDocument() function in phimail direct module.

 NOTE that there is a previous bug noted where documents within the CouchDB server will
 not work in the Document module CCD/CCR viewer. I did not address this bug on this commit.
Version 2 Scanned Documents, INTERIM CODE.

 -Still lots to do:
   -Add ability to modify/change document.
   -Add ability to completely delete it.
   -Deal with in the custom reports (the documents works in Rod's
    pdf, but breaks with scanned encounter form; also need to
    figure out if only give option to see them in scanned forms)
 -Deal with the report and encounter view (will need to
  possible break it into piece images etc)
 -Keep testing.