23.04.2015 Views

Unofficial Mirth Connect Developer’s Guide

This is a preview version of the book. The full book, with all related files, is available at - http://mirthconnect.shamilpublishing.com This book introduces readers to free-ware and open source HL7 Interface Engine called Mirth Connect to the point that readers are confident enough to start building their own healthcare data exchange interfaces.

This is a preview version of the book. The full book, with all related files, is available at - http://mirthconnect.shamilpublishing.com

This book introduces readers to free-ware and open source HL7 Interface Engine called Mirth Connect to the point that readers are confident enough to start building their own healthcare data exchange interfaces.

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Shamil Nizamov<br />

<strong>Unofficial</strong> <strong>Mirth</strong> <strong>Connect</strong> v3.2<br />

<strong>Developer’s</strong> <strong>Guide</strong>*<br />

* - Preview Version


Copyright Page<br />

Copyright © 2013-2015 by Shamil Nizamov<br />

Cover image copyright © 2013 by Shamil Nizamov<br />

All rights reserved. No part of the contents of this book may be reproduced or<br />

transmitted in any form or by any means without the written permission of the author.<br />

<strong>Mirth</strong> <strong>Connect</strong> is a trademark of <strong>Mirth</strong> Corporation. HL7 and Health Level Seven are<br />

registered trademarks of Health Level Seven International. All other marks are property<br />

of their respective owners.<br />

Any rights not expressly granted herein are reserved.<br />

The companies, organizations, products, domain names, email addresses, logos, people,<br />

places, and/or data mentioned herein in examples are fictitious. No association with any<br />

real company, organization, product, domain name, email address, logo, person, place,<br />

or data is intended or should be inferred.<br />

This book expresses the author’s views and opinions. The information contained in this<br />

book is provided without any express, statutory, or implied warranties. The author, <strong>Mirth</strong><br />

Corporation, Health Level Seven International, resellers and distributors will NOT be held<br />

liable for any damages caused or alleged to be caused either directly or indirectly by this<br />

book.<br />

This is a preview version of the book.<br />

Introduction 2


Contents<br />

PART 1<br />

MIRTH CONNECT BASICS<br />

Chapter 1 Getting Started ................................................................................................................. 15<br />

Installation ........................................................................................................................ 15<br />

<strong>Mirth</strong> <strong>Connect</strong> Administrator ........................................................................................... 16<br />

Chapter 2 What is a Channel? ........................................................................................................... 18<br />

<strong>Connect</strong>ors ........................................................................................................................ 19<br />

Filters ................................................................................................................................ 19<br />

Transformers ..................................................................................................................... 20<br />

Scripts................................................................................................................................ 21<br />

Chapter 3 Creating a Channel ........................................................................................................... 23<br />

Source <strong>Connect</strong>or ............................................................................................................. 24<br />

TMP, MSG and MESSAGE .................................................................................................. 25<br />

Destination <strong>Connect</strong>ors .................................................................................................... 27<br />

Testing the Channel .......................................................................................................... 31<br />

Global Map, Global Channel Map, Channel Map ............................................................. 34<br />

Global Scripts .................................................................................................................... 36<br />

Code Templates ................................................................................................................ 38<br />

PART II<br />

GENERIC ELIGIBILITY SERVICE IMPLEMENTATION<br />

Chapter 4 Generic Eligibility Service Introduction ........................................................................... 41<br />

Eligibility Service Introduction .......................................................................................... 41<br />

Scenario Overview ............................................................................................................ 42<br />

Messages and Interactions Overview ............................................................................... 43<br />

Eligibility Query Channels Overview ................................................................................. 44<br />

Chapter 5 Query Sender Channel ..................................................................................................... 47<br />

Summary Tab .................................................................................................................... 47<br />

Source <strong>Connect</strong>or ............................................................................................................. 49<br />

Destinations <strong>Connect</strong>or ................................................................................................... 49<br />

Channel Implementation Verification .............................................................................. 53<br />

Chapter 6 HL7v2 to HL7v3 Transformer Channel ............................................................................. 55<br />

3 Introduction


Summary Tab .................................................................................................................... 55<br />

Source <strong>Connect</strong>or ............................................................................................................. 56<br />

Destinations <strong>Connect</strong>or ................................................................................................... 58<br />

Code Templates ................................................................................................................ 64<br />

Scripts................................................................................................................................ 65<br />

Channel Implementation Verification .............................................................................. 66<br />

Chapter 7 Data Logger Channel ........................................................................................................ 67<br />

Summary Tab .................................................................................................................... 67<br />

Source <strong>Connect</strong>or ............................................................................................................. 68<br />

Destinations <strong>Connect</strong>or ................................................................................................... 69<br />

Code Templates ................................................................................................................ 74<br />

Global Scripts .................................................................................................................... 74<br />

Channel Implementation Verification .............................................................................. 76<br />

Chapter 8 HL7v3 Verification Channel .............................................................................................. 78<br />

Summary Tab .................................................................................................................... 79<br />

Source <strong>Connect</strong>or ............................................................................................................. 79<br />

Destinations <strong>Connect</strong>or ................................................................................................... 82<br />

Code Templates ................................................................................................................ 88<br />

Global Scripts .................................................................................................................... 89<br />

Scripts................................................................................................................................ 91<br />

Channel Implementation Verification .............................................................................. 91<br />

Chapter 9 Response Sender Channel ................................................................................................ 93<br />

Summary Tab .................................................................................................................... 93<br />

