HL7: Find Segment


This example shows how to use the hl7util.findSegment.lua module to find any HL7 segment in a parsed HL7 message node tree. The hl7util.findSegment() function works by searching through the node tree passed in and putting each segment in the tree through the filter function which is supplied as the second argument.

If you have any questions please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the HL7: Find Segment channel from the Builtin: Iguana Protocols repository
  • Experiment with the code to find out how it works
  • Then add the module to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a single function
  • Adapt the code to your own requirements
  • Parse the HL7 message using hl7.parse{}
  • Use the function hl7.findSegment() to find the desired segment in the parsed message
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

This code finds one or more matching segments in a parsed HL7 message using a filter function. This approach is extremely flexible because you can use the filter function to apply any filter criteria that you wish.

The first return contains the first matching segment as an hl7 node, the second return contains a table of matching hl7 nodes, if no matching segments are found then both returns are nil.

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.