Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text Lines and Arrays

Status
Not open for further replies.

tbohon

Programmer
Apr 20, 2000
293
US
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:

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 ...
 
I forgot to mention that the segments are separated by a ^M (chr 13) and really don't appear as shown in the example layout. My routine for breaking them up works just fine, however, so that isn't a problem.

Tnx.

"My mind is like a steel whatchamacallit ...
 
Thanks, Kevin ... I've seen that but haven't had time to download it - too many 'requests' for scripts (Perl and ksh) sitting in my inbox :)

Best,

Tom

"My mind is like a steel whatchamacallit ...
 
Since you are dealing with what looks like standardized data I would highly recommend you look into using the API. Your attempts to modify the data file on your own may just create more problems unless you are very familiar with whatever hl7 standards are.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I agree - being an integration analyst with several HL7 courses under my belt, I'm familiar with HL7 ... it's a daily task to help move messages between systems.

Managed to hack out a solution to this little problem by breaking each message up into it's component segments, scanning through the array of segments to locate the PID and then to find the GT1, pulling the SSN in the GT1 into a working variable, checking and modifying the PID SSN field if necessary, constructing a new PID to replace the original and then reconstructing the (modified) message for further processing by the main .ksh script. Sounds a lot more complicated than it is ... just took it one step at a time, checked myself at every opportunity, and had it completed in about 2 hours total (including testing). Waiting on customer acceptance now, then it goes into production with tomorrow morning's run.

Appreciate the input and you're right, I probably need to dig into the HL7kit sooner rather than later.

Tnx.

Tom

"My mind is like a steel whatchamacallit ...
 
Sounds good. If you want your perl code looked over for comment you can post it.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top