Source <strong>Connect</strong>or ............................................................................................................. 94<br />

Destinations <strong>Connect</strong>or ................................................................................................... 96<br />

Scripts................................................................................................................................ 99<br />

Channel Implementation Verification ............................................................................ 100<br />

Chapter 10 HL7v3 to HL7v2 Transformer Channel .......................................................................... 102<br />

Summary Tab .................................................................................................................. 102<br />

Source <strong>Connect</strong>or ........................................................................................................... 103<br />

Destinations <strong>Connect</strong>or ................................................................................................. 103<br />

Channel Implementation Verification ............................................................................ 106<br />

Introduction 4


PART III<br />

ACKNOWLEDGEMENTS IMPLEMENTATION<br />

Chapter 11 Acknowledgements Introduction .................................................................................. 109<br />

Scenario Overview .......................................................................................................... 109<br />

Acknowledgement Channels Overview .......................................................................... 110<br />

Chapter 12 HL7v3 ACK Channel ........................................................................................................ 112<br />

Summary Tab .................................................................................................................. 112<br />

Source <strong>Connect</strong>or ........................................................................................................... 113<br />

Destinations <strong>Connect</strong>or ................................................................................................. 113<br />

Scripts.............................................................................................................................. 114<br />

Chapter 13 HL7v3 Verification ACK Channel .................................................................................... 116<br />

Destinations <strong>Connect</strong>or ................................................................................................. 116<br />

Code Templates .............................................................................................................. 119<br />

Scripts.............................................................................................................................. 120<br />

Source <strong>Connect</strong>or ........................................................................................................... 121<br />

Chapter 14 HL7v2 to HL7v3 Transformer ACK Channel .................................................................. 122<br />

Destinations <strong>Connect</strong>or ................................................................................................. 122<br />

Code Templates .............................................................................................................. 125<br />

Scripts.............................................................................................................................. 126<br />

Source <strong>Connect</strong>or ........................................................................................................... 127<br />

Channel Implementation Verification ............................................................................ 128<br />

Chapter 15 Query Sender ACK Channel ........................................................................................... 129<br />

Destinations <strong>Connect</strong>or ................................................................................................. 129<br />

Source <strong>Connect</strong>or ........................................................................................................... 131<br />

Channel Implementation Verification ............................................................................ 133<br />

PART IV<br />

ADVANCING IN MIRTH CONNECT<br />

Chapter 16 Debugging JavaScript in <strong>Mirth</strong> <strong>Connect</strong> ........................................................................ 135<br />

Built in Logger function .................................................................................................. 135<br />

Rhino JavaScript Debugger in Standalone Mode ............................................................ 136<br />

Rhino JavaScript Debugger in Embedded Mode............................................................. 137<br />

Eclipse JSDT Debugger in Embedded Mode ................................................................... 142<br />

Console Input .................................................................................................................. 145<br />

5 Introduction


Chapter 17 Utilizing JMS (Java Message Service) ............................................................................ 147<br />

Scenario Overview .......................................................................................................... 148<br />

Sending Messages ........................................................................................................... 149<br />

Sending Objects .............................................................................................................. 156<br />

Channels Implementation Verification ........................................................................... 162<br />

Chapter 18 Polling Web Services ..................................................................................................... 164<br />

Scenario Overview .......................................................................................................... 164<br />

Summary Tab .................................................................................................................. 165<br />

Source <strong>Connect</strong>or ........................................................................................................... 165<br />

Destinations <strong>Connect</strong>or ................................................................................................. 166<br />

Channels Implementation Verification ........................................................................... 171<br />

Chapter 19 Building Extensions ....................................................................................................... 173<br />

Creating Templates ......................................................................................................... 175<br />

Signing Extension ............................................................................................................ 180<br />

Deploying Extension ....................................................................................................... 181<br />

Extension Implementation Verification .......................................................................... 183<br />

Book Resources ........................................................................................................................................ 186<br />

PART V<br />

APPENDICES<br />

A: Eligibility Query Request (QUCR_IN200101) Template .............................................. 188<br />

B: Eligibility Query Results (QUCR_IN210101) Template ............................................... 189<br />

C: MS Access Log Database Structure ............................................................................. 190<br />

D: PostgreSQL Eligibility Database Structure .................................................................. 190<br />

E: XSLT to transform from HL7v3 to HL7v2 ..................................................................... 191<br />

F: JavaScriptTask.java ...................................................................................................... 193<br />

G: Archives Content ........................................................................................................ 195<br />

Introduction 6


7 Introduction<br />

This page is intentionally left blank


Introduction<br />

Introduction<br />

As <strong>Mirth</strong> Corporation says on their web-site, “<strong>Mirth</strong> <strong>Connect</strong> is the Swiss Army knife of<br />

healthcare integration engines, specifically designed for HL7 message integration. It<br />

provides the necessary tools for developing, testing, deploying, and monitoring interfaces.<br />

And because it’s open source, you get all of the advantages of a large community of users<br />

with commercial quality support.”<br />

In addition, “The 2014 HL7 Interface Technology Survey Results” show that <strong>Mirth</strong> <strong>Connect</strong><br />

is one of the fastest growing healthcare messaging platforms due to its open source<br />

paradigm, and robust functionality for HL7 messaging and X12 documents. <strong>Mirth</strong><br />

<strong>Connect</strong> also speeds up the development of interfaces for data exchange across different<br />

formats and diverse healthcare systems environment.<br />

This book describes version 3.x of <strong>Mirth</strong> <strong>Connect</strong> to the point that reader are confident<br />

