如何在hl7消息中使用转义符 [英] How to use Escape character in hl7 message

查看:860
本文介绍了如何在hl7消息中使用转义符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using ca.uhn.hl7v2.util.Terser to create hl7 message. For one of the hl7 fields I need to set the following value "\home\one\two".

HL7消息类型为MDM_T02(版本为2.3.1).因为如果我尝试使用

HL7 message type is MDM_T02(version is 2.3.1). Because "\" is an escape character in hl7 messages if I try to use

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

在hl7消息中,OBX-5-1打印为"\ E \ E \ usne-server \ E \ Pathology \ E \ Quantum".

In the hl7 messge OBX-5-1 is printed as "\E\E\usne-server\E\Pathology\E\Quantum".

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

Can someone help me to print the proper message.

推荐答案

您可以参考HL7转义序列的描述此处.

You may refer description of HL7 Escape Sequences here or here.

HL7定义了字符序列来表示HL7消息中其他不允许的特殊"字符.这些序列以邮件的转义字符(通常为"\")开头和结尾,并包含一个标识字符,后跟0个或多个字符. HL7的最常见用法 HL7是由美国国家标准协会(ANSI)认可的标准制定组织,旨在制定基于共识的标准,代表医疗保健系统利益相关者的董事会观点. HL7已编译了一组消息表单...更多 转义序列是转义HL7定义的定界符.

HL7 defines character sequences to represent ’special’ characters not otherwise permitted in HL7 messages. These sequences begin and end with the message’s Escape character (usually ‘\’), and contain an identifying character, followed by 0 or more characters. 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 has compiled a collection of message form... More escape sequences is to escape the HL7 defined delimiter characters.

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

如果\是数据的一部分,则需要使用\E\对其进行转义.

If \ is part of your data, you need to escape it with \E\.

所以您的价值:

"\ home \ one \ two"

"\home\one\two"

成为

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

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

关于第二期:

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

In the hl7 messge OBX-5-1 is printed as "\E\E\usne-server\E\Pathology\E\Quantum"

在读取值时,您必须逆转该过程.也就是说,您应该将\E\替换为\以获得原始值.

While reading the value, you have to reverse the process. That means, you should replace \E\ with \ back to get original value.

这篇关于如何在hl7消息中使用转义符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