[Navigation]

Report generator: Advanced

Advanced options

Running a report
When running a report there are four output methods available:

Output options - summary
Looking at the overall output options we get a tree structure:

Output method :       Printed Displayed Disk Summary
                                         |
                                 |-------|-------|-------|
Output Type   :               Spooled  ASCII  Record    BDS 
                                         |
                                    |----|------|-----|
Delimiter     :                    CSV  Colon  Pipe  Tab
Once these questions have been answered you will be asked to enter a report filename. This is the name under which the report will be stored. If you press RETURN report generator will automatically assign a name. This is the name that is used to access the report at a later date and will be included on the summary.

WARNING: You are well advised to use the automatic name option as it is by this name the system is able to recognise where the file originated.

Advanced uses - search
In the search section of this chapter we looked at comparing a selected item with a preset value e.g. Client type =SA. There may be times when you want to compare one item with another. To do this you would enter the field abbreviation within the search criteria. A list of the available abbreviations can be obtained from an option on the utilities menu. Abbreviations are entered in a similar manner to reserved words; that is, you prefix the abbreviation with an ampersand symbol '&'. There can be no spaces between the & and the abbreviation.

For example, to list all stock items where the quantity is less than the minimum quantity you would search on the quantity field with the criteria <&mi (&MI is the abbreviation for minimum amount). The report generator will replace &mi with the minimum quantity from the record card.

You can also perform calculations on these abbreviations and you have to indicate a calculation is following by prefixing the calculation with a question mark (?) e.g. in the above example we searched for quantity below minimum (&MI); this does not take into account any goods on order (&ON). The following criteria could be used:

Search criteria against quantity - <?&on*&cp+&mi

Note: Goods on order are stored as the 'outer' quantity and the quantity and minimum amounts are stored as 'inner' sizes so we must convert to a standard by using the pack contents field (&CP).

This is fine as long as the items you are searching against are valid fields, the next section explains how to search (and print) items which do not have a specific field.

Extrapolated fields
Extrapolated fields are fields that do not have an entry to search or printout on. e.g. You may want a list of stock items where the total holding (at cost) of any item is greater than -1000.00.

You can specify up to three separate extrapolated fields and these are labelled 'Special 1 - 3'. When these fields are selected you will be asked to enter, first of all, what to print out.

Printout - Again by using abbreviations this is easy to specify. In the above example the total stock holding is determined by the quantity in stock (&QU) multiplied by the cost price (&CO). When you are asked to specify what to print out you would enter &QU*&CO. When these abbreviations appear on the screen you will see the pipe symbol (|) appearing before them, don't worry, the pipe is used internally to tell the report generator that a calculation is to be performed. As extrapolated fields can only be performed on abbreviations and calculations are always performed you do not need to specify the question mark.

Search - You can search extrapolated fields without actually printing them. Select 'Special 1 - 3' as appropriate, you will then have to specify the search criteria. The report generator needs to compare 'something' with 'something' and both of these must be specified on the same line. To separate one side of the equation from another you use the at symbol '@'. In the above example you would specify &QU*CO@>1000 ( e.g. is Quantity times cost greater that 1000). If when the search criteria is specified the '@' symbol is not specified then the system will not let you leave the search criteria field.

Advanced uses - Files and directories
This page gives an explanation of the file names created and used by the report generator.

All report generator files are stored in a sub-directory below the directory containing the Premvet 5 software e.g. if the Premvet 5 system is installed in C:\VET then report generator files are contained in C:\VET\REPORT.

Deleting unwanted files
Generator files can be deleted via the erase option under 'Edit a report'. Output files will have to be deleted manually with the appropriate Operating System command.

Files names used follow the following convention:


Running Report Generator scripts outwith the menus

You can run any report generator script from the command line, this enables you to automate any of the reports e.g. using at or cron. The summary is sent to 'standard out' making it very easy to mail/file the results. The actual results can be sent to a CSV or text file in the text sub-directory (same name as the report being run) or 'standard out'. The location and name of the file will be shown on the summary report.

