Search code examples
sqliteencodingmirthhl7-v2

HL7 to SQLite with Mirth Connect


I'm trying to build a channel to read an HL7 ADT text file, extract an MRN and write output to a SQLite table (Database Writer).

My SQLite table contains my data but all my PatientIDs are appearing as a concatenated string in one very wide column. As opposed to a PatientID per row/record.

I'm noticing some weird illegal(?) characters in my HL7 file (which come from a Meditech EMR). In QuickViewHL7 they appear in the MSH-22 and MSH-30.

enter image description here

In the VIM editor -

enter image description here

My question is, are these supposed to be delimiters? If so, what are they? Carriage Returns?

I've posted this question on the Mirth Connect forums but seen little but tumbleweeds. I'm hoping someone here might have seen this before and tell me what's going on.

UPDATE: Hex dump suggests it's a 0x7f (0111 1111). This looks like a backspace character. Should I simply strip it or substitute it with something?


Solution

  • This illegal character should be a line feed carriage return to delimit the start of the next HL7 segment.

    Using VIM, highlight the illegal character and press 'ga'. This will tell you the hex value of the character. In my case 0xfa (which appears to be a back space!?).

    Again in Vim, do a global substitute for a \r

    :%s/\%x7f/\r/g

    Then save the file.

    Everything parses out nicely now.