In Tutorial #5F, we translated the Financial Code with the function translatefincodedb. In this tutorial, we will look at a simplified table lookup command.

First we will use the Help facility to get details of the lookup command we want to use:

  1. Choose Help | HL7Connect Script Reference | Index tab. You should get a screen like the following:

    Screen Shot

  2. In the Index Tab, look for the keyword "lookup". You should a have screen like the following:

    Screen Shot

  3. Choose TDBConnPool.Lookup. You will get a help screen like the following:

    Screen Shot

  4. We will now develop a new function called translatefincodedblookup that uses this function.


Select the script you are using then cut/paste the following code into your translate5.vbs OR translate5.js editor window.

Language    Script
    function translatefincodedblookup(aEvent)

      fcodein  = uppercase(aEvent.message.hl7.element("PV1-20").AsString)
      fcodeout = kernel.GetDB("HL7Tutorial").Lookup("PASFinCodes", "Code", fcodein, "LISCode", "")
      if fcodeout = "" then
        fcodeout = fcodein
        LastErrorMessage = ""
        On Error Resume Next
        SendEmail "",                                               +_
                  "HL7Tutorial Interface Error",                             +_
                  "",                                      +_
                  "",                                      +_
                  "PAS Financial Code " & fcodein & " is unknown"
        if LastErrorMessage <> "" then
           Kernel.WriteToLog DBG_WARNING, "SendEmail Error " & LastErrorMessage
        end if
      end if
      aEvent.message.hl7.element("PV1-20").AsString = fcodeout
      translatefincodedblookup = True
    end function
    function translatefincodedblookup(aEvent)
      var fcodein;
      var fcodeout;

      fcodein  = uppercase(aEvent.message.hl7.element('PV1-20').AsString);
      fcodeout = kernel.GetDB('HL7Tutorial').Lookup('PASFinCodes', 'Code', fcodein, 'LISCode', '');
      if (fcodeout == '')
        fcodeout = fcodein;
                    'HL7Tutorial Interface Error',
                    'PAS Financial Code "'+fcodein+' " unknown');
          Kernel.WriteToLog(DBG_WARNING,'SendEmail - SCRIPT EXCEPTION: ' + LastErrorMessage);
      aEvent.message.hl7.element('PV1-20').AsString = fcodeout;

Testing translatefincodedblookup

To test the updated translation code, take the following steps:

  1. Using, test the new function translatefincodedblookup.
  2. Update the function translate defined in Tutorial #5E to call translatefincodedblookup rather than translatefincodedb, and test this works.

© Kestral Computing P/L 2000-2010.