Monday 28 October 2013

Mirth Client - Android


With this post I wish to share a really exciting research/development to have a Mirth Dashboard on interface administrator’s mobile device (Android device in this case).

I have just relocated to Pune for a new job and was not able to post anything during this time. On my new job I am working on a mobile healthcare platform and evaluating Mirth Connect as interface engine for few of our clients. Last time I worked on Mirth was in 2008. But I feel the core of all the integration engines is same.
Now comming back to this article, the idea to have a mirth client on Android is not my own but came from my manager in a casual discussion and I picked it up.
There is very less that an interface administrator could do or would prefer to do with channels (create/edit/deploy) on a mobile device but there is a lot that he can monitor and control (view statistics /start/stop/pause/resume).
Let’s first explore the application then will share some technical details.
The application displays the mirth connect dashboard on android device. It requires the login credentials to connect with Mirth Server and HTTP endpoint of a special mirth channel that serves as base for this application.
On successful connection, the application will display a dashboard with list of channels deployed.
Mirth Client Android - Login
Mirth Client Android - Dashboard
Mirth Client Android - Channel Statistics
Channel Status Indicator
Channel Status
Started
Channel Status
Stopped
Channel Status
Paused
Login Channel List with Status Expanded Channel Statistics
Mirth Client Android - Channel Action
Long press any channel to display action menu.
Action(s) on Started Channel Action(s) on Paused Channel Action(s) on Stopped Channel

The dashboard refreshes automatically every 10 seconds (this is default interval) to sync recent data i.e. channel statistics & status. Everytime dashboard refreshes, it sends a request to our special mirth channel. A short refresh interval could impact performance of Mirth Server (I have not tested this).
To use this application your device should be connected to same network of Mirth Server on wireless LAN.
To start with my research experience (note: I am not a java developer or android developer and just learning the things)

Approach - 1 (not convincing)

My initial idea was to just display deployed channels with statistics. I started exploring mirth database to get these details, it was not difficult. Now the problem was to get these details on android and I couldn’t find a feasible solution. There was an option to have a service to listen for requests but this would lead to a complex deployment for a simple application.

Approach - 2 (failed)

After holding on the Approach-1, I started digging the mirth API and found that API provides all the functions to get the data that I wanted (deployed channels list with statistics) and much more like controlling the channels (start, stop, pause, resume, deploy, undeploy).
So with the Mirth Client API, I developed a small java project in eclipse and was successful to get the channel list and to send commands to start/stop/pause/resume channels.
After successful java project I tried same thing in Android Project and oops……. it didn’t work on Android. Same code, same jars that was used in java project but Android project was not able to resolve some classes of jars (ClassNotFoundException). I tried many things to resolve this with no luck. I suppose the problem was with JDK versions. Also the project becaome to heavy to load on low memory device after referencing all the mirth-client libraries.

Approach - 3 (worked like a champ)

While discovering ways to use Mirth client APIs I found something which lead me to the current solution.
The solution is to have a mirth channel with HTTP reader source and a Javascript Writer destination.
My HTTP reader listens on a specific HTTP port and expects HTTP POST request with a body containing XML with request details. This XML contains the login credential and action request (fetch channel list or start/stop/pause/resume a channel)
HTTP reader passes the XML to Javascript Writer which handles the request and returns response XML which is then sent to client by HTTP reader.

Javascript Writer parses the request XML to identify the request type. If the request type is not to fetch channel list then the request will have an additional parameter channelId, this will identify the channel on which the operation is to be performed.
For "fetch channel list" request it returns the list of channels, for other requests is returns status code 0 for failure, 1 for success.

Source code of this application is available on my git hub https://github.com/j4jayant/MirthClient-Android/tree/master/mirthClient
Mirth Channel designed for this application is available here in xml format, which can be imported using Mirth Administrator or CLI https://github.com/j4jayant/MirthClient-Android/tree/master/mirthChannel
Android APK file can be downloaded from here mirthClient.apk
This is not a carefully architected and designed solution and can be improved.

Sample Immunization Records Blockchain using Hyperledger Composer

This is basic and sample Blockchain implementation of Immunization Records using Hyperledger Composer.  Source Code available at:  https...