Running DataMajor Script via Cron
Automation
Idexx/NWL/Finn etc. send me e-mail when they have carried out the tests, a line is added to the clinical screen but sometimes my staff forget to check. This leads to results not being looked at or being charged for. I want DataMajor to send me e-mail every morning of the work received.
While this example is based on Lab work - most reports can be automated.
| The only thing to keep in mind for these reports is, if the report is being run via the system there is no way it can ask questions. All dates and codes etc. must be automatically determined. |
The 1st step is to create an Ad-Hoc report that includes all the work. Look at a recently received Lab report entry - check the analysis code - usually it will be 43 but that may be different in your setup. You could also look at any AP codes you enter to say 'Discussed with client', or 'External Lab Results' etc. - again make a note of the analysis codes.
With a bit of luck they are all in a similar range e.g. 41 to 48, however, to cover all possibilities we will include 100 and 110 in this example.
For a simple range:
For a more complicated range, make sure all the analysis codes are in your Billing group 'Lab Work' (you may call it laboratory, test etc. - use the Stored Report -> Analysis -> Code by Group' - make a note of the group number).
Here we specified the anagroup = 15 in the restrict by - we only want work that has been grouped 'laboratory'.
Note: Rather than specify specific dates we have used the generic 1 Day in the dates - this is because we cannot prompt for the dates.
So if you want the last 24 hours, use 1 day, last week use 7 days, the last month would be 1 month, last 6 months 6 months etc.
The system will use the date the report is run and work back automatically.
Whichever report you use, run it, check it looks ok.
At the 'Do you want to Save this query Yes .. No' question answer Yes, Allocate it a name say 'Lab work in last 24 hours' - go into stored reports, My Own Stored reports, select the report we have just created, make a note of the filename - top left e.g. in the example below it is ah1.sql
The report is there for you to run at will, however, we want it to mail you each morning. For this we use the The Automation Manager. (You will need to be on version 2.20.10 or later as that is when DataMajor script support was added).
Select 'Add a New Job', followed by; 'DataMajor Script'
Enter the script name you saved it as earlier, in our case it was 'ah1' (you should not specify the .sql).
Specify when yoy want the report to run, in this examples, lets run it at 7:30 am (just in case results appear over night).
The report will now run each day at 7:30 am - however, we want to send the report somewhere - the best bet is an E-mail account. This could be an aliases (a group of people), a single person, and external address. In our example we will send it to an individual 'tom'.
Select Command from the prompt line, and add:
| mail -s "Lab Work" tom So our full line is:
This means:
| | | Pass the results to ... |
| The command the results have to be passed to | |
| -s "xxx" | The subject to use |
| tom | The user the mail is to be sent to |
Confirm the settings and Submit the changes. Now everyday at 7:30 you will get a mail message titled 'Lab Work' with all the details.