I have often been asked about how to create a MOSAIQ treatment backup report and so instead of writing emails to different people with instructions I thought I’d create a blog post about it and then direct people here!
In my 9-5 work I manage MOSAIQ which is the patient management application for cancer centres. As part of the application’s use we wanted to create a report of upcoming patient treatments which we could use as a backup plan. If the application is down for any reason we can simply print off this report, use it to treat our patients and then scan the records back into MOSAIQ when it comes back online. Unfortunately MOSAIQ doesn’t have this functionality built in so we had to set it up ourselves. Here’s what we ended up doing:
Steps to create a MOSAIQ Treatment Backup Report
- Built a Crystal report to extract and format the patient treatment data from MOSAIQ
- Scheduled this report to run automatically on a set interval and export to a PDF file
- Copy this file to the local desktop of several PCs around the building to provide redundant copies
- Set these PCs up with backup power supplies and local printers
Let’s now look into the reasons behind these steps and how we actually did things.
Creating the Crystal Report
Being perfectly honest I wasn’t especially involved with this part of the project. Also I can’t go into too many details about the database fields we used to collect the data. There’s probably not much more I can provide here other than a screenshot of what the finished report looks like:
Obviously this report is tailored specifically for our hospital and you may need to add or remove details for your own versions. Hopefully this serves as good inspiration.
I wish I could provide a bit more information for you but for now this is all I can really do. If you do require further assistance I suggest posting to either the MOSAIQ user group email list or the Australia and New Zealand user group list. I am fairly regular on these and will help if I can. Plus there are a lot of other talented people on these lists so you’re bound to get some assistance.
Running the Report Automatically on a Schedule
This is the section where I can provide more detail! I also suspect that this is the area where people require the most help so let’s do this!
In order to run the report automatically we use a free tool called CREXPORT. I can’t tell you much about who developed this software except that it is offered free to use (including source code for those interested) and that it is not really maintained much at all any more. It does however work quite well and suits our purposes for this project.
CREXPORT runs as a command-line tool which makes it easy to write a script to run it as a scheduled task. For example here is a simple batch script you might use to create a PDF export of a Crystal report:
Let’s break this down:
- crexport.exe – This is the program we are calling which you will have downloaded from the CREXPORT download page. Note that you may need quotes around this as well as the full path. (eg. “C:\crexport\crexport.exe”)
- -F report.rpt – This is the report you wish to run. Again you may need quotes around this as well as the full path.
- -O outputFile.pdf – This is the output file for the report. There are a number of different formats which crexport can export to. See the crexport support page for a full list.
- -U databaseUserName -P databasePassword – These will be used to access your MOSAIQ database. This will depend on your setup so perhaps check with your database administrator if you are unsure.
- -a “parameterName:parameterValue” – This section is for any parameters you might need to pass to the report. In our case we use this to tell the report which day’s records to get from the database.
You can learn about all the program arguments at the CREXPORT support page.
One other ‘gotcha’ which can come up with custom reports is that the report you are running needs to be closed in Crystal Reports otherwise CREXPORT won’t be able to access the file to run the report.
We actually extended on this and wrote our own command-line utility in C#. This allows us to apply dates to the output file name and to email alerts out if the report fails to run for some reason. I may post the source code and instructions for this in a later post. Let me know in the comments if this is something you’d be interested in.
Once we get a script that runs for us we can schedule it using the Windows Task Scheduler. We schedule ours to run every hour and using the extra functionality in our other command-line tool we produce a report for the current day as well as tomorrow’s treatments. You of course can use a different schedule depending on your requirements.
And that’s it! For some of you this may seem a bit complicated in which case I’d suggest enlisting the help of your local IT support team. If you are finding it all fairly straight forward then let’s continue.
Copying the Report to Local PCs
In our environment we set this up to run on the MOSAIQ application server and store the file to a network share and not on the server. This mitigates the risks if anything was to happen to the MOSAIQ application or database but does not protect against network failures.
In order to protect against network failures we need to copy the completed PDF file to the local hard drives of some PCs. You could use a simple batch script to copy the files similar to the following:
Note that the -y switch just means it won’t prompt to confirm overwriting an existing file.
We schedule this to run at on a few different triggers:
- 5 minutes after the hour, every hour. (eg 12:05, 13:05, 14:05, etc) This is just after the server version is produced so it’ll be nice and up to date.
- When the PC is first powered on to get any reports which have refreshed over night.
Again we use a custom written command-line tool to complete this so that we ensure we get all the files we need. Let me know in the comments if you’d like me to post details of this.
Protecting the PCs From Disasters
Once the file is on the local PCs we still need to do a couple more things to ensure the PCs will remain available in the event of certain disasters.
In our case our building provides backup generator power supply to all PCs in the building so that was one thing we didn’t have to protect against. I know that most centres won’t have this luxury and in those cases you’ll need to purchase some sort of a UPS for each PC you want to be available in the event of a power outage.
You’ll also want to connect your printer to the UPS so that you can print out the report. Unfortunately this isn’t as easy as you’d think. Printers are very power hungry when they are actually printing and can drain a UPS very quickly. Make sure you take this into account when selecting the configuration for your final solution.
Lastly you’ll also need to make sure that the printer is setup as a local printer. Most printers will be configured as network printers but if the network is the reason MOSAIQ is offline then this won’t do you much good. Always make sure that you have at least one printer which you can still use if the network goes down.
So there you have it, we’ve completed all the steps to creating our MOSAIQ treatment backup report. This is how we run Crystal reports automatically on a schedule. By running them automatically we remove the human element so we can run the reports at all hours and know that they will be copied to the places where they are needed.
I understand that there will probably be a lot of people reading this post who may not completely understand the techniques we’ve used here. If you would like more details feel free to email me at [email protected] or use our contact form. I’ll update this post if/when I write about the custom tools we mentioned here as well as clarify any areas which aren’t clear.
Please let me know in the comments if you found this useful and feel free to share this post to anyone who you think would benefit from the information.