enough to start building their own healthcare data exchange interfaces and transforming<br />

various versions of HL7 messages.<br />

As you read this book, you will be implementing a fictitious Eligibility Query Service. Each<br />

connection point (channel) is explained in a separate chapter, which in turn provides<br />

step-by-step instructions on how to create and code data transformation rules.<br />

This book is written using <strong>Mirth</strong> <strong>Connect</strong> 3.2.1.7650 version of the product.<br />

Consequently, other releases may include new features, or features used in this book<br />

may change or disappear. You may also notice some differences between screen shots<br />

provided in the book and those you see when using <strong>Mirth</strong> <strong>Connect</strong>.<br />

Who is this book for?<br />

I wrote this book primarily for application developers and system integrators who have<br />

found the online <strong>Mirth</strong> <strong>Connect</strong> documentation lacking and needed a guidebook that<br />

explains things in a more detailed and organized way.<br />

In a book of this size, I cannot cover every feature that <strong>Mirth</strong> <strong>Connect</strong> v3.x or previous<br />

versions have; consequently, I assume you already have some familiarity with <strong>Mirth</strong><br />

<strong>Connect</strong>.<br />

Introduction 8


Assumption<br />

This book assumes that you are dealing with applications that use message-oriented<br />

middleware products and expects that you have at least a minimal understanding of<br />

Web service technologies including, but not limited to, XML, XML Schemas, XPath, XSL<br />

Transformation and SOAP/WSDL.<br />

Before you start reading this book, you should have a basic knowledge of JavaScript and<br />

Java; MS Access and PostgreSQL databases from a database administrator perspective;<br />

and are familiarity with operating system environment variables settings.<br />

You should also have basic knowledge of HL7, the standard that is being used to<br />

exchange healthcare data, both version 2 and version 3.<br />

Who should not read this book?<br />

As mentioned earlier, the purpose of this book is to provide the reader with a high-level<br />

overview of the capabilities and features associated with <strong>Mirth</strong> <strong>Connect</strong> v3.2. This book is<br />

not intended to be a step-by-step comprehensive guide or substitute of any kind to<br />

original training and certification programs provided by <strong>Mirth</strong> Corporation (Quality<br />

Systems, Inc.).<br />

This book is also not a tutorial on a specific messaging or middleware technology<br />

implementation. All examples included in this book are for illustrative purposes only. If<br />

you are interested in learning more about a specific technology or product, please refer<br />

to one of the many on-line resources.<br />

This book does not cover any specific installation, configuration, deployment or<br />

monitoring activities for system administrators.<br />

Errata and Book Support<br />

I have made every effort to ensure the accuracy of this book and its companion content.<br />

If you find an error, please report through email - mirthconnect@isarp.com<br />

Warning and Disclaimer<br />

The purpose of this book is to educate and entertain. Every effort has been made to<br />

make this book as complete and as accurate as possible, but no warranty or fitness is<br />

implied.<br />

9 Introduction


The information is provided on an “as is” basis. The author shall have neither liability nor<br />

responsibility to any person or entity with respect to any loss or damage caused, or<br />

alleged to be caused, directly or indirectly by the information contained in this book or<br />

from the use of software mentioned in this book. The information, methods and<br />

techniques described by the author are based on his own experience. They may not work<br />

for you and no recommendation is made to follow the same course of action. No<br />

representation is made that following the advice in this book will work in your case.<br />

The author is not an employee or representative of <strong>Mirth</strong> Corporation and never has<br />

been, and author’s views and opinions are not necessarily those of <strong>Mirth</strong> Corporation.<br />

This book is not based on trainings or certifications provided by <strong>Mirth</strong> Corporation.<br />

This book contains links to third-party websites that are not under the control of the<br />

author, and the author is not responsible for the content of any linked site. If you access<br />

a third-party website mentioned in this book, then you do so at your own risk. The<br />

author provides these links only as a convenience, and the inclusion of the link does not<br />

imply that the author endorses or accepts any responsibility for the content of those<br />

third-party sites.<br />

Furthermore, this book contains information on the subject only up to the published<br />

date.<br />

Acknowledgements<br />

Like most books, this guide has been a long time in the making. I would like to<br />

acknowledge everyone who has assisted in this project. I could not have done this<br />

without you.<br />

Nathan Blakley and Elliot Freedman volunteered to review early versions of a few<br />

chapters. Your feedback helped steer me in the right direction. I’d like to thank Philip<br />

Helger in making an active contribution to the development of the open source<br />

Schematron validator.<br />

My biggest thanks go to Wayne Zafft and David Sanders, who were incredibly gracious<br />

with their time and effort in reviewing the final version of the book.<br />

Introduction 10


Roadmap<br />

This book is divided into four parts:<br />

Part 1 provides an introduction to <strong>Mirth</strong> <strong>Connect</strong> and a high-level overview of channels.<br />

• Chapter 1, Getting Started<br />

Introduces <strong>Mirth</strong> <strong>Connect</strong> at a high level, and demonstrates how to download and<br />

install <strong>Mirth</strong> <strong>Connect</strong> Server and Administrator.<br />

• Chapter 2, What is a Channel<br />

Provides an overview of the channel architecture implemented in <strong>Mirth</strong> <strong>Connect</strong>. It<br />

also covers a channel’s major components such as connectors, filters, transformers<br />

and scripts.<br />

• Chapter 3, Creating a Channel<br />

Walks the reader through the creation and configuration of a simple channel. It<br />

