Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Selecting HL7 Transactions

by sundialsvc4 (Abbot)
on May 02, 2013 at 12:29 UTC ( #1031746=note: print w/replies, xml ) Need Help??

in reply to Selecting HL7 Transactions

My first comment would be that you should check out Net::HL7, either to use it directly or to study its mysteries.   “Do Not Do A Thing Already Done.™”

Second, the HL7 format is designed to be simple:   it is “pipe-delimited,” therefore a simple split() can be used to break up each string, and the parameters are positional.

Now reaching down a level to the core problem itself ... this sort of thing is most-easily handled by finite-state machine (FSM) techniques.   Each HL7 transaction starts with a known group, such as MSH in this case, and ends either with a known terminator group or the start of the next group.   A state-machine might therefore start in a SKIP_FOR_MSH state, whereupon it empties a list, pushes the current record onto it, and switches, say, to SKIP_FOR_PV1 which is pushing strings until it encounters a PV1 or another MSH (the latter meaning that PV1 is not there).   Now, it sees if the group is missing.   If not, this message is uninteresting and we revert to SKIP_FOR_MSH state.   Otherwise we switch to COLLECT_BAD_TXN and I think you can take it from here.

This logic is simplified by writing the main loop in such a way that you can process the same record twice, so that you can, if you want to, stash the MSH record, switch to SKIP_FOR_MSH state, and know that the just-stashed record will be the next record seen in that state.

Lest your eyes glaze over, go to and search for “FSM.”   Do Not Do A Thing Already Done.™

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031746]
[marto]: Corion, not bringing the kids would make it ideal :P
[marto]: a suggestion, have one project in the list that isn't programming/perl related
[Corion]: marto: Yeah, things are more parent-friendly the way they are ;))
[marto]: some hardware/makey thing
[Corion]: marto: Ah, I'm currently drifting to that again, over"painting" (well with Inkscape) one of my photographs and thinking about vectorizing some other images ...
[marto]: Corion, yes something 'artistic', so that or some music. Even combine some things, build a musical instrument :)
[Corion]: marto: Naah, I'm avoiding that rabbit hole ;) Sometimes I think of using Perl to create MIDI to generate music, or at least the harmonies to which I could jam, but then that would eat even more into available time ;-))

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-07-27 07:47 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (404 votes). Check out past polls.