简体   繁体   English

如何在hl7消息中使用Escape字符

[英]How to use Escape character in hl7 message

I am using ca.uhn.hl7v2.util.Terser to create hl7 message. 我正在使用ca.uhn.hl7v2.util.Terser来创建hl7消息。 For one of the hl7 fields I need to set the following value "\\home\\one\\two". 对于其中一个hl7字段,我需要设置以下值“\\ home \\ one \\ two”。

HL7 message type is MDM_T02(version is 2.3.1). HL7消息类型为MDM_T02(版本为2.3.1)。 Because "\\" is an escape character in hl7 messages if I try to use 因为如果我尝试使用“\\”是hl7消息中的转义字符

public void methodOne() {
   MDM_T02 mdmt02  = new MDM_T02();
   Terser terser = new Terser(mdmt02);
   terser.set("OBX-5-1", "\\\\usne-server\\Pathology\\Quantum"); 
}

In the hl7 messge OBX-5-1 is printed as "\\E\\E\\usne-server\\E\\Pathology\\E\\Quantum". 在hl7中,OBX-5-1打印为“\\ E \\ E \\ usne-server \\ E \\ Pathology \\ E \\ Quantum”。

Can someone help me to print the proper message. 有人可以帮我打印正确的信息。

You may refer description of HL7 Escape Sequences here or here . 您可以在这里此处参考HL7转义序列的描述。

HL7 defines character sequences to represent 'special' characters not otherwise permitted in HL7 messages. HL7定义字符序列以表示HL7消息中不允许的“特殊”字符。 These sequences begin and end with the message's Escape character (usually '\\'), and contain an identifying character, followed by 0 or more characters. 这些序列以消息的Escape字符(通常为'\\')开头和结尾,并包含一个标识字符,后跟0个或多个字符。 The most common use of HL7 HL7 is a Standards Developing Organization accredited by the American National Standards Institute (ANSI) to author consensus-based standards representing a board view from healthcare system stakeholders. HL7 HL7最常见的用途是由美国国家标准协会(ANSI)认可的标准制定组织,以创建基于共识的标准,代表医疗保健系统利益相关者的董事会观点。 HL7 has compiled a collection of message form... More escape sequences is to escape the HL7 defined delimiter characters. HL7编译了一个消息表单集合...更多转义序列是为了逃避HL7定义的分隔符字符。

 Character Description Conversion \\Cxxyy\\ Single-byte character set escape sequence with two hexadecimal values not converted \\E\\ Escape character converted to escape character (eg, '\\') \\F\\ Field separator converted to field separator character (eg, '|') \\H\\ Start highlighting not converted \\Mxxyyzz\\ Multi-byte character set escape sequence with two or three hexadecimal values (zz is optional) not converted \\N\\ Normal text (end highlighting) not converted \\R\\ Repetition separator converted to repetition separator character (eg, '~') \\S\\ Component separator converted to component separator character (eg, '^') \\T\\ Subcomponent separator converted to subcomponent separator character (eg, '&') \\Xdd…\\ Hexadecimal data (dd must be hexadecimal characters) converted to the characters identified by each pair of digits \\Zdd…\\ Locally defined escape sequence not converted 

If \\ is part of your data, you need to escape it with \\E\\ . 如果\\是数据的一部分,则需要使用\\E\\进行转义。

So your value: 所以你的价值:

"\\home\\one\\two" “\\家\\一个\\两个”

becomes

"\\E\\home\\E\\one\\E\\two" “\\ E \\家庭。\\ E \\一个。\\ E \\二”

About second issue: 关于第二期:

In the hl7 messge OBX-5-1 is printed as "\\E\\E\\usne-server\\E\\Pathology\\E\\Quantum" 在hl7中,OBX-5-1打印为“\\ E \\ E \\ usne-server \\ E \\ Pathology \\ E \\ Quantum”

While reading the value, you have to reverse the process. 在读取值时,您必须反转该过程。 That means, you should replace \\E\\ with \\ back to get original value. 这意味着,您应该将\\E\\替换为\\ back以获取原始值。

As @Amit Joshi mentioned, this has to do with HL7 escaping. 正如@Amit Joshi所提到的,这与HL7逃逸有关。 You may want to try to change your escape character to one other than a backslash that is unlikely to appear in your message as your client appears to not be following it anyway. 您可能希望尝试将转义字符更改为不太可能出现在消息中的反斜杠,因为您的客户端似乎无法跟随它。

This would be the 3rd character in MSH-2. 这将是MSH-2中的第3个角色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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