在 HL7 段内使用 ASCII 10 是否是表示新行的有效方法?

Is using ASCII 10 inside a HL7 segment a valid way to represent a new line?

将 ASCII 10 (0A) 字符放置在 HL7 消息段内的某处以表示换行符。这有效吗?

据我所知,建议使用\X0D\ 或\X0D0A\ 来表示纯文本格式HL7 的换行符。仅使用 0A ASCII 字符是否显式无效 HL7?

HL7 消息中不允许换行 (0x0A)。如果您使用记事本、写字板和许多其他文本编辑器编辑消息,它们会将回车 returns (0x0D) 转换为 CR/LF (0x0D 0x0A),如果您保存,您现在会收到损坏的 HL7 消息。避免 LF (0x0A)。

如果您只发送 0A 则无法确定您想要 ASCII 10/换行符,并且会假定您想要一个零和一个 A。

标准 HL7,转义字符是 \,那么推荐的方式是 \X0A\\X 表示十六进制数据的开头,后跟两个字符的十六进制值,以 \.

结尾

也就是说,如果您将此数据发送到系统,那么他们应该能够告诉您他们接受什么换行符。我见过使用 \.br\ 或重复字符 ~ 来确定新行的系统。有时他们想要重复片段。例如下面,每个 OBX 段是系统中报告的新行。

OBX|1|TX|||This is line one
OBX|2|TX|||This is line two

回答问题"Is using just the 0A ASCII character explicitly invalid HL7?":

字符 0A 在 HL7 规范中的任何地方被提及为特殊字符。

摘自 HL7 2.5 美国规格:

2.5.4 Message delimiters

In constructing a message, certain special characters are used. They are the segment terminator, the field separator, the component separator, subcomponent separator, repetition separator, and escape character. The segment terminator is always a carriage return (in ASCII, a hex 0D). The other delimiters are defined in the MSH segment, with the field delimiter in the 4th character position, and the other delimiters occurring as in the field called Encoding Characters, which is the first field after the segment ID. The delimiter values used in the MSH segment are the delimiter values used throughout the entire message. In the absence of other considerations, HL7 recommends the suggested values found in Figure 2-1 delimiter values.

严格来说,这意味着您可以像使用前面提到的 6 个字符以外的任何字符一样使用字符 0A

<"formal" 回复结束>

话虽如此,我同意 Dale H. 的观点,即您最好不要在 HL7 消息的内容中使用此字符。由于大多数编辑器(Windows 上的老式记事本除外)会将此字符显示为新行,因此您可能不情愿地认为某个段被截断或格式错误。我至少有一个实例,其中接口引擎确实将该字符作为段终止处理(这本身是无效的,并且接口引擎构建被修改为不再这样做)。

所以最好避免这种情况。但是在你不控制输出的情况下,它似乎并不是一个正式禁止的字符......