Sunday, March 12, 2017

Receiving HL7 Messages with WSO2 EI

Before getting EI involved in this story,let's get to know what are these HL7 messages? Why do we need such messages ? From where does these messages come?

What is HL7 ?

HL7 refers to a set of international standards defined for exchanging, integrating, sharing, and retrieval of clinical and administrative data between software applications used by various healthcare providers. In simple words HL7 is the common language that is used by different types of health care instruments to talk to each other.

Use case

Now let's see how these HL7 messages can be received from WSO2 EI using a simple use case.

In order to simulate emitting messages from Health instruments, we will be using Hapi Test Panel. If you are not familiar with the Hapi Test Panel you can go thorough this previous blog post about Hapi Test Panel.

Messages sent from the Hapi Test Panel will be captured by WSO2 EI's HL7 inbound endpoint and the mediated messages will be saved in a MYSQL database as shown in the below architecture diagram.


Note that we are building the above use case starting from the right side of the above diagram.

   1.  Create MySQL table and data service for storing messages
   2.  Writing Mediation logic for extracting data from HL7 messages and calling data service
   3.  Writing HL7 inbound to receive HL7 messages
   3.  Sending HL7 messages to WSO2 EI from Hapi Test Panel

    Note : As the purpose of this blog post is to demonstrate the HL7 capabilities of EI and not to deploy in any production     environment as is, we will be creating synapse configurations using management console of EI.

Creating data service in WSO2 EI

Let's first create the MySQL table for storing mediated messages. Below given is the sample table that we created in MySQL database.

   1.  Copy the MySQL driver in to EI_HOME/lib folder and start EI by running script at EI_HOME/bin
   2.  Log into the EI management console and Go to Configure --> Datasources and click Add Datasource
   3.  Fill in the details as per your created table in MySQL and Save

   4.  Then go to Main --> Generate under Data Source
   5.  Go through the wizard and generate the data service.

Note the data service name that we have used in this use case is "patient_data_DataService"

   6.  Go to Main --> Endpoints and click on Add endpoint
   7.  Choose Address Endpoint from the list of endpoints and fill in the data as given below

Since our data service name is "patient_data_DataService", our endpoint address is "http://localhost:8280/services/patient_data_DataService"

Writing mediation for the HL7 messages in WSO2 EI

   1.  Select Main --> Sequences and click on Add Sequence
   2.  Switch to the source view and paste the below given sequence

Note that we have used a payload factory mediator to extract data from HL7 message and at the end of the sequence we are calling the data service with the newly built payload.

Creating HL7 Inbound endpoint in WSO2 EI

   1.  Go to Main --> Inbound Endpoints
   2.  Then click on Add Inbound Endpoint
   3.  Give an endpoint name and select Type as HL7
   4.  Fill in the details as shown in the below image

Note that the inbound HL7 port is 20000

Sending HL7 messages from Hapi Test Panel

Send below HL7 message of type ORU^R01 and version 2.4

Now go to your MySQL table and verify whether the following entry is inserted.

Note that the payload factory mediator is written only to accept messages of type ORU^R01 and version 2.4 and in a real use case we can write the mediation logic in a more generic way to accept differnt type of HL7 messages.

Sending HL7 messages using Hapi Test Panel

The purpose of this blog post is to describe how to install the Hapi Test Panel in an ubuntu environment and send HL7 messages using that.

What is Hapi Test Panel ?

The HAPI Test Panel is a tool that can be used to send, receive and edit HL7 messages.

How to install in Ubuntu ?

There are multiple ways to install Hapi Test panel and you can find more information here. The approach that I followed was
   1.  Download hapi-testpanel-2.0.1-linux.tar.bz2 from download page
   2.  Extract the download to your preferred location
   3.  Run the file which is at the Home of the Hapi Test Panel extraction

How to send HL7 messages using Test Panel ?

   1.  Click on Test Menu and then select Populate Test Panel with Sample Message and Connections
   2.  You can send the created new message by clicking Send button which is in the top of the middle panel

If you need any specific version or type of message, you can click on File Menu and then select New Message. You can choose your preferred message version and type from the pop up window.

Enjoy sending HL7 messages with Hapi Test Panel !!!

Friday, January 27, 2017

Loading JsPlumb with RequireJS

