如何在 hl7 消息中使用转义字符

Kil*_*dra 5 java hl7 mirth hl7-v2

我正在使用 ca.uhn.hl7v2.util.Terser 创建 hl7 消息。对于 hl7 字段之一,我需要设置以下值“\home\one\two”。

HL7 消息类型为 MDM_T02(版本为 2.3.1)。因为如果我尝试使用“\”是 hl7 消息中的转义字符

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

在 hl7 消息中,OBX-5-1 被打印为“\E\E\usne-server\E\Pathology\E\Quantum”。

有人可以帮我打印正确的消息吗?

Ami*_*shi 6

您可以在此处此处参考 HL7 转义序列的说明。

HL7 定义了字符序列来表示 HL7 消息中不允许的“特殊”字符。这些序列以消息的转义字符(通常是“\”)开始和结束,并包含一个标识字符,后跟 0 个或多个字符。HL7 最常见的用途是 HL7 是美国国家标准协会 (ANSI) 认可的标准制定组织,负责制定代表医疗保健系统利益相关者董事会观点的基于共识的标准。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 (e.g., ‘\’)
\F\         Field separator converted to field separator character (e.g., ‘|’)
\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 (e.g., ‘~’)
\S\         Component separator converted to component separator character (e.g., ‘^’)
\T\         Subcomponent separator converted to subcomponent separator character (e.g., ‘&’)
\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
Run Code Online (Sandbox Code Playgroud)

如果\是您数据的一部分,您需要使用\E\.

所以你的价值:

“\家\一\二”

变成

"\E\home\E\one\E\two"

关于第二个问题:

在 hl7 消息中 OBX-5-1 打印为“\E\E\usne-server\E\Pathology\E\Quantum”

在读取值时,您必须反转该过程。这意味着,您应该\E\\back替换以获得原始值。