Extracting Documents From MOSAIQ

Extracting Documents From MOSAIQ

Recently we had a need to extract a large amount of documents from MOSAIQ and at first this job went to staff who add the documents to the patient records. As you would expect these staff members proceeded to do what they were familiar with and started using the MOSAIQ GUI to select the patient documents and export them one at a time. When we’re looking at 1000+ documents this is a ridiculous proposition and I knew there had to be a way to automate the process. So here is how we went about extracting documents from MOSAIQ.

How MOSAIQ Stores Documents

The trick for doing this comes in knowing how MOSAIQ stores documents on the back end. The system uses some fairly simple obfuscation and stores the documents in their original formats of either .rtf or .pdf.

Folder Structure

The folder structure is stored in the MOSAIQ_DATA folder in the following path:

MOSAIQ_DATA\DB\eSCRIBE

And here is where things start to get interesting. Within the eSCRIBE folder you will find a series of folders labelled with numbers ranging from 00 to 19. Then within these you will see folders labelled with numbers and some letters such as 00000000.000

Here is a summary of what each of these levels mean:

  • 00 to 19
    • This is the last 2 digits of the Pat_ID modulo by 20.
  • 00000000.00
    • The numbers/letters before the period (.) are the Pat_ID represented in hexadecimal format.
    • The numbers after the period (.) are the document number from the Object.Filenum field
Filename and Format

The first thing we need to know here is that each document has a datbase record stored in the Object table. Documents stored as .pdf documents will also have a record in the ObjFilenames table linked by the OBJ_ID field.

The documents will be stored in either .rtf or .pdf formats

  • .rtf
    • The files will always be called Word1.rtf
    • If there is no associated ObjFilenames then the file will be stored as Word1.rtf
  • .pdf
    • These files will most likely have a unique name. (I haven’t determined where the name is derived from so if anyone knows feel free to contact me)
    • The filename can be found in the ObjFilenames table linked to the document by the OBJ_ID field
Document Types

A common scenario may require you to export documents based on the document type. Unfortunately determining the document type from the database records is not as obvious as you might think. It took me quite some time as well as some assistance from Elekta

It turns out that there is a field, Object.DocType, which is linked to the Prompt.pro_id field. You can get the descriptive text to link the number to the description using the following SQL:

Summary

Obviously in order to use this information you would need to access the documents programmatically which is what we did in our case. The program I wrote was completed fairly quickly so it isn’t ready for distribution and I can’t really share it here just yet.I hope to spend some time on this though and create a small command line tool which you can use to easily extract documents from MOSAIQ.

If this is something you would be interested in feel free to either contact me or leave a comment below and I’ll make it a priority.

Hopefully this information proves interesting and helps you when extracting documents from MOSAIQ.

Leave a Reply

Your email address will not be published. Required fields are marked *