Make HL7 requests with flows

The HL7 healthcare standard can be very easily implemented with Mule and Saddle. We'll present you how with 2 short blog posts. This first one will describe how to make requests.

The main tip is to use the <response> block from Mule to handle the response. Let's see the flow in Saddle:

HL7Request2

  • We read the HL7 Message from a file and transform it to a String
  • The <response> block is ignored at the first time
  • We call the HL7 server
  • The server responds
  • The response goes through the <response> block, e.g. it is converted to a String, logged, and saved to a file

This is a simple example, you can adapt it to your use-case by changing the inbound-endpoint, or making more refined transformation in the <response> block. You could even send some message out of the response block, so that it is returned to the caller if it has been called synchronously.

BTW, have you noticed the nice "minus" icons that allow you to collapse blocks ?

 

Here is the XML configuration:

<?xml version="1.0" encoding="UTF-8"?>
<mule xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd /schemas/saddle/hl7/mule32/0.8 /schemas/saddle/hl7/mule32/0.8/saddle-hl7.xsd" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hl7="/schemas/saddle/hl7/mule32/0.8" xmlns:file="http://www.mulesoft.org/schema/mule/file">
    <hl7:connector name="hl7Connector" keepSendSocketOpen="false" clientSoTimeout="5000"/>
     <flow name="HL7Client">
        <file:inbound-endpoint name="getHL7File" path="/home/user/Test/in/" pollingFrequency="5000"/>
        <byte-array-to-string-transformer name="ReqtoString"/>
        <response>
            <byte-array-to-string-transformer name="RespToString"/>
            <log-component/>
            <file:outbound-endpoint name="writeResponse" path="/home/user/Test/Out/" outputPattern="hl7response.txt"/>
        </response>
        <hl7:outbound-endpoint name="sendHL7" host="127.0.0.1" port="4242" exchange-pattern="request-response" connector-ref="hl7Connector"/>
    </flow>
</mule>

We hope that this will help you implementing HL7 requests, stay tuned for the second post about HL7 Server. In the neantime, don't hesitate to share your thoughts on this!

Add comment

Security code
Refresh