Overview

We will now create a script to translate the financial codes, based on the following translation table:

NK   HP
NC   HP
PRIV   PR
GOV   MC
MIL   VA
RES   MR

One problem that can arise is how to deal with codes that are not in this table. In this case, we will send an email to the person responsible for maintaining the translation script, translate5.

Context Sensitive Help

If you require help with any of the methods used in the scripts below, place you cursor on the method and press F1. For example, when we get to the SendEmail procedure in the sample below, if you highlight this method and press the F1 key, you will see a screen similar to the following:

Screen Shot

Scripts

Select the script you are using then cut/paste the following code into your translate5.vbs OR translate5.js editor window. This new code should be appended to the existing script - do NOT overwrite. Also, please remember to save after making any changes.

Language    Script
VBScript   
    function translatefincodessimple(aEvent)

      fcodein = uppercase(aEvent.message.hl7.element("PV1-20").AsString)

      if (fcodein = "NK") then
        fcodeout = "HP"
      elseif (fcodein = "NC") then
        fcodeout = "HP"
      elseif (fcodein = "PRIV") then
        fcodeout = "PR"
      elseif (fcodein = "GOV") then
        fcodeout = "MC"
      elseif (fcodein = "MIL") then
        fcodeout = "VA"
      elseif (fcodein = "RES") then
        fcodeout = "MR"
      else
        translatefincodessimple = False

        LastErrorMessage = ""
        On Error Resume Next
        SendEmail "10.10.1.1",                    +_
                  "Unknown Financial Code",       +_
                  "myname@myplace.com",           +_
                  "myname@myplace.com",           +_
                  "Financial Code " & fcodein & " is unrecognised in PAS feed. Please update script translate5.vbs"
        if LastErrorMessage <> "" then
           Kernel.WriteToLog DBG_WARNING, "SendEmail Error " & LastErrorMessage
        end if
        exit function
      end if

      aEvent.message.hl7.element("PV1-20").AsString = fcodeout
      translatefincodessimple = True

    end function
   
Javascript   
    function translatefincodessimple(aEvent){
      var fcodein;
      var fcodeout;

      fcodein = uppercase(aEvent.message.hl7.element('PV1-20').AsString);

      if (fcodein == 'NK')
        fcodeout = 'HP'
      else if (fcodein == 'NC')
        fcodeout = 'HP'
      else if (fcodein == 'PRIV')
        fcodeout = 'PR'
      else if (fcodein == 'GOV')
        fcodeout = 'MC'
      else if (fcodein == 'MIL')
        fcodeout = 'VA'
      else if (fcodein == 'RES')
        fcodeout = 'MR'
      else
        {
        try
          {
          SendEmail('10.10.1.1',
                    'Unknown Financial Code',
                    'myname@myplace.com',
                    'myname@myplace.com',
                    'Financial Code ' + fcodein + ' is unrecognised in PAS feed. Please update script translate5.js');
          }
        catch(e)
        {
          Kernel.WriteToLog(DBG_WARNING,'SendEmail - SCRIPT EXCEPTION: ' + LastErrorMessage);
        }
        return(false);
        };

      aEvent.message.hl7.element('PV1-20').AsString = fcodeout;
      return(true);
    }
   

Testing the script

We will now test the script. To do this take the following steps:

  1. Adjust the host name in the SendEmail procedure (1st parameter) to be the mail server on your site. If you do not have a mail server then you might like to comment out the email code and replace it with a WriteToLog command.
  2. Change the sendto and sendfrom email addresses (3rd and 4th parameters respectively) in the SendEmail procedure to your own email address.
  3. Change the procedure selected in testcase5.tci to translatefincodessimple.

It is suggested that you try the following scenarios:

  1. A translation that works. The existing HL7 message in testcase5.tci should be ok.
  2. A translation that does not work. Paste the following HL7 message in the HL7 Message window of testcase5.tci and retest. (Note: In the sample message below, PRIV has been intentionally changed to PRIX in the PV1 segment.) If possible, check both a case where the SendEmail procedure is invoked, and a case where it is not.

       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|||||PRIX||||||
      


© Kestral Computing P/L 2000-2010.