简体   繁体   中英

How to mask specific elements in HL7?

Currently I am learning how to work with HL7 and how to parse it in python. Now I was wondering what happens if a value in a HL7 segment contains a pipe sign, eg '|'. How is this sign handled? If there is no masking, it would lead to a crash of the HL7 parser. Is there a masking possibility?

\\F\\

You should read the relevant sections of chapter 2 of the version 2 standard about how escaping works in version 2.

The HL7 structure has defined escape sequences for the separators like | . When you look at a HL7 message, the used five delimiters are right after the MSH:

MSH|^~\&
  • | is the Field separator F
  • ^ the component separator S
  • ~ is the repetition separator (for the second level elements) R
  • \\ is the escape character E
  • & is the sub-component separator T

So to escape one of the special characters like | , you have to take the escape character and then add the defined letter (F,S, etc.)

So in above case, to escape the | you would have to put \\F\\ . Or escaping the escape character is \\E\\ .

If you like you can also change the delimiters after the MSH completely, but I don't recommend that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM