Create an HL7 File Feeder

Say you have a text file with a bunch of HL7 messages. Each segment ends with \r. And each message ends with \n. Here’s a sample file:

You could use the simulator component and feed it in via an HL7 Server - but honestly it’s probably easier to write you own simple component and feed the data directly into the component you are testing.

Here we use ~/test.txt for the default location of the input file. Take a look at Custom Fieldsif you haven’t already.

You access the field with:

local F = component.fields()

The FIL Library makes it really easy to inhale the file:

local Content = FILread(F)

We can easily see this by looking at the contents of the file using escaped mode of:

The string viewing window

See String:split(). The List contains a Lua table as list with the messages.

local List = Content:split("\n") trace(#List)

See Lua table as list

And now we have a working test component!

Now for a little extra flourish:

And now we have a simple tool that makes it easy to test our HL7 interfaces. But more importantly this exercise puts together a set of little concepts that once you grasp you can solve not only simple problems, but you can build up the skills to be able solve complex ones as well. There are no bottlenecks you cannot remove.

 

Â