I am trying to modify an HL7 (hospital interface data) file to copy a value from one segment into another. Unfortunately, the source segment follows the destination segment so none of the tricks I normally use are working.
Here's the layout:
What I need to do is, for each record in the file (where one record consists of some or all of the segments, i.e., the GT1 segment may or may not appear), check a specific value in the GT1 segment and, if it's 'S', copy a single field from GT1 into the PID segment. I would then reassemble the segments into the message and write it to the output file before looping for the next message.
My first thought was that I could somehow put these into a two dimensioned array - rows consisting of the segments, columns of the fields within each segment (delimited by' | ' character), locate the segments I need, check the values and move as necessary - leaving everything alone if there was no GT1 segment. However, I can't seem to get that to work.
This is a great opportunity for me to expand my Perl knowledge but I'm having problems getting started - if anyone has any ideas about how I can hold the entire message in memory and work with it before reassembly, I'd be extremely grateful.
Thanks in advance.
Tom
"My mind is like a steel whatchamacallit ...
Here's the layout:
Code:
MSH|.....| | | | |...
PID|.x.x.x.x|aaaaaa|...
...
GT1|x.x.x.x|lllllll|dddddd|...
ZPV|....|||||...
What I need to do is, for each record in the file (where one record consists of some or all of the segments, i.e., the GT1 segment may or may not appear), check a specific value in the GT1 segment and, if it's 'S', copy a single field from GT1 into the PID segment. I would then reassemble the segments into the message and write it to the output file before looping for the next message.
My first thought was that I could somehow put these into a two dimensioned array - rows consisting of the segments, columns of the fields within each segment (delimited by' | ' character), locate the segments I need, check the values and move as necessary - leaving everything alone if there was no GT1 segment. However, I can't seem to get that to work.
This is a great opportunity for me to expand my Perl knowledge but I'm having problems getting started - if anyone has any ideas about how I can hold the entire message in memory and work with it before reassembly, I'd be extremely grateful.
Thanks in advance.
Tom
"My mind is like a steel whatchamacallit ...