When run as a stand-alone option there is are no page breaks, any heading boxes are suppressed and the column width is increased to 999 characters. You cannot use '/' to ask for search critiera - when run stand-alone all search critera must be specifed within the report. If run before 6am on the 1st of a month the system will use the last dat of the previous month.

The option is similar to the other stand-alone options within Premvet, and has the format:

vet -p rgen Report-to-run Where filename
rgen Name of the premvet program to run
Report-to-run This is the actual report including suffix of the report you want to run.
Where If you want to save the output, then specify:
Spool - This will save the results as a .txt file
Disk - This will save the results as a .csv file
  If Where is not specified the results will be sent to 'standard out' allowing you to filter as you require. The summary' page will always be output.
filename This is optional, the full location of the output file. If the filename is specified on the command line it will NOT be reset when the report is run.

The report name is shown on the summary page, so to run an existing report that you are not sure what it is called, run it manually to check everything is working as expected, look at the 1st line of the summary:

 Report run - Client Agreement Check (CACheck.vrg)   on 14.12.2001
The 'Report-to-Run' is shown in brackets '()', in this case the report is: CACheck.vrg If we wanted this report sent as a text file the full line would be:
        vet -p rgen CACheck.vrg Spool 
Rather than the summary going out to the screen, you may want to redirect to you as a user, just 'pipe' the results to your mailer e.g.
	vet -p rgen CACheck.vrg Spool | mail -s "Client Agreement" tom
would send the summary to the user 'tom' with the subject 'Client Agreement' or to send the results to a specific file (and the summary to the screen).
	vet -p rgen CACheck.vrg > /u/home/tom/CACheck
would send the results to the file CACheck in /u/home/tom

Running via cron

As with all Premvet cron jobs they should NOT be run by 'root', we suggest you run them as the user 'vet' making sure they don't clash with other jobs e.g. validations, end of day/year and backups.

So to run the job at 1:10 am on the 1st of each month you would use

10 1 1 * * /usr/local/bin/vet -p rgen CACheck.vrg Spool | mail -s "Client Agreement" tom

If you have a few reports to run it is recommended you do NOT add them all into cron. This can lead to over-runs and having to edit cron every time a new report is added is a waste of time and a possible cause of errors. Rather you should:

Note: Do NOT save the script in the main 'vetdata' sub-directory as one of the periodical security sweeps will remove the execute permissions and the report will NOT work. We suggest you save it in the home directory of the user running the job.

Running over mutiple databases

You can use a simple shell script to run a single report over multiple copies of the vet system.

To save having to maintain multiple copies of the report-to-run (as they should all be the same), the system will use the Enviroment Variable REPORT, this should be set to the top level directory of the database containing the report description and dictionary files.

For example, this script will assume all the vet systems live under /w and that the reports have been defined in the main live vet system (/v/vetdata). This script includes comments so you can see what is happening.

MIRROR=/w         # Where do the vet systems live?
rm -f /u/tom/test.csv # Remove the file
REPORT=/v/vetdata  ; export REPORT  # Use the reports in the main vet system

# Loop over all the possible directories 
for x in `ls $MIRROR`
do
    # Does the directory have a vet system in it?
    [ -f $MIRROR/$x/u/vetdata/param.exe ] || continue
    # Run the report
    vet -d $MIRROR/$x/u/vetdata -p rgen dogs Disk /u/tom/test
done
The results will be sent to the file /u/tom/test.csv ready for impoting into Excel and the summaries will be sent to the screen.

You should not use any sort options when running this method as while individual sites will be sorted the overall date will not. If you are searching clinical records, the csv file with the actual records found will be in the text directory relative to the database being searched.

The system will still include individual summary pages for each database set allowing the totals to be brokendown.


Top Classic New-Style Chapters Sections Index Search