搜索

42.2. HL7 MLLP 协议

download PDF

HL7 通常与 HL7 MLLP 协议一起使用,它是基于文本的 TCP 套接字协议。此组件提供了 Mina 和 Netty Codec,它符合 MLLP 协议,以便您可以轻松地公开可以接受通过 TCP 传输层的 HL7 请求的 HL7 侦听器。要公开 HL7 侦听器服务,camel-mina 或 link:camel-netty 组件与 HL7MLLPCodec (mina)或 HL7MLLPNettyDecoder/HL7MLLPNettyEncoder (Netty)一起使用。

HL7 MLLP codec 可以配置如下:

Name默认值描述

startByte

0x0b

跨越 HL7 有效负载的开始字节。

endByte1

0x1c

跨越 HL7 有效负载的第一个结束字节。

endByte2

0x0d

跨越 HL7 有效负载的第 2 个结束字节。

charset

JVM 默认值

用于 codec 的编码(费用名称)。如果没有提供,Camel 将使用 JVM 默认 Charset

produceString

true

如果为 true,则 codec 使用定义的 charset 创建一个字符串。如果为 false,则 codec 会将普通字节数组发送到路由,以便 HL7 数据格式可以决定 HL7 消息内容中的实际 charset。

convertLFtoCR

false

\n 转换为 \r (0x0d, 13 十进制)作为 HL7 stipulates \r as segment terminators。HAPI 库需要使用 \r

42.2.1. 使用 Mina 公开 HL7 侦听器

在 Spring XML 文件中,我们将 mina 端点配置为使用 TCP 在端口 8888 上侦听 HL7 请求:

<endpoint id="hl7MinaListener" uri="mina:tcp://localhost:8888?sync=true&amp;codec=#hl7codec"/>

sync=true 表示此监听器是同步的,因此会将 HL7 响应返回给调用者。HL7 codec 使用 codec=#hl7codec 设置。请注意,hl7codec 只是一个 Spring bean ID,因此它可以命名为 mygreatcodecforhl7 或 any。codec 也在 Spring XML 文件中设置:

<bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
    <property name="charset" value="iso-8859-1"/>
</bean>

然后,端点 hl7MinaLlistener 可以在路由中使用,因为此 Java DSL 示例所示:

from("hl7MinaListener")
  .bean("patientLookupService");

这是一个非常简单的路由,它将侦听 HL7,并将其路由到名为 patient LookupService 的服务。这也是 Spring bean ID,在 Spring XML 中配置,如下所示:

<bean id="patientLookupService" class="com.mycompany.healthcare.service.PatientLookupService"/>

业务逻辑可以在不依赖于 Camel 的 POJO 类中实施,如下所示:

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.model.v24.segment.QRD;

public class PatientLookupService {
    public Message lookupPatient(Message input) throws HL7Exception {
        QRD qrd = (QRD)input.get("QRD");
        String patientId = qrd.getWhoSubjectFilter(0).getIDNumber().getValue();

        // find patient data based on the patient id and create a HL7 model object with the response
        Message response = ... create and set response data
        return response
    }

42.2.2. 使用 Netty 公开 HL7 侦听器(从 Camel 2.15 开始可用)

在 Spring XML 文件中,我们将 netty 端点配置为使用 TCP 在端口 8888 上侦听 HL7 请求:

<endpoint id="hl7NettyListener" uri="netty:tcp://localhost:8888?sync=true&amp;encoders=#hl7encoder&amp;decoders=#hl7decoder"/>

sync=true 表示此监听器是同步的,因此会将 HL7 响应返回给调用者。HL7 codec 使用 encoders=#hl7encoder*and*decoders=#hl7decoder 设置。请注意,hl7encoderhl7decoder 只是 bean ID,因此它们可以被不同命名。Bean 可以在 Spring XML 文件中设置:

<bean id="hl7decoder" class="org.apache.camel.component.hl7.HL7MLLPNettyDecoderFactory"/>
<bean id="hl7encoder" class="org.apache.camel.component.hl7.HL7MLLPNettyEncoderFactory"/>

然后,端点 hl7NettyListener 可用作消费者的路由,如 Java DSL 示例所示:

from("hl7NettyListener")
  .bean("patientLookupService");
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.