covers some of the major points of the <strong>Mirth</strong> <strong>Connect</strong> channels implementation<br />

model such as tmp and msg variables, different types of maps and their visibilities. It<br />

also covers Global Scripts, channel scripts and Code Templates.<br />

Part 2 focuses on the implementation of an imaginary but complete eligibility service.<br />

• Chapter 4, Generic Eligibility Service Introduction<br />

Introduces the Eligibility Service as defined in the HL7v3 Normative Edition, presents<br />

the implementation plan and walks through the required components.<br />

• Chapter 5, Query Sender Channel<br />

Walks the reader through the implementation of the first channel in a chain that<br />

serves as an interface to send HL7v2 Eligibility Query messages.<br />

• Chapter 6, HL7v2-HL7v3 Transformer Channel<br />

Explains the implementation of a channel that plays the role of a conduit or broker.<br />

The chapter shows how to establish a MLLP connection to other channels, how to<br />

filter messages based on some criteria and transform messages from one format to<br />

another using different techniques that <strong>Mirth</strong> <strong>Connect</strong> provides.<br />

• Chapter 7, Data Logger Channel<br />

11 Introduction


Explains the implementation of a channel that uses a file and MS Access database as<br />

destinations.<br />

• Chapter 8, HL7v3 Verification Channel<br />

Walks the reader through the implementation of the XML Schema and Schematron<br />

validators using external Java classes.<br />

• Chapter 9, Response Sender Channel<br />

Provides insight into implementation of a database-facing channel that retrieves<br />

data, forms the message and passes it along using a SOAP connector.<br />

• Chapter 10, HL7v3 to HL7v2 Transformer Channel<br />

Concludes the implementation of the Eligibility service and provides a detailed<br />

explanation on configuring the SOAP connector and XSL Transformation.<br />

Part 3 is dedicated to the implementation of acknowledgements.<br />

• Chapter 11, Acknowledgements Introduction<br />

Provides introduction and presents the implementation plan of a message<br />

acknowledgement based on the Eligibility Service implemented in Part 2.<br />

• Chapter 12, HL7v3 ACK Channel<br />

Explains how to create another interim channel that receives routed HL7v3 messages<br />

and stores them in a file.<br />

• Chapter 13, HL7v3 Verification ACK Channel<br />

Explains how to expand functionalities of the already existing channel to send HL7v3<br />

MCCI acknowledgements.<br />

• Chapter 14, HL7v2 to HL7v3 Transformer ACK Channel<br />

Explains how to expand functionalities of the already existing channel to send HL7v2<br />

RSP^E45 acknowledgements back and intercept HL7v3 acknowledgements received<br />

from other channels.<br />

• Chapter 15, Query Sender ACK Channel<br />

Explains how to intercept HL7v2 acknowledgements received from one channel and<br />

route them to another channel.<br />

Introduction 12


Part 4 covers advanced topics.<br />

• Chapter 16, Debugging JavaScript in <strong>Mirth</strong> <strong>Connect</strong><br />

Provides an in-depth explanation of such important topics as debugging filters and<br />

transformers JavaScript using built-in and external tools such as Rhino JavaScript<br />

Debugger and Eclipse JSDT Debugger.<br />

• Chapter 17, Utilizing JMS (Java Message Service)<br />

Introduces the JMS Sender and Listener connector configurations to pass messages<br />

and objects through a Message Broker such as Apache ActiveMQ. Provides insight<br />

into passing messages, and gives a detailed explanation of serialization /<br />

deserialization techniques to pass Java objects via the Message Broker.<br />

• Chapter 18, Polling Web Services<br />

Explains how to extend the functionality of the Web Server Sender connector to<br />

periodically poll data from external service providers.<br />

• Chapter 19, Building Extensions<br />

Provides an in-depth explanation of such confused topic as building the <strong>Mirth</strong><br />

<strong>Connect</strong> extension using the example of building a JSON Writer Destination<br />

<strong>Connect</strong>or.<br />

13 Introduction


PART I – MIRTH CONNECT BASICS<br />

<strong>Mirth</strong> <strong>Connect</strong><br />

Basics<br />

CHAPTER 1<br />

CHAPTER 2<br />

CHAPTER 3<br />

Getting Started<br />

What is a Channel?<br />

Creating a Channel<br />

PART I – MIRTH CONNECT BASICS 14


CHAPTER 1 Getting Started<br />

Getting Started<br />

T<br />

his chapter outlines the <strong>Mirth</strong> <strong>Connect</strong> basic installation procedure. All examples in<br />

this book are based on the Windows version of <strong>Mirth</strong> <strong>Connect</strong> v3.2, available to<br />

download at - http://www.mirthcorp.com/community/downloads<br />

Make sure your computer meets minimum system requirements before you start:<br />

• Oracle JRE version 1.7 or higher;<br />

• 1 GB of RAM is recommended;<br />

• A web browser.<br />

Installation<br />

There are two possible ways to install <strong>Mirth</strong> <strong>Connect</strong> based on what package you have<br />

downloaded or what package is available on the website. In one case, the package is an<br />

archive of all files and classes that you need to run <strong>Mirth</strong> <strong>Connect</strong> on your computer. You<br />

simply unzip and copy the package to an appropriate folder, for example to the<br />

C:\Program Files\<strong>Mirth</strong> <strong>Connect</strong>\. In the other case, there is a GUI based installer<br />

that you just start and go through the steps in the installation wizard. The installation<br />

process itself is quite straight forward.<br />

