IMA-WorldHealth / bhima

A hospital information management application for rural Congolese hospitals
GNU General Public License v2.0
213 stars 102 forks source link

Upload and attach scanned documents to transactions. #4895

Open jniles opened 3 years ago

jniles commented 3 years ago

It would be helpful to allow users to scan and upload documents and attach them to any generic transaction. This would make auditing BHIMA a lot easier. For example, you could attach a PV de reception to a voucher, or a bank statement to a particular transaction justifying it.

We already have a lot of the difficult infrastructure written. We have an uploader on the server. We also have mechanisms for uploading documents. All we need to do is implement the client-side modals and behavior.

I propose the way we go about this is the following:

  1. Create a new component/modal that lists documents attached to a particular transaction. All it needs to know is the record_uuid of that transaction. It will allow the user to download a single attachment, all attachments, or delete them.

  2. Store the attachments in a table in the database. They would have a reference to the record_uuid in their table, their own ID, and a path to where they are stored on disk.

  3. Store a boolean variable to indicate if the transaction has an attachment. I propose using the document_map table and extending it with:

    ALTER TABLE `document_map` ADD COLUMN attachments BOOLEAN NOT NULL DEFAULT FALSE;

    Since all vouchers/invoices/transactions/purchase orders/etc usually LEFT JOIN the document_map table to get their human readable reference, we'll be able to easily add in the attachments boolean.

  4. Add an "Upload an attachment" to the dropdown menu of the different registries that allows a user to add an attachment to that record.

  5. Add a "View attachments" to the dropdown menu of the different registries if the record has an attachment. This will bring up the modal described in (1).

I've been using BHIMA for my own personal finances and this is a critical component to allow me to manage my personal documentaton. I imagine it will be useful as well for users as well.

jniles commented 2 years ago

With SEMI, we'll want to have really good tracing of our medications, from purchase order to consumption. Specifically, we'll probably want uploads of our shipping documents.

I say we prioritize this issue. We'll want to be able to see, for every transaction, a list of "attachments" that we can download later. These would be scanned PDFs.

This proposal would probably need to be implemented in conjunction with https://github.com/IMA-WorldHealth/bhima/issues/6275 and https://github.com/IMA-WorldHealth/bhima/issues/6274. Also see https://github.com/IMA-WorldHealth/bhima/issues/4895.

jmcameron commented 2 years ago

When you say "Store the attachments in a table in the database. They would have a reference to the record_uuid in their table, their own ID, and a path to where they are stored on disk.", I presume you are talking about storing the attachment metadata in the database.

I presume we will need a unique file naming convention: Perhaps incorporating the date and UUID into the filename?

jniles commented 2 years ago

I presume we will need a unique file naming convention: Perhaps incorporating the date and UUID into the filename?

Yes, that is right.

jmcameron commented 2 years ago

Should we consider doing https://github.com/IMA-WorldHealth/bhima/issues/6663 first?

jniles commented 2 years ago

Sure!