Overview

In this section of the tutorial we will write scripts to translate the financial code.

Sample scripts will be provided in both Javascript and VBScript. You can choose whichever you prefer.

All the files created in this tutorial will be stored in c:\hl7tutorial directory. When there is a choice of Javascript or VBScript, you can choose the scripting language you are most comfortable/familiar with.

Setting up a Translate Function

In this section you will setup a translate script. This script will only write a message into the Debug log. At this stage we are setting up the framework for the solution you will create.

Take the following steps:

  1. Create the folder c:\hl7tutorial (e.g. using Windows Explorer). All tutorial files should be saved to this directory.
  2. Within the HL7Connect Development Environment, select File | New | VBScript(.vbs) OR Javascript(.js).
  3. Type (or Cut/Paste) the following function into the script:
    Language    Script
    VBScript  
          function translatetest(aEvent)
            Kernel.WriteToLog DBG_ANNOUNCE, "Test of translate function"
          end function
         
    Javascript  
          function translatetest(aEvent){
            Kernel.WriteToLog(DBG_ANNOUNCE,'Test of translate function');
          }
         
  4. To save the script, select | Save As... | translate5.vbs OR translate5.js. (Note: Remember to save the file in the directory c:\hl7tutorial)

Setting up a Test Case File (.tci)

Now we have a translate script. Before we can execute the script, we must create a Test Case File, and then create an association between our script and the Test Case File.

Take the following steps:

  1. Make sure you have your translate5.vbs OR translate5.js script open
  2. Select File | New | Test Case File to get the following screen:

    Screen Shot

  3. As we will be translating the message as it is sent, choose OnSendMessage, then select OK to get the window below:

    Screen Shot

  4. Select File | Save As... and save the test case file as testcase5. (Note: Remember to save the file in the directory c:\hl7tutorial)
  5. Select the Script drop down, and choose translate5.vbs OR translate5.js.
  6. Select the Procedure input box and type translatetest.
  7. Use Cut and Paste to place the sample HL7 message below into the HL7 Message area:

       MSH|^~\&|ADT1|MCM|LABADT|MCM|198808181126|SECURITY|ADT^A01|MSG00001|P|2.3.1|
       EVN|A01|198808181123||
       PID|1||123456^^^^MR^PAS~123456789^^^USSSA^SS~4321234^^^DL^NTA||JONES^WILLIAM^A^III||19610615|M||C|1200 N ELM STREET^^GREENSBORO^NC^27401-1020|GL|(91-9)379-1212|(919)271-3434||S||PATID12345001^2^M10^ADT1^AN^A|123456789|987654^NC|
       NK1|1|JONES^BARBARA^K|WI^WIFE||||NK^NEXT OF KIN
       PV1|1|I|2000^2012^01||||004777^LEBAUER^SIDNEY^J.|||SUR||||ADM|A0|||||PRIV||||||
      
  8. Make sure the screen now appears as follows (this is the VB version):

    Screen Shot

  9. Click on Go to execute the script. The window should now appear as follows:

    Screen Shot

  10. Select Tools | Debug log and see the entry in the debug log as shown below:
  11. Screen Shot

The message has not changed (except for the removal of redundant component markers at the end of some segments). This is because the translate function does not have any instructions incorporated.

Another way of running the script is from within the script editor. Refer to the screen shot below:

Screen Shot

When you press the play button (green forward arrow), the option OnSendMessage will be highlighted. Clicking on this option produces the same effect as clicking the Go button in the Test Case File editor.


© Kestral Computing P/L 2000-2010.