[Navigation]

Definition files and Reserved Words

This chapter will explain how you can alter the way common documents, like consent and recovery forms, fee notes etc., look when they are printed. To some degree, you can also change the amount and type of information the documents contain. This functionality is provided so that you can customise each document to reflect the image and workflow of your practice.

In many parts of the Premvet 5 system, the program has to identify clients using a range of criteria and then send unique information to each of those clients.

If you are creating Microsoft Word documents for Operation forms please see the separate section for more details.

To explain how Premvet 5 accomplishes this, it's best to draw a conceptual distinction between presentation information and data information. For example, when Premvet 5 is producing invoices it consults a separate file which tells it how an invoice should look - the presentation - and inserts information specific to each client - the data - accordingly.

In Premvet 5 the files which store presentation information are called definition files. They contain the lay-out details of each document, default text to include and 'place-holders' for the data called reserved words. To make a very simple example; when you write a letter to Mr Smith it invariably starts:

Dear Mr Smith

If you wanted to send the same letter to hundreds of people it would be tedious to change the name before you print each letter, and less personal to write:

Dear Customer

So you need a program that looks through your database of clients and adds each person's name in the appropriate place. But the computer needs to be able to distinguish between text it is supposed to print regardless, and text which should be replaced with data. Wiggly brackets might be one way of doing this:

Dear {Name}

Premvet 5 uses the ampersand character (&) to decide what is just text and what is a reserved word which should be replaced with appropriate information from the database. Reserved words look like this:

&fee
&drug
&vat

To sum up, Premvet 5 relies on definition files to tell it how to present information. Each definition file contains a mixture of lay-out instructions, standard text and reserved words. When you first run Premvet 5 it will be using the default definition files supplied with the system; so in order to change the way documents look, and customise them to reflect the image of your practice you will need to edit these definition files.