In both cases what is installed are <strong>Mirth</strong> <strong>Connect</strong> Server, <strong>Mirth</strong> <strong>Connect</strong> Server Manager,<br />

<strong>Mirth</strong> <strong>Connect</strong> Administrator and <strong>Mirth</strong> <strong>Connect</strong> Command Line Interface. During the<br />

installation you have to decide which port will be used by the <strong>Mirth</strong> <strong>Connect</strong> Server. By<br />

default it is 8080 for unsecure communication and 8443 for the SSL connection. You can<br />

change it later using the <strong>Mirth</strong> <strong>Connect</strong> Server Manager.<br />

To verify the installation:<br />

• Launch the <strong>Mirth</strong> <strong>Connect</strong> Server either through the <strong>Mirth</strong> <strong>Connect</strong> Server Manager<br />

or the <strong>Mirth</strong> <strong>Connect</strong> Command Line;<br />

• Open the web browser and type localhost:8080 in the address bar;<br />

• Click the Access Secure Site button in Web Dashboard Sign In launch page;<br />

• Type admin for the user name and repeat admin as the password, click Sign in.<br />

If you see the Dashboard statistics page with, most likely, no channels available, you have<br />

successfully done the installation and ready to continue. If not, refer to <strong>Mirth</strong> <strong>Connect</strong> 3.0<br />

15 PART I – MIRTH CONNECT BASICS


User <strong>Guide</strong> written by “the same <strong>Mirth</strong> technical experts who developed the software”<br />

available at - http://info.mirth.com/<strong>Connect</strong>_Documentation_Download.html<br />

Configuration<br />

The <strong>Mirth</strong> <strong>Connect</strong> Server Manager can be used as a single point to launch <strong>Mirth</strong><br />

<strong>Connect</strong> Service, configure ports, allocated memories, and database connections.<br />

However, a fully-fledged configuration description is beyond the scope of this book.<br />

Here is only a recommended step is to add a path to the \custom-lib folder to the<br />

operating system’s CLASSPATH environment variable. This is the folder where you put<br />

your Java classes, libraries and other required files.<br />

Versions 1 and 2 of <strong>Mirth</strong> <strong>Connect</strong> were using port 1099 for viewing statistics though the<br />

JMX (Java Management Extensions) and RMI (Remote Method Invocation) interfaces.<br />

This port is no longer used in version 3.x. Hence, if any of your applications or firewall is<br />

utilizing ports 8080 or 8443 you can either change <strong>Mirth</strong>’s ports using <strong>Mirth</strong> <strong>Connect</strong><br />

Server Manager or manually modify the configuration file located in<br />

\conf\mirth.properties. Don’t forget to restart the <strong>Mirth</strong> <strong>Connect</strong> Server or Service for<br />

any changes to make effect.<br />

<strong>Mirth</strong> <strong>Connect</strong> Administrator<br />

The <strong>Mirth</strong> <strong>Connect</strong> Administrator is a Java application that is not explicitly installed on a<br />

local computer by default in a distributed environment. It is downloaded from the <strong>Mirth</strong><br />

<strong>Connect</strong> Server. The reason for this is to ensure the <strong>Mirth</strong> <strong>Connect</strong> Administrator<br />

matches version of the <strong>Mirth</strong> <strong>Connect</strong> Server.<br />

To download the <strong>Mirth</strong> <strong>Connect</strong> Administrator:<br />

• Start <strong>Mirth</strong> <strong>Connect</strong> Server if it is not already running as a service;<br />

• Open the web browser;<br />

• Type localhost:8080 in the address bar;<br />

• Click Launch <strong>Mirth</strong> <strong>Connect</strong> Administrator in the <strong>Mirth</strong> <strong>Connect</strong> Administrator launch<br />

page;<br />

• Click Ok to open the webstart.jnlp;<br />

• Type admin for the user name and repeat admin as the password in the <strong>Mirth</strong><br />

<strong>Connect</strong> Login pop-up window, then click Login.<br />

If everything is done correctly, each time you login, you will see the Dashboard as the<br />

initial screen. The Dashboard displays two information panels:<br />

PART I – MIRTH CONNECT BASICS 16


• Channels status and statistics - the number of messages Received, Filtered,<br />

Queued, Sent, and Errored. The Dashboard Tasks area on the navigation bar on the<br />

left side has menu items essential for developing channels such as Refresh, Send<br />

Messages, and Remove All Messages. Same menu items can be accessed faster by<br />

right clicking on a channel row.<br />

• Logs – Server Log, <strong>Connect</strong>ion Log and Global Maps. The Server Log is used a lot to<br />

debug channels development. Double-clicking on a Server Log entry brings a pop-up<br />

window where you can view and copy the entire log entry content. The Server Log is<br />

stored by <strong>Mirth</strong> <strong>Connect</strong> Server in the database and therefore closing and opening<br />

the <strong>Mirth</strong> <strong>Connect</strong> Administrator brings back all entries not previously explicitly<br />

purged. To clear the Server Log click Clear Displayed Log under the Server Log or<br />

<strong>Connect</strong>ion Log area.<br />

Logging Level<br />

Channel’s log level can be configured manually by changing \conf\log4j.properties<br />

entries. Available options are: ERROR, WARN, INFO, DEBUG, and TRACE with DEBUG<br />

selected by default. Log levels may be configured separately for filters, transformers,<br />

postprocessors and other scripts that are explained later in this book.<br />

FIGURE 1-1 <strong>Mirth</strong> <strong>Connect</strong> Administrator window by default<br />