Have you hit with an error like below ?

     Uncaught TypeError: Cannot read property 'Defaults' of undefined

Or something similar which says jsPlumb is not loaded with requireJs ?


Add jsPlumb to your shim configuration using the export setting as shown below.

And then you can use the library in the usual manner.

Saturday, October 29, 2016

Aggregate multiple responses using WSO2 ESB

This blog post explains how we can aggregate multiple responses from different endpoints.
In my previous post, I explained how we can call multiple endpoints in parallel using WSO2 ESB. So in this post we are aggregating the responses we got from those service calls.

Synapse Configuration


In this example, we have aggregated the two responses coming from our two service calls and have wrap them using My_Response tag. So your final message after the aggregation will look like below.

Note the following.
  • When aggregating we have used the same id (which is "BOOKING_RESPONSE") that we set when we are calling the two services
  • Inside "onComplete" element you can write the logic you want to perform after the aggregation. It can contain sequences or another call to an endpoint.
  • In this example we have aggregated the bodies of the two responses without any condition
  • "Aggregated_Responses" property defined before the aggregate mediator is used to accumulate the aggregated messages inside a single property. Note we have given the name of the property in the "enclosingElementProperty" tag

Apart from aggregating the responses of the service calls sent from clone mediator, we can use the aggregate mediator to aggregate responses of the service calls from iterate mediator as well.

Call multiple endpoints in parallel using WSO2 ESB

In this blog post I'm going to explain how to call multiple endpoints in parallel using the Clone Mediator.

Synapse Configuration


In the above example configuration, we are calling the two endpoints defined in the two call templates in parallel. Similarly by adding multiple "target" elements to the same configuration you can call multiple endpoints in parallel. When using the above configuration same message is cloned and two identical copies of the message is send to the two endpoints.

Note the following.
  • "sequential" attribute is set to false. Hence the two calls are happening in parallel
  • A value is set to "id" so that later we can use this id to aggregate the responses from two services
  • By default "continueParent" is set to false
  • Instead of the call template you can also use a sequence inside the "target"

In a future post I will explain how we can aggregate the response from the two services when the clone mediator is used to call endpoints.

Sunday, October 23, 2016

Adding a new xml element to the payload - WSO2 ESB

In this blog post I'm going to explain how we can insert a single new xml element in to the payload in WSO2 ESB.

Why not payloadFactory Mediator ?
If you are familiar with WSO2 ESB you may know that if we want to change the entire payload into a different payload or build a new payload by extracting properties using the existing payload, we can use payloadFactory mediator. But for this requirement that I'm going to describe, payload factory mediator will not be the ideal mediator due to different reasons. One major reason is, if the current payload is bit lengthy one, you will have to build the other parts of the payload even though you don't need to change them at all.

If not payloadFactory then what?
It will be very convenient to get this requirement done using Enrich Mediator. Enrich Mediator will take your desired OMElement (xml element) using the configuration that you state in the source section and then will insert it to the target location you state.

I will explain the configuration using a sample usecase. Say I receive some request into ESB and depending on some properties in the payload I want to set some element in the payload. For an example assume I need to insert a new element into the payload if the received payload is not a valid payload.

In the above example I have set the incoming request to ESB in to a property (INCOMING_REQUEST) during a previous mediation. And hence using the first enrich mediator I am replacing the body of the current payload using that property.
So the second mediator is the one actually does the job.
It will take the OMElement given under source which is
and will insert as a child element of /BookingRequest/Booking xpath location in the INCOMING_REQUEST xml.

Incoming Request

After enrich mediator
In this example I have modified the payload by adding only one xml element. Even if you need to add more elements also you can follow the same approach.

Many thanks to Rajith from WSO2 for the tip.

Thursday, February 20, 2014

Crowning of WSO2 ESB as "Usain Bolt" in the ESB space !!!

With the latest round of performance testing results published for WSO2 ESB 4.8.1, it is unveiled that the fastest ESB in the ESB space is WSO2 ESB. You can find the complete article here.

The tests has been conducted against number of leading open source ESB's and it is proven that WSO2 ESB surpasses rest in almost all the scenarios and crowned as the No 1.


The table and the graph below shows the summarized results.

WSO2 ESB 4.8.1 has continued to outperform all other compared ESBs in almost all scenarios !!!