Chapter contents

  • Editing definition files
  • Long Lines
  • Changing the case of the 1st letter
  • Printer codes
  • Dot commands and advanced features
  • If/else option
  • .pl Paper length
  • Selecting printers (.PR /.DP)
  • Date functions in definition files
  • Species specific information
  • Using PCL Overlays.
  • Printing Windows PCL files
  • General definition file Specific notes.
  • Filters and Logo's

  • Editing definition files

    To change the way a document looks, you first need to identify which definition file Premvet 5 is using to create the document. Because there are many documents which can be altered, and more than one definition file in some cases, you should refer to the links below:

  • Full list of definition files
  • Full list of reserved words
  • Drug labelling reserved words
  • Receipt Reserved words
  • You will also find instructions on identifying the definition file an option is using, and a list of the related reserved words, in each chapter where a document's layout can be altered in this way.

    Once you have identified the file you need to change, e.g. "bill.def" for fee notes, open it using a text editor. Examine each definition file carefully before you alter any of the contents. By examining the document you will have a better idea of how the definition file works. At the head of the file you may see various 'Dot' commands, e.g.:

     .pl 26
    
    These lines are not printed. They are used to control various aspects of the document's behaviour. The code above, for example, controls the length of the printed document in relation to the length of the definition file. We will describe the various 'Dot' commands you can use later in the chapter.

    Beneath the 'Dot' commands, you will see the main body of the definition file. It will be a mixture of text and reserved words, for example:

    Dear &client ,
    We see from our records that your pet &animal ....
    
    When printing Premvet 5 will replace the reserved words with the associated data from a client's details, so the above definition would become:
    Dear Mr Sandy Shores,
    We see from our records that your pet Figgins ....
    
    We can change any of the general text without altering the reserved words used, e.g.:
    Congratulations &client !
    Your pet &animal has won a year's free supply ....
    
    Which would output as follows:
    Congratulations Mr Sandy Shores!
    Your pet Figgins has won a year's free supply ....
    
    And we can also add and remove reserved words:
    Congratulations &client !
    You have won the &pname prize draw....
    
    Output:
    Congratulations Mr Sandy Shores!
    You have won the Moores Veterinary Surgery prize draw....
    

    Note: We've used the prize draw example because its an easy way of illustrating the relationship between reserved words and general text. If you actually wanted to send a prize draw notification, or any similar marketing letters/newsletters it would be better to use the merge printing option described in the previous chapter.

    Example definition file
    Look at this sample consent form. You will notice:


    Reserved words - Rules

    When you are adding reserved words to definition files, remember the following points:


    Long Lines

    As some of the lines may exceed the capacity of the editor you are using to create the definition file. Lines ending with a back slash (\) will be treated as not complete and the following line will be appended. e.g.

        This will be \
         treated as  \
         one \
          line.
          


    Reserved Word - Make it look 'nice'

    If the reserved word starts with a capital letter then the replacement will also have capital letter e.g.

    &animal = fred
    &Animal = Fred

    Note: Only the 1st letter will be checked.


    Printer codes

    Whenever a label, stage letter, form or letter is produced the system will check for commands to alter the typeface e.g. bold or enlarged writing, extra pages etc. It does this by looking for the following codes embedded in your text:

    &bs / &bf Bold start/finish
    &es / &ef Enlarged start/finish
    &us / &uf Underline start/finish
    &cs / &cf Condensed start/finish
    &fs / &ff Additional font off/on
    &pa Form feed
    For a full list of printer codes please see Table 10.

    The usage of these codes is as follows:

    When you &bs print &bf this sentence, the first 'print' is bold.
    
    Output:
    When you print this sentence, the first 'print' is bold.
    

    Note: Some of these codes may not be set up on your system. See the section concerning printers in Appendix A for more details on adding or changing these codes.

    Remember that the code to turn on one of these print functions takes up three characters on the screen, but when printed will not appear. This can affect your layout if you have not accounted for it.


    Dot commands and advanced features

    The definition files have some additional features that can be used. These are 'dot' commands:

    .PL Set the paper length
    .PA Take a new page
    .RM Set right margin
    .LM Set left margin
    .DP Printer to send to (Unix only)
    .CP Number of copies to print
    .IF If/Else option
    .EL If/Else option
    .FI If/Else finish option
    .TY what Sets the format of the printout.
    .file=[filename] Include species specific information
    .Overlay [number] Add an Overlay document to your forms.
    .Winfile [filename] Printing Windows PCL files
    .filter cmd Sends the output to the cmd specified.
    .logo=[filename] prints your logo
    .Logfile [filename] Send the output to 'filename' instead
    .SA [filename] [text] Send [text] to [filename]
    See example

    The set left right margins can only be used once within a document and you should make sure the .PL option is set so the system can determine the size of paper to use.

    Species specific information

    You can include species specific messages on any of your definition files. This is done by inserting a dot command into the definition file which specifies a text file e.g.

    .file=species.rcl
    
    This tells the system to include at this point the contents of the text file canine.rcl, feline.rcl etc. This allows you to create different species files for different applications. You could use:

    species.rcl - Recalls
    species.fee - Fee notes

    To save paging problems you are advised to set the paper length with the .pl command, or include .pa on the last line of the definition file.

    Notes:

    If/else option

    Another way of achieving the insertion of species specific information is by using the If/else option. However, the If/else option is more rudimentary, and can also be used to examine the values of other reserved words. An example application might be:

            &bs RE: ANNUAL BOOSTER VACCINATIONS AND CHECK-UP  &bf
    
    Dear &animal ,
    
    [snipped]
    
    .IF SPECIES=CANINE
    The &bs annual booster and check-up &bf  will not cost any more
    than #35.84 for dogs, (this includes 17.5% VAT), unless you would
    like to have any extra tests or treatments. We strongly advise
    worming treatment.
    
    .EL SPECIES=FELINE
    &bs &animal , good news for cats like you! &bf
    We are now using a new 3-in-1 cat vaccine. Feline Leukaemia is now
    included with the Flu and Enteritis viruses in one injection.  This
    means that you can get more complete protection in one injection!
    (Less ouch!). Remember that leukaemia is the number one infectious
    killer of cats in the U.K.
    
    Please let &client  know that your annual check up and a single
    booster including Flu, Enteritis and Leukaemia is now only #41.13
    inc vat.  (If you have not been vaccinated against leukaemia before,
    you will need a second leukaemia vaccine 3 weeks later at a cost
    of #14.10 inc vat.)
    .FI
    
    Please ask &client  to telephone for an appointment.
    This helps us to reduce any waiting time in the reception room.
    
    
    In this case, if Premvet 5 was printing the definition file and the species field of the animal concerned was 'canine', text relating to Canine vaccinations would be included. If the species field read 'feline', Feline related information is included instead.

    It works by comparing the word that follows the '.IF' or '.EL' with the known reserved words. You should NOT use the ampersand '&' in front of the word.

    The only exception to this rule is reserved words in the @date(n &word) option - here the & has to be included as the '@date...' has to be pre-processed to get the correct value.
    If the two agree the text following until either .EL or .FI is printed, otherwise the next comparison is made.

    In addition to equals (=) you can also use less than (<) e.g.

    .IF YEARS < 5
    blah blah
    or the greater than (>) can be used, however in this case it will be taken as greater than equal to e.g.
    .IF YEARS > 7
    This animal is sever years of age or older

    You can also add a 'catch all', that is something similar to:

     .IF species = canine
     This is a dog
     .EL species = feline
     This is a cat
     .EL
     This is neither a dog nor a cat but a &species
     .FI
    

    When using the If/Else option the paper length MUST have been set with the .PL command or the documents must finish with a .PA


    .pl Paper length

    The system will print the number of lines contained in the definition file e.g. if gen.def has 10 lines then only 10 will be printed. There are many cases where you will want the printer to skip to the top of the next page. This can be handled easily in two ways:


    Date functions in definition files

    You can also perform basic date functions in your definition files. The syntax is as follows:
    @date(function) 
    
    The supported options are:
    Enter Value returned
    @date(+5) 5 days from today returned as dd.mm.yyyy
    @date(-6) 6 days ago as dd.mm.yyyy
    @date(w) Returns the day of the week (for today) e.g. Monday
    @date(w 15.12.2001) Returns Saturday (the 15th Dec 2001 is a Sat)
    @date(w &var0) Assuming &var0 is a date, will return day of the week.
    @date(m) Returns the month and year e.g. January 2001
    @date(m 15.12.2001) Returns December 2001
    @date(m &var0) Assuming &var0 is a date, will return
    @date(c) Returns the current month e.g. January
    @date(c +1) Returns current month plus 1 e.g. Febuary
    @date(n 15.12.2001)
    @date(n &vacc)
    Numeric representation of the date, this can be used in IF/ELSE comparisons.
    @date(t 15.12.2001)
    @date(t &var0)
    Text representation of the date. e.g.
    Saturday, 15th December 2001
    @Full(&date) Will return today's date spelt out e.g.
    FIFTEEN DECEMBER TWO THOUSAND ONE
    @Full(date xx) Will return full date plus xx days

    Date functions example:

    &date
    Today is @date(w) the @date()
    Month and year is @date(m)
    
    Add 5 days and it will be is @date(w +5) the @date(+5)
    Recall will be due around @date(m +365)
    
    Current month @date(c)
    Work to be done in @date(c +1)
    Work to be done in @date(c +2)
    Work to be done in @date(c +3)
    Oh I forgot about @date(c -2)
    

    This will generate something similar to:

    14.02.2001
    Today is Wednesday the 14.02.2001
    Month and year is Febuary 2001 
    
    Add 5 days and it will be is Monday the 19.02.2001
    Recall will be due around Febuary 2002 
    
    Current month Febuary 
    Work to be done in March 
    Work to be done in April 
    Work to be done in May 
    Oh I forgot about December 
    


    Selecting printers (.PR /.DP)

    Normally the .DP (or .PR) is followed by a letter e.g. .DP F to print to printer F. However, this can limit you if you are dynamically altering the printers in use by location. To allow printers to be assigned by location use a number (1-3) this number corresponds to :

    1. Currently selected main printer
    2. Currently selected label printer
    3. Currently selected receipt printer

    so assuming your receipt printer is set to B then .DP 3 will be translated to printer B.


    Using PCL Overlays.

    See .Logo option for a simpler method. There may be times where you want to add a logo or get the system to generate letterheads. This can be done easily with the .Overlay command which is available within all definition file processing.

    The other option is to use the General Purpose Form with a link into a Microsoft Word document.

    The .Overlay command WILL work on any terminal type.

    The format is

    .Overlay <number>

    This will automatically call the PCL macro <number> and include that with the document you are printing.

    Creating the overlay:

    The above procedure is great for Logo's and letterheads but if you want to print 'one-off' documents then you should use:

    .Overlay <number> <overlay-file>

    Make sure the <overlay-file> and <number> agrees, it is a good i dea to standardise on say 100 for one-off files. This will avoid any conflicts with other permanent overlay's.

    Note: The above examples use the file suffix .prf this is purely to identify the file as a PrinteR Font file you can call them anything.


    Printing Windows PCL files

    You may have a Windows document that you want to print from any screen, you can create a dummy definition file that allows any Windows PCL file to be printed. This DOES NOT need to be printed from a Windows PC.

    Save the document (use the print to file option within the Windows Print Dialogue Box). Copy the file to the text sub-directory on your Unix machine.

    Use .Winfile <name-of-file> this will print the specified file to the currently selected printer e.g.

           .dp G
           .Winfile wintest.prn
           


    Using the log options

    One example is logging the settings used when X-Rays are taken. Setup either a definition file :

    .qu Enter the X-Setting (KV) [Number]
    .qu Enter the MAS setting [Number]
    .qu What view was taken
    .qu Comments
    .logfile text/xray.csv
    &date, &time, &ref, &surname, &user, &var0, &var1, "&var2","&var3"
    
    Now when that def file is printed (can be from an AP card is needed) it will log to the file text/xray.csv the details.

    The other way, you may have a def file setup to print the X-ray label, rather than use the example above you could use:

    .dp B
    .qu Enter date X-Rayed [Number]
    .qu Enter area X-Rayed
    .sa test.csv &client, &ref, &user, &date, &time,\
    &animal, &var0,\
    &&var1
    &client
    &animal
    &species
    &breed
    &age
    &sex
    &var0
    &var1
    

    In this case the label will still be produced as before, except the .sa entry will make an record in the logfile text/text.csv. Note, the use of the '/' to split long lines.


    Filtering the output

    There may be times where you don't what the results to be sent straight to the printer - you may want to pass them 'filter' via another option.

    If this is the case you should specify the full command via the .filter option e.g.

    .filter groff -mm -t -Tlj4 %% | lp %d In the above example the print job will be sent to the 'groff' program first to produce better quality presentation then to the printer. The total filter command after replacements must not exceed 120 characters.

    Note: For groff documents use the .TY option below.

    The filter command will be checked for some abbreviations:

    OptionWhat
    %% The name of the file to be processed
    %p The name of the current default printer

    This allows you to specify the exact command line.


    The .LOGO option

    This is very similar to the .overlay command above. You can specify .logo=filename and the system will automatically include the logo (or any form) in the current document.

    The procedure is very straight forward:

    Notes:


    Using groff for processing

    The groff test processing system allows you to produce much higher quality printouts. You can tell the system to use groff automatically with the dot command 'TY'.

    There are additional options to the TY command depending on the type of documents you are generating.

    .TY nroff Generic settings and will handle 99% of your requirements
    .TY psroff Incudes support for postscript documents and sends the results as postscript to the printer.
    .TY PSGS For sites without postscript printers this option will post process the document and convert to PCL suitable for most Deskjet/LaserJet printers.

    1. .TY nroff
      This option tells the system that the format the document is suitable for groff - in adition if the filter command is not set it will be set to:

      groff -mm -t -Tlj4 %% | lp -c -s -o raw

    2. .TY psroff
      If you have a postscript printer use this option. It does include support for the .PSPIC marco that allows images to be processed. Output is postscript so you should make sure your printer supports it. The filter command is set to:

      groff -mm -p -t %% | lp -c -s -o raw

    3. .TY psgs
      If have a printer that does not support postscript and still want to include images etc. then use this option. You will need to install Ghostscript (on the Premvet Utility CD) before you can use this. The filter command is set to:

      groff -mm -pt %%|gs -q -sDEVICE=laserjet -oOutputFile=- - -c quit|lp -cs -o raw

    The current default printer will be appended to the command.

    See also:


    Top Classic New-Style Chapters Sections Index Search