Familiarize yourself with other navigation items and tabs since this is the main tool used<br />

to develop channels throughout this book.<br />

17 PART I – MIRTH CONNECT BASICS


CHAPTER 2 What is a Channel?<br />

What is a Channel?<br />

T<br />

he Channel is an essential part of <strong>Mirth</strong> <strong>Connect</strong> and can be seen as one-to-many<br />

abstract unidirectional pipes to decouple components from each other to transfer<br />

healthcare data between two or more applications. The channel architecture<br />

implemented in <strong>Mirth</strong> <strong>Connect</strong> can divide a large message processing task into a<br />

sequence of smaller independent steps. This affords developers the flexibility for<br />

dependency, maintenance and/or performance. Some of the processing tasks can even<br />

be external to <strong>Mirth</strong> <strong>Connect</strong> and developed independently.<br />

FIGURE 2-1 <strong>Mirth</strong> <strong>Connect</strong> abstract channel architecture<br />

In general, each channel consists of inbound and outbound <strong>Connect</strong>ors, Filters and<br />

Transformers. The connector that receives inbound messages from the Sending<br />

Application is called the Source. Similarly, the connector that sends outbound messages<br />

is called the Destination. From the Source connector data is passed through the channel,<br />

where filters and transformers perform operations on the data, for example, routing a<br />

message to one or another Destination connector and transforming the data<br />

representation. Deciding channel’s tasks is when wearing an analyst's hat comes into<br />

play.<br />

Before you create a new channel, you need to elicit the following requirements:<br />

• Type of Application the channel reads data from (Source connector type);<br />

• Type of Application the channel sends data to (Destination connector type);<br />

• Type and format of the inbound message;<br />

• Type and format of the outbound message(s);<br />

PART I – MIRTH CONNECT BASICS 18


• Mapping table(s) between inbound and outbound messages (Transformation).<br />

<strong>Connect</strong>ors<br />

Filters<br />

In terms of Enterprise Integration, the connector is a Message Endpoint that specifies a<br />

particular way or, more accurately, a particular protocol <strong>Mirth</strong> <strong>Connect</strong> should use to<br />

communicate with an external application or another <strong>Mirth</strong> <strong>Connect</strong> channel.<br />

<strong>Mirth</strong> <strong>Connect</strong> supports sending and receiving messages over a variety of connectors<br />

listed here in no particular order:<br />

• TCP/MLLP;<br />

• Database (MySQL, PostgreSQL, Oracle, Microsoft SQL Server, ODBC);<br />

• File (local file system and network shares);<br />

• PDF and RTF documents;<br />

• JMS;<br />

• HTTP (note that HTTPS is not supported in the free version);<br />

• SMTP;<br />

• SOAP (over HTTP).<br />

The connector that receives the data is called a Reader, for example the MLLP Reader.<br />

The connector that sends the data is called a Writer, the Database Writer is an example.<br />

<strong>Connect</strong>or types are configured under the Source and Destinations tabs of the channel,<br />

which is explained later in this chapter. As should be obvious, some settings are common<br />

across all connectors while others are unique to a specific connector type.<br />

If you need a connector that is not shipped with the <strong>Mirth</strong> <strong>Connect</strong> installation package,<br />

you can develop your own one (such as a custom HTTPS connector). Some templates<br />

and developer’s level documentation for such development are in the chapter dedicated<br />

to <strong>Mirth</strong> extensions.<br />

In a real world scenario, when numerous applications and channels are connected, a<br />

channel may receive messages from several sources and these messages may have to be<br />

processed differently, based on the message type or other criteria.<br />

There are two paradigms for solving this problem, a Router and a Filter:<br />

19 PART I – MIRTH CONNECT BASICS


• Router connects to multiple outbound channels. The key benefit of the Router is that<br />

the decision criteria for the destination(s) of a message are maintained in a single<br />

location.<br />

• Filter, this is what <strong>Mirth</strong> <strong>Connect</strong> uses, is built into a message processing mechanism<br />

and is responsible for determining whether the message should be processed or not.<br />

The Filter inspects message properties (segments or elements) without removing the<br />

message from the message queue. If the message cannot be consumed by this<br />

particular pipe, it is returned to the queue unchanged for another pipe to filter or<br />

process.<br />

Filters can be as simple as specific elements comparison against a hard coded value or as<br />

complex as JavaScript scripts and external Java classes. Filters can also be omitted<br />

allowing all messages to pass through. Some routing capabilities have been introduced<br />

in <strong>Mirth</strong> <strong>Connect</strong> v3.1 by using a "destinationSet". If a destination is removed from the<br />

destination set, this destination will not receive the message.<br />

If a single channel needs to process more than one type of messages, you can create any<br />

number of separate pipes – Destinations - and specify none, one or more filters for each<br />

of them.<br />

Transformers<br />

More often than not, messages are sent between legacy systems, custom applications<br />

and third-party solutions, each of which is built around a proprietary data model. Even<br />

systems that claim to support a single standard may place specific requirements on data<br />

format and content. If we could bring all legacy systems to a single format when a new<br />

business requirement is proposed, we would avoid conversion issues. Unfortunately, for<br />

most legacy systems, data format, content or data sequence changes are difficult and<br />

risky, and simply not feasible.<br />

How do we communicate data using different formats then? In <strong>Mirth</strong> <strong>Connect</strong> this is<br />

done by a message Transformer that translates one data format into another. As a result,<br />

a destination application expects to receive messages it understands which can be<br />

processed and stored in the application’s internal data format.<br />

