Working with HL7

Specify the minimum number of fields in an HL7 segment

There are times when you need to show empty segments in an HL7 message. Perhaps the receiving application expects certain fields in a message, even if they are empty. For example you may require the first 26 fields in the PID segment.

So if you get a message that looks like this:

You need to make it look like this:

This is how to achieve this using Iguana:

  • Create a node extension function node.setMinFields().
  • Call it from main.
  • I used the trace() function to show the message before and after.

You can import the project from the Specify_no_of_fields.zip file, the sample data is included in the project.

If you want to know a bit more about how the code works – then here we go…

This is code from the node module in the zip:

  • All it does is put an empty string ” in the Nth place in the node tree
  • That makes Iguana recognize all the fields up to at least that point
  • As the node tree only accepts data in leaf nodes, I recurse the tree to find the leaf

Leave A Comment?