If you are FTPing between Windows and Unix, it’s the line terminations that will get you. Native line terminations are:
Unix: x0a (LF, linefeed, newline, ^J)
Windows: x0dx0a (CRLF, carriage return/linefeed, ^M^J)
Mac: x0d (CR, carriage return, ^M)
HL7 messages are really native to UNIX in that, unlike Windows/DOS and Mac, they use the x0d and x0a for different purposes. x0d is the segment terminator, x0a is the message terminator. In UNIX, an HL7 message is equivalent to a single line. You can display the count of messages in a file by using the UNIX command “wc -l fileName”
We use a tcl proc to handle the conversion/cleanup on files moved from Windows to UNIX. We move them as binary files. You can write your proc in a number of ways, but these steps are what you want to accomplish:
1. Convert anyx0dx0a pairs to x0d by deleting all xa occurrences. You’re file is now comparable to a SMAT .msg file.
2. Convert any x0dx0d strings to a single x0d so you don’t create empty segments.
3. Convert any string of x0dMSH to x0dx0aMSH. This will put in all the correct message terminators except for the last message which will be terminated correctly by closing the file you are writing in your tcl proc.
Don’t punish yourself by trying to use an editor to fix the messages by hand.