<strong>Mirth</strong> <strong>Connect</strong> allows message translation to occur at different levels, and to chain<br />

message transformers to achieve a required result.<br />

Supported transformers are:<br />

PART I – MIRTH CONNECT BASICS 20


Scripts<br />

• Message Builder maps segments of the inbound message to segments in the<br />

outbound message.<br />

• Mapper maps segments of the inbound message to internal <strong>Mirth</strong> <strong>Connect</strong> variables.<br />

These variables may be used later.<br />

• External Script, as the name suggests, employs external JavaScripts to transform or<br />

map the data.<br />

• XSLT Step utilizes the XSL transformation.<br />

• JavaScript, along with External Script, is where flexibility comes into play. Here any<br />

type of (Rhino) Java Script and Java code can be used.<br />

Channels also support unique features called Scripts to enhance the message processing<br />

logic. Scripts apply to a channel itself and all messages that are passing through.<br />

These scripts are:<br />

• Deploy script is executed each time <strong>Mirth</strong> <strong>Connect</strong> Server starts or a channel is<br />

redeployed. This is the best place to initialize variables or create class objects.<br />

• Attachment script deals with a message in a native format and allows extracting a<br />

part of the message to store as an attachment or to irrevocably modify a message.<br />

• Preprocessor script also allows handling each message in a native format before<br />

<strong>Mirth</strong> <strong>Connect</strong> starts translating it into the internal format, which is XML.<br />

• Filter & Transformer scripts are the main places where you handle the inbound and<br />

outbound messages.<br />

• Response script, as the name suggests, handles the response sent by a destination.<br />

• Postprocessor script is executed after the message has been successfully sent.<br />

• Undeploy script is launched each time <strong>Mirth</strong> <strong>Connect</strong> Server stops. This is the place<br />

to, for example, release memory that was allocated for the classes used by the<br />

channel.<br />

Scripts are performed in the following order:<br />

1. Global Deploy script;<br />

2. Deploy;<br />

3. Attachment script;<br />

4. Global Preprocessor script;<br />

5. Preprocessor script;<br />

6. Source connector Filters script;<br />

7. Source connector Transformer script or mapping;<br />

8. Destination 1 connector Filters script;<br />

21 PART I – MIRTH CONNECT BASICS


9. Destination 1 connector Transformer script or mapping;<br />

10. Destination N connector Filters script;<br />

11. Destination N connector Transformer script or mapping;<br />

12. Response 1 Transformer script or mapping;<br />

13. Response N transformer script or mapping;<br />

14. Postprocessor script;<br />

15. Global Postprocessor script;<br />

16. Undeploy;<br />

17. Global Undeploy script.<br />

Deploy and Undeploy scripts are performed only once, when a channel is deployed or<br />

undeployed, respectively. It is important to note that Global Deploy and Deploy scripts<br />

are also executed every time any channel is redeployed. Same with Undeploy and Global<br />

Undeploy scripts, they are executed for every channel. All other scripts are performed<br />

every time a message is sent through a channel or an acknowledgement is received.<br />

Notice that the Global Preprocessor script is executed before the channel’s Preprocessor<br />

script is executed. Similarly, after the channel’s Postprocessor script completes, the<br />

Global Postprocessor script is run.<br />

If channels operate in series, the Attachment Script of the first channel is the first to<br />

perform. The Postprocessor Script of the same channel will be executed last, after all<br />

other scripts in all consequent channels. (see Figure 2-2)<br />

FIGURE 2-2 Scripts execution sequence<br />

Next, we will explore each of these steps in detail.<br />

PART I – MIRTH CONNECT BASICS 22


This is a preview edition of the book.<br />

The complete version is available to download at<br />

http://mirthconnect.shamilpublishing.com<br />

23 PART I – MIRTH CONNECT BASICS


Book Resources<br />

Book Resources<br />

Other titles you may be interested in:<br />

<strong>Unofficial</strong> Developer's <strong>Guide</strong> to CCD on <strong>Mirth</strong><br />

<strong>Connect</strong><br />

This book introduces readers to version 3.x of <strong>Mirth</strong><br />

<strong>Connect</strong> to the point that they are confident enough<br />

to start building their own healthcare data exchange<br />

interfaces.<br />

By implementing an imaginary CCD Builder Server,<br />

this book covers topics on XSL Transformation,<br />

acknowledgements implementation, XML schema and<br />

Schematron validation. Each connection point<br />

(channels and destinations) is explained in a separate<br />

chapter, which in turn provides step-by-step<br />

instructions on how to create and code data<br />

transformation rules for ADT and ORU messages.<br />

The book is available to download at –<br />

http://ccdonmirth.shamilpublishing.com<br />

<strong>Unofficial</strong> Developer's <strong>Guide</strong> to HL7v3 Basics<br />

This book introduces readers to HL7 version 3 to the<br />

point that they are confident enough to start building<br />

their own healthcare data exchange interfaces. The<br />

book provides clear and easy to use, step-by-step<br />

guidance for learning the standard, with numerous<br />

examples covering many topics.<br />

This book may be interesting for those implementing<br />

the Clinical Document Architecture (CDA) or HL7<br />

Reference Information Model (aka RIM) based<br />

solutions.<br />

The book is available to download at –<br />

http://hl7basics.shamilpublishing.com<br />

PART I – MIRTH CONNECT BASICS 24


APPENDICES<br />

Appendices<br />

A: Eligibility Query Request (QUCR_IN200101) Template<br />

