Overview

If HL7Connect is sending messages to a text file, a script must be written to convert an HL7 message to a text line.

To do this take the following steps:

  1. Create a New | Test Case File for OnHL7Build and save it as ConvertBack6
  2. Paste the HL7 Message produced in Tutorial #6D into this Test Case File to get a screen like the one below:

    Screen Shot

  3. Add the following function to the Convert6.vbs OR Convert6.js script:

    Language    Script
    VBScript   
        function Build(aEvent)
          set m = aEvent.Msg
          aEvent.Fields.Add(cStr(aEvent.FileOffset))        ' SeqNo
          aEvent.Fields.Add(m.Element("PID-3-1").AsString)  ' MRN
          aEvent.Fields.Add(m.Element("PID-5-1").AsString)  ' Surname
          aEvent.Fields.Add(m.Element("PID-5-2").AsString)  ' Firstname
          aEvent.Fields.Add(m.Element("PID-5-3").AsString)  ' MiddleNames
          aEvent.Fields.Add(m.Element("PID-7").AsDateTime.FormatTimeStamp("mm/dd/yyyy")) ' Date of Birth
          aEvent.Fields.Add(m.Element("PID-8").AsString)    ' Sex
          aEvent.Fields.Add(m.Element("PID-11-1").AsString) ' Address1
          aEvent.Fields.Add(m.Element("PID-11-2").AsString) ' Address2
          aEvent.Fields.Add(m.Element("PID-11-3").AsString) ' Suburb
          aEvent.Fields.Add(m.Element("PID-11-4").AsString) ' State
          aEvent.Fields.Add(m.Element("PID-11-5").AsString) ' Postcode
          aEvent.Fields.Add("")                             ' Date Registered is unknown
          aEvent.Fields.Add(m.Element("PV1-20").AsString)   ' Financial Code
        end function
       
    Javascript   
        function Build(aEvent){
          var m;  // message
          m = aEvent.Msg;
          aEvent.Fields.Add(aEvent.FileOffset.toString()); // SeqNo
          aEvent.Fields.Add(m.Element('PID-3-1').AsString);  // MRN
          aEvent.Fields.Add(m.Element('PID-5-1').AsString);  // Surname
          aEvent.Fields.Add(m.Element('PID-5-2').AsString);  // Firstname
          aEvent.Fields.Add(m.Element('PID-5-3').AsString);  // MiddleNames
          aEvent.Fields.Add(m.Element('PID-7').AsDateTime.FormatTimeStamp('mm/dd/yyyy')); // Date of Birth
          aEvent.Fields.Add(m.Element('PID-8').AsString);    // Sex
          aEvent.Fields.Add(m.Element('PID-11-1').AsString); // Address1
          aEvent.Fields.Add(m.Element('PID-11-2').AsString); // Address2
          aEvent.Fields.Add(m.Element('PID-11-3').AsString); // Suburb
          aEvent.Fields.Add(m.Element('PID-11-4').AsString); // State
          aEvent.Fields.Add(m.Element('PID-11-5').AsString); // Postcode
          aEvent.Fields.Add('');                             // Date Registered is unknown
          aEvent.Fields.Add(m.Element('PV1-20').AsString);   // Financial Code
        };
       

Running this updated script gives the following result:

Screen Shot


© Kestral Computing P/L 2000-2010.