Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleExamine the file contents in the translator - each segment ends in \r but the message ends with \n characters

We can easily see by looking at the contents of the file using the Escaped Text mode:

that have a custom field for filename, can read in the messages, split them and push them into a queue.

...

Expand
titleThen we split the contents on the \n with local List = Content:split("\n")

So now our code looks like this:

Code Block
require "FIL.FILreadWrite"

function main(Data)
   local F = component.fields().InputFile
   trace(F)
   local Content = FILread(F)
   local List = Content:split("\n")
   trace(#List)   
end

In the editor it looks like:

Image Added

By double clicking of the list coming back we can we the list of messages:

Image Added
Expand
titleWith a for loop we can push these messages into the queue:
Code Block
for i=1, #List do
   queue.push{data=List[i]}
end

And now we have a working test component!

Expand
titleConnect it the component we want to test with - done!

Now for a little extra flourish:

Expand
titleAdd some custom logging

Let’s add some Custom Logging

Just added lines 7 and 11 to the script:

Code Block
function main(Data)
   local F = component.fields().InputFile
   trace(F)
   local Content = FILread(F)
   local List = Content:split("\n")
   trace(#List)  
   iguana.logInfo("#start About to queue "..#List.." messages");
   for i=1, #List do
      queue.push{data=List[i]}
   end
   iguana.logInfo("#end Finished queueing "..#List.." messages");
end

Now we we run the script we can see custom logging:

Image Added
Expand
titleAnd some custom status

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