B: Eligibility Query Results (QUCR_IN210101) Template<br />

C: MS Access Log Database Structure<br />

D: PostgreSQL Eligibility Database Structure<br />

E: XSLT to transform from HL7v3 to HL7v2<br />

F: JavaScriptTask.java<br />

G: Archives Content<br />

There are five archives provided with this book each of which contains a complete set of<br />

files required for Part II, Part III and Part IV implementations.<br />

Eligibility.NoACK<br />

Folder Files Comment<br />

Channels<br />

Code Template.xml<br />

Data Logger.xml<br />

Global Script.xml<br />

HL7v3 Verification.xml<br />

Query Sender.xml<br />

Response Sender.xml<br />

v2-v3 Transformater.xml<br />

v3-v2 Transformater.xml<br />

Channels, code templates and<br />

global scripts for Part II<br />

implementation.<br />

custom-lib<br />

DB<br />

HL7v2\Samples<br />

/coreschemas<br />

/schemas<br />

/schematron<br />

PostgreSQL-Eligibility DB.sql<br />

QBP_Log.accdb<br />

QBP_E22_Request.hl7<br />

RSP_E22_Error.hl7<br />

RSP_E22_Success.hl7<br />

RSP-45_Template.hl7<br />

QUCR-RSP.xslt<br />

Custom-lib folder for <strong>Mirth</strong> <strong>Connect</strong><br />

Server installation.<br />

PostgreSQL patients database<br />

MS Access Log database<br />

HL7v2\Templates<br />

HL7v2\XSLT<br />

HL7v3 Schemas for HL7v3 messages<br />

HL7v3\-<br />

QUCR_IN200101UV01_Request_Annotated.xml Annotated Eligibility query response<br />

Samples_Annotated QUCR_IN210101UV01_Error_Annoteated.xml and request messages


HL7v3\Templates<br />

QUCR_IN210101UV01_Success_Annotated.xml<br />

QUCR_IN200101_Template.xml<br />

QUCR_IN210101_Template.xml<br />

Eligibility query response and<br />

request template messages with<br />

empty fields<br />

Eligibility.ACK-NACK<br />

Folder Files Comment<br />

Channels<br />

Code Template ACK.xml<br />

Data Logger.xml<br />

Global Script.xml<br />

HL7v3 ACK.xml<br />

HL7v3 Verification-ACK.xml<br />

Query Sender ACK.xml<br />

v2-v3 Transformer-ACK.xml<br />

Channels, code templates and<br />

global scripts for Part III<br />

implementation.<br />

custom-lib<br />

DB<br />

HL7v2\Samples<br />

/coreschemas<br />

/schemas<br />

/schematron<br />

PostgreSQL-Eligibility DB.sql<br />

QBP_Log.accdb<br />

ACK-A01_Negative.hl7<br />

ACK-A01_Positive.hl7<br />

Custom-lib folder for <strong>Mirth</strong> <strong>Connect</strong><br />

Server installation.<br />

PostgreSQL patients database<br />

MS Access Log database<br />

HL7v2 acknowledgement samples<br />

HL7v3 Schemas for HL7v3 messages<br />

HL7v3\Samples MCCI_IN000002UV01.xml HL7v3 acknowledgement sample<br />

HL7v3\-<br />

Samples_Annotated<br />

MCCI_IN000002UV01-Annotated.xml<br />

HL7v2 acknowledgement sample<br />

with annotations<br />

HL7v3\Templates MCCI_IN000002_template.xml HL7v2 acknowledgement template<br />

with empty fields<br />

Eligibility.JMS<br />

Folder Files Comment<br />

Channels<br />

Code Template.xml<br />

Data Logger JMS.xml<br />

Data Logger RAW.xml<br />

Channels, code templates and<br />

global scripts for Part IV<br />

implementation.<br />

HL7v3 Verification JMS.xml<br />

HL7v3 Verification RAW.xml<br />

Query Sender JMS.xml<br />

v2-v3 Transformer JMS.xml<br />

v2-v3 Transformer RAW.xml<br />

custom-lib faultmessage.jar Custom-lib folder for <strong>Mirth</strong> <strong>Connect</strong><br />

Server installation.<br />

Debugging<br />

Folder Files Comment<br />

JSDT JavaScriptTask.java Eclipse JSDT debugger in<br />

embedded mode.<br />

APPENDICES 26


Rhino Debugger JavaScriptTask.java Rhino JavaScript debugger in<br />

embedded mode.<br />

Polling.zip<br />

Folder Files Comment<br />

Channels Web Service Polling.xml Polling channel for Chapter 19<br />

Extension.JSON<br />

Folder Files Comment<br />

Deploy<br />

json/lib/org-json.jar<br />

json/destination.xml<br />

JSON Writer destination connector<br />

deployment package<br />

json/json-client.jar<br />

json/json-server.jar<br />

json/json-shared.jar<br />

jarsigner signjar.bat Batch file with command prompts<br />

to sign JARs<br />

Source\Client JSONWriter.java Client side extension template<br />

Source\Server destination.xml<br />

Server side extension templates<br />

JSONDispatcher.java<br />

JSONDispatcherProperties.java<br />

JSONWriterService.java<br />

Source\org.json JSONArray.java<br />

JSONException.java<br />

JSONObject.java<br />

JSONString.java<br />

JSONStringer.java<br />

JSONTokener.java<br />

JSONWriter.java<br />

XML.java<br />

XMLTokener.java<br />

XML to JSON library source code<br />

27 APPENDICES

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!