unofficial mirth connect v3.0 developer's guide (preview)
DESCRIPTION
This is a preview version of the book. The full version is available to download at http://mirthconnect.shamilpublishing.comThe focus of this book is to introduce readers to version 3.x of Mirth Connect to the point that they confident enough to start building their own healthcare data exchange interfaces.By implementing an imaginary Eligibility Query Service, described in this book, some of the topics you will cover are schema and Schematron validation, XSL Transformation, database connection pool creation, acknowledgements implementation, Mirth extensions implementation and sending objects via the ActiveMQ Message Broker. Each connection point (channel) is explained in a separate chapter, which in turn provides step-by-step instructions how to create and code data transformation rules.TRANSCRIPT
Introduction 2
Copyright Page
Copyright © 2013-2014 by Shamil Nizamov
Cover image copyright © 2013 by Shamil Nizamov
All rights reserved. No part of the contents of this book may be reproduced or
transmitted in any form or by any means without the written permission of the author.
Mirth Connect is a trademark of Mirth Corporation. HL7 and Health Level Seven are
registered trademarks of Health Level Seven International. All other marks are property
of their respective owners.
Any rights not expressly granted herein are reserved.
The companies, organizations, products, domain names, email addresses, logos , people,
places, and/or data mentioned herein in examples are fictitious. No association with any
real company, organization, product, domain name, email address, logo, person, place,
or data is intended or should be inferred.
This book expresses the author’s views and opinions. The information contained in this
book is provided without any express, statutory, or implied warranties. Neither the
author, Mirth Corporation, Health Level Seven International, nor resellers, or distributors
will be held liable for any damages caused or alleged to be caused either directly or
indirectly by this book.
* This is a preview edition of the book.
3 Introduction
Contents
PART 1 MIRTH CONNECT BASICS
Chapter 1 Getting Started ........................................................................................................ 14
Installation ............................................................................................................... 14
Mirth Connect Administrator .................................................................................... 15
Chapter 2 What is a Channel? .................................................................................................. 17
Connectors............................................................................................................... 18
Filters ...................................................................................................................... 18
Transformers............................................................................................................ 19
Scripts...................................................................................................................... 20
Chapter 3 Creating a Channel ................................................................................................... 22
Source Connector ..................................................................................................... 23
TMP, MSG and MESSAGE .......................................................................................... 24
Destination Connectors............................................................................................. 26
Testing the Channel .................................................................................................. 30
Global Map, Global Channel Map, Channel Map ......................................................... 33
Global Scripts ........................................................................................................... 35
Code Templates........................................................................................................ 37
PART II GENERIC ELIGIBILITY SERVICE IMPLEMENTATION
Chapter 4 Generic Eligibility Service Introduction...................................................................... 40
Eligibility Service Introduction ................................................................................... 40
Scenario Overview .................................................................................................... 41
Messages and Interactions Overview ......................................................................... 42
Eligibility Query Channels Overview ........................................................................... 43
Chapter 5 Sender Channel ........................................................................................................ 46
Summary Tab ........................................................................................................... 46
Source Tab ............................................................................................................... 48
Destinations Tab....................................................................................................... 48
Channel Implementation Verification......................................................................... 51
Chapter 6 HL7v2 to HL7v3 Transformation Channel .................................................................. 54
Introduction 4
Summary Tab ........................................................................................................... 54
Source Tab ............................................................................................................... 55
Destinations Tab....................................................................................................... 57
Code Templates........................................................................................................ 64
Scripts...................................................................................................................... 64
Channel Implementation Verification......................................................................... 65
Chapter 7 Logging Channel ....................................................................................................... 66
Summary Tab ........................................................................................................... 66
Source Tab ............................................................................................................... 67
Destinations Tab....................................................................................................... 68
Code Templates........................................................................................................ 73
Global Scripts ........................................................................................................... 73
Channel Implementation Verification......................................................................... 75
Chapter 8 HL7v3 Verification Channel....................................................................................... 77
Summary Tab ........................................................................................................... 78
Source Tab ............................................................................................................... 78
Destinations Tab....................................................................................................... 80
Code Templates........................................................................................................ 86
Global Scripts ........................................................................................................... 87
Scripts...................................................................................................................... 88
Channel Implementation Verification......................................................................... 90
Chapter 9 Response Channel .................................................................................................... 91
Summary Tab ........................................................................................................... 91
Source Tab ............................................................................................................... 92
Destinations Tab....................................................................................................... 94
Scripts...................................................................................................................... 97
Channel Implementation Verification......................................................................... 97
Chapter 10 HL7v3 to HL7v2 Transformation Channel .................................................................. 99
Summary Tab ........................................................................................................... 99
Source Tab ............................................................................................................. 100
Destinations Tab..................................................................................................... 100
Channel Implementation Verification....................................................................... 103
5 Introduction
PART III ACKNOWLEDGEMENTS IMPLEMENTATION
Chapter 11 Acknowledgements Introduction ............................................................................ 105
Scenario Overview .................................................................................................. 105
Acknowledgement Channels Overview .................................................................... 106
Chapter 12 HL7v2 ACK Channel ................................................................................................ 108
Summary Tab ......................................................................................................... 108
Source Tab ............................................................................................................. 109
Destinations Tab..................................................................................................... 109
Scripts.................................................................................................................... 110
Chapter 13 HL7v3 ACK Channel ................................................................................................ 112
Summary Tab ......................................................................................................... 112
Source Tab ............................................................................................................. 112
Destinations Tab..................................................................................................... 113
Scripts.................................................................................................................... 114
Chapter 14 HL7v3 Verification Channel..................................................................................... 116
Destinations Tab .................................................................................................... 116
Code Templates...................................................................................................... 118
Scripts.................................................................................................................... 120
Source Tab ............................................................................................................. 120
Chapter 15 HL7v2 to HL7v3 Transformation Channel ACK ......................................................... 122
Destinations Tab .................................................................................................... 122
Code Templates...................................................................................................... 125
Scripts.................................................................................................................... 126
Source Tab ............................................................................................................. 127
Channel Implementation Verification ...................................................................... 127
Chapter 16 Sender Channel ACK .............................................................................................. 129
Destinations Tab .................................................................................................... 129
Channel Implementation Verification ...................................................................... 130
Introduction 6
PART IV ADVANCING IN MIRTH CONNECT
Chapter 17 Debugging JavaScript in Mirth Connect .................................................................. 132
Built in Logger function .......................................................................................... 132
Rhino JavaScript Debugger in Standalone Mode ....................................................... 133
Rhino JavaScript Debugger in Embedded Mode ........................................................ 134
Eclipse JSDT Debugger in Embedded Mode .............................................................. 138
Chapter 18 Utilizing JMS (Java Message Service) ...................................................................... 143
Scenario Overview .................................................................................................. 144
Sending Messages .................................................................................................. 145
Sending Objects...................................................................................................... 152
Channels Implementation Verification ..................................................................... 159
Chapter 19 Polling Web Services ............................................................................................. 162
Scenario Overview .................................................................................................. 162
Summary Tab ......................................................................................................... 162
Source Tab ............................................................................................................. 163
Destinations Tab..................................................................................................... 163
Channels Implementation Verification ..................................................................... 169
Chapter 20 Building Extensions ............................................................................................... 171
Creating Templates................................................................................................. 173
Signing Extension.................................................................................................... 178
Deploying Extension ............................................................................................... 179
Extension Implementation Verification .................................................................... 181
PART V APPENDICES
A: Eligibility Query Request (QUCR_IN200101) Template .......................................... 184
B: Eligibility Query Results (QUCR_IN210101) Template ............................................ 185
C: MS Access Log Database Structure ....................................................................... 186
D: PostgreSQL Eligibility Database Structure ............................................................. 186
E: XSLT to transform from HL7v3 to HL7v2 ............................................................... 187
F: JavaScriptTask.java.............................................................................................. 188
G: Archives Content ................................................................................................ 190
Introduction 8
Introduction
Introduction As Mirth Corporation says on their web-site, “Mirth Connect is the Swiss Army knife of
healthcare integration engines, specifically designed for HL7 message integration. It
provides the necessary tools for developing, testing, deploying, and monitoring interfaces.
And because it’s open source, you get all of the advantages of a large community of users
with commercial quality support.”
In addition, “The 2012 HL7 Interface Technology Survey Results” show that Mirth Connect
is one of the fastest growing healthcare messaging platforms due to its open source
paradigm, and robust functionality for HL7 messaging and X12 documents. Mirth
Connect also speeds up the development of interfaces for data exchange across different
formats and diverse healthcare systems environment.
The focus of this book is to introduce readers to version 3.x of Mirth Connect to the
point that they confident enough to start building their own healthcare data exchange
interfaces.
As you read this book, you will be implementing a fictitious Eligibility Query Service. Each
connection point (channel) is explained in a separate chapter, which in turn provides
step-by-step instructions on how to create and code data transformation rules.
This book is written using Mirth Connect 3.0.0.6931 version of the product.
Consequently, other releases may include new features, or features used in this book
may change or disappear. You may also notice some differences between screen shots
provided in the book and those you see when using Mirth Connect.
Who is this book for?
I wrote this book primarily for application developers and system integrators who have
found the online Mirth Connect documentation lacking and needed a guidebook that
explains things in a more detailed and organized way.
In a book of this size, I cannot cover every feature that Mirth Connect v3.x or previous
versions have; consequently, I assume you already have some familiarity with Mirth
Connect.
9 Introduction
Assumption
This book assumes that you are dealing with applications that use message-oriented
middleware products and expects that you have at least a minimal understanding of
Web service technologies including, but not limited to, XML, XML Schemas, XPath, XSL
Transformation and SOAP/WSDL.
Before you start reading this book, you should have a basic knowledge of JavaScript and
Java; MS Access and PostgreSQL databases from a database administrator perspective;
and are familiarity with operating system environment variables settings.
You should also have basic knowledge of HL7, the standard that is being used to
exchange healthcare data, both version 2 and version 3.
Who should not read this book?
As mentioned earlier, the purpose of this book is to provide the reader with a high-level
overview of the capabilities and features associated with Mirth Connect v3.0. This book is
not intended to be a step-by-step comprehensive guide or substitute of any kind to
original training and certification programs provided by Mirth Corporation.
This book is also not a tutorial on a specific messaging or middleware technology
implementation. All examples included in this book are for illustrative purposes only. If
you are interested in learning more about a specific technology or product, please refer
to one of the many on-line resources.
This book does not cover any specific installation, configuration, deployment or
monitoring activities for system administrators.
Errata and Book Support
I have made every effort to ensure the accuracy of this book and its companion content.
If you find an error, please report through email - [email protected]
Warning and Disclaimer
The purpose of this book is to educate and entertain. Every effort has been made to
make this book as complete and as accurate as possible, but no warranty or fitness is
implied.
The information is provided on an “as is” basis. The author shall have neither liability nor
responsibility to any person or entity with respect to any loss or damage caused, or
Introduction 10
alleged to be caused, directly or indirectly by the information contained in this book or
from the use of software mentioned in this book. The information, methods and
techniques described by the author are based on his own experience. They may not work
for you and no recommendation is made to follow the same course of action. No
representation is made that following the advice in this book will work in your case.
The author is not an employee or representative of Mirth Corporation and never has
been, and author’s views and opinions are not necessarily those of Mirth Corporation.
This book is not based on trainings or certifications provided by Mirth Corporation.
This book contains links to third-party websites that are not under the control of the
author, and the author is not responsible for the content of any linked site. If you access
a third-party website mentioned in this book, then you do so at your own risk. The
author provides these links only as a convenience, and the inclusion of the link does not
imply that the author endorses or accepts any responsibility for the content of those
third-party sites.
Furthermore, this book contains information on the subject only up to the published
date.
Acknowledgements
Like most books, this guide has been a long time in the making. I would like to
acknowledge everyone who has assisted in this project. I could not have done this
without you.
Nathan Blakley and Elliot Freedman volunteered to review early versions of a few
chapters. Your feedback helped steer me in the right direction. I’d like to thank Philip
Helger in making an active contribution to the development of the open source
Schematron validator.
My biggest thanks go to Wayne Zafft and David Sanders, who were incredibly gracious
with their time and effort in reviewing the final version of the book.
11 Introduction
Roadmap
This book is divided into four parts:
Part 1 provides an introduction to Mirth Connect and a high-level overview of channels.
Chapter 1, Getting Started
Introduces Mirth Connect at a high level, and demonstrates how to download and
install Mirth Connect Server and Administrator.
Chapter 2, What is a Channel
Provides an overview of the channel architecture implemented in Mirth Connect. It
also covers a channel’s major components such as connectors, filters, transformers
and scripts.
Chapter 3, Creating a Channel
Walks the reader through the creation and configuration of a simple channel. It
covers some of the major points of the Mirth Connect channels implementation
model such as tmp and msg variables, different types of maps and their visibilities. It
also covers Global Scripts, channel scripts and Code Templates.
Part 2 focuses on the implementation of an imaginary but complete eligibility service.
Chapter 4, Generic Eligibility Service Introduction
Introduces the Eligibility Service as defined in the HL7v3 Normative Edition, presents
the implementation plan and walks through the required components.
Chapter 5, Sender Channel
Walks the reader through the implementation of the first channel in a chain that
serves as an interface to send HL7v2 Eligibility Query messages.
Chapter 6, HL7v2-HL7v3 Transformation Channel
Explains the implementation of a channel that plays the role of a conduit or broker.
The chapter shows how to establish a MLLP connection to other channels, how to
filter messages based on some criteria and transform messages from one format to
another using different techniques that Mirth Connect provides.
Chapter 7, Logging Channel
Explains the implementation of a channel that uses a file and MS Access database as
destinations.
Introduction 12
Chapter 8, HL7v3 Verification Channel
Walks the reader through the implementation of the XML Schema and Schematron
validators using external Java classes.
Chapter 9, Response Channel
Provides insight into implementation of a database-facing channel that retrieves
data, forms the message and passes it along using a SOAP connector.
Chapter 10, HL7v3 to HL7v2 Transformation Channel
Concludes the implementation of the Eligibility service and provides a detailed
explanation on configuring the SOAP connector and XSL Transformation.
Part 3 is dedicated to the implementation of acknowledgements.
Chapter 11, Acknowledgements Introduction
Provides introduction and presents the implementation plan of a message
acknowledgement based on the Eligibility Service implemented in Part 2.
Chapter 12, HL7v2 ACK Channel
Explains how to create an interim channel that receives routed HL7v2 messages and
stores them in a file.
Chapter 13, HL7v3 ACK Channel
Explains how to create another interim channel that receives routed HL7v3 messages
and stores them in a file.
Chapter 14, HL7v3 Verification Channel ACK
Explains how to expand functionalities of the already existing channel to send HL7v3
MCCI acknowledgements.
Chapter 15, HL7v2 to HL7v3 Transformation Channel ACK
Explains how to expand functionalities of the already existing channel to send HL7v2
RSP^E45 acknowledgements back and intercept HL7v3 acknowledgements received
from other channels.
Chapter 16, Sender Channel ACK
Explains how to intercept HL7v2 acknowledgements received from one channel and
route them to another channel.
13 Introduction
Part 4 covers advanced topics.
Chapter 17, Debugging JavaScript in Mirth Connect
Provides an in-depth explanation of such important topics as debugging filters and
transformers JavaScript using built-in and external tools such as Rhino JavaScript
Debugger and Eclipse JSDT Debugger.
Chapter 18, Utilizing JMS (Java Message Service)
Introduces the JMS Sender and Listener connector configurations to pass messages
and objects through a Message Broker such as Apache ActiveMQ. Provides insight
into passing messages, and gives a detailed explanation of serialization /
deserialization techniques to pass Java objects via the Message Broker.
Chapter 19, Polling Web Services
Explains how to extend the functionality of the Web Server Sender connector to
periodically poll data from external service providers.
Chapter 20, Building Extensions
Provides an in-depth explanation of such confused topic as building the Mirth
Connect extension using the example of building a JSON Writer Destination
Connector.
PART I – MIRTH CONNECT BASICS 14
PART I – MIRTH CONNECT BASICS
Mirth Connect Basics
CHAPTER 1 Getting Started
CHAPTER 2 What is a Channel?
CHAPTER 3 Creating a Channel
15 PART I – MIRTH CONNECT BASICS
CHAPTER 1 Getting Started
Getting Started his chapter outlines the Mirth Connect basic installation procedure. All examples in
this book are based on the Windows version of Mirth Connect v3.0, available to
download at http://www.mirthcorp.com/community/downloads
Make sure your computer meets minimum system requirements before you start:
Sun Java JRE 1.5/5.0 or newer;
1 GB of RAM is recommended;
A web browser.
Installation
There are two possible ways to install Mirth Connect based on what package you have
downloaded or what package is available on the website. In one case, the package is an
archive of all files and classes that you need to run Mirth Connect on your computer. You
simply unzip and copy the package to an appropriate folder, for example to the
C:\Program Files\Mirth Connect\. In the other case, there is a GUI based installer that
you just start and go through the steps in the installation wizard. The installation process
itself is quite straight forward.
In both cases what is installed are Mirth Connect Server, Mirth Connect Server Manager,
Mirth Connect Administrator and Mirth Connect Command Line Interface. During the
installation you have to decide which port will be used by the Mirth Connect Server. By
default it is 8080 for unsecure communication and 8443 for the SSL connection. You can
change it later using the Mirth Connect Server Manager.
To verify the installation:
Launch the Mirth Connect Server either through the Mirth Connect Server Manager
or the Mirth Connect Command Line;
Open the web browser and type localhost:8080 in the address bar;
Click the Access Secure Site button in Web Dashboard Sign in;
Type admin for the user name and repeat admin as the password, click Sign in.
If you see the Dashboard statistics page with, most likely, no channels available, you have
successfully done the installation and ready to continue.
T
PART I – MIRTH CONNECT BASICS 16
If not, follow this link to troubleshoot -
http://www.mirthcorp.com/.../mirth/Mirth+Connect+FAQ.
Configuration
The Mirth Connect Server Manager can be used as a single point to launch Mirth
Connect Service, configure ports, allocated memories, and database connections.
However, a fully-fledged configuration description is beyond the scope of this book.
Here is only a recommended step is to add a path to the \custom-lib folder to the
operating system’s CLASSPATH environment variable. This is the folder where you put
your Java classes, libraries and other required files.
Versions 1 and 2 of Mirth Connect were using port 1099 for viewing statistics though the
JMX (Java Management Extensions) and RMI (Remote Method Invocation) interfaces.
This port is no longer used in version 3. Hence, if any of your applications or firewall is
utilizing ports 8080 or 8443 you can either change Mirth’s ports using Mirth Connect
Server Manager or manually modify the configuration file located in
\conf\mirth.properties. Don’t forget to restart the Mirth Connect Server or Service for
any changes to make effect.
Mirth Connect Administrator
The Mirth Connect Administrator is a Java application that is not explicitly installed on a
local computer by default in a distributed environment. It is downloaded from the Mirth
Connect Server. The reason for this is to ensure the Mirth Connect Administrator
matches version of the Mirth Connect Server.
To download the Mirth Connect Administrator:
Start Mirth Connect Server if it is not already running as a service;
Open the web browser;
Type localhost:8080 in the address bar;
Click Launch Mirth Connect Administrator in the Mirth Connect Administrator;
Click Ok to open the webstart.jnlp;
Type admin for the user name and repeat admin as the password in the Mirth
Connect Login pop-up window, then click Login.
If everything is done correctly, each time you login, you will see the Dashboard as the
initial screen. The Dashboard displays two areas of information:
17 PART I – MIRTH CONNECT BASICS
Channels status and statistics - the number of messages Received, Filtered,
Queued, Sent, and Errored. The Dashboard Tasks area on the navigation bar on the
left side has menu items essential for developing channels such as Refresh, Send
Messages, and Remove All Messages. Same menu items can be accessed faster by
right clicking on a channel row.
Logs – Server Log and Connection Log. The former - Server Log - is used a lot to
debug channels development. Double-clicking on a Server Log entry brings a pop-up
window where you can view and copy the entire log entry content. The Server Log is
stored by Mirth Connect Server in the database and therefore closing and opening
the Mirth Connect Administrator brings back all entries not previously explicitly
purged. To clear the Server Log click Clear Displayed Log under the Server Log or
Connection Log area.
Logging Level
Channel’s log level can be configured manually by changing \conf\log4j.properties
entries. Available options are: ERROR, WARN, INFO, DEBUG, and TRACE with DEBUG
selected by default. Log levels may be configured separately for filters, transformers,
postprocessors and other scripts that are explained later in this book.
FIGURE 1-1 Mirth Connect Administrator window by default
Familiarize yourself with other navigation items and tabs since this is the main tool used
to develop channels throughout this book.
PART I – MIRTH CONNECT BASICS 18
CHAPTER 2 What is a Channel?
What is a Channel? he Channel is an essential part of Mirth Connect and can be seen as one-to-many
abstract unidirectional pipes to decouple components from each other to transfer
healthcare data between two or more applications. The channel architecture
implemented in Mirth Connect can divide a large message processing task into a
sequence of smaller independent steps. This affords developers the flex ibility for
dependency, maintenance and/or performance. Some of the processing tasks can even
be external to Mirth Connect and developed independently.
FIGURE 2-1 Mirth Connect abstract channel architecture
In general, each channel consists of inbound and outbound Connectors, Filters and
Transformers. The connector that receives inbound messages from the Sending
Application is called the Source. Similarly, the connector that sends outbound messages
is called the Destination. From the Source connector data is passed through the channel,
where filters and transformers perform operations on the data, for example, routing a
message to one or another Destination connector and transforming the data
representation. Deciding channel’s tasks is when wearing an analyst's hat comes into
play.
Before you create a new channel, you need to elicit the following requirements:
Type of Application the channel reads data from (Source connector type);
Type of Application the channel sends data to (Destination connector type);
Type and format of the inbound message;
Type and format of the outbound message(s);
T
19 PART I – MIRTH CONNECT BASICS
Mapping table(s) between inbound and outbound messages (Transformation).
Connectors
In terms of Enterprise Integration, the connector is a Message Endpoint that specifies a
particular way or, more accurately, a particular protocol Mirth Connect should use to
communicate with an external application or another Mirth Connect channel.
Mirth Connect supports sending and receiving messages over a variety of connectors
listed here in no particular order:
TCP/MLLP;
Database (MySQL, PostgreSQL, Oracle, Microsoft SQL Server, ODBC);
File (local file system and network shares);
PDF and RTF documents;
JMS;
FTP/SFTP;
HTTP (note that HTTPS is not supported in the free version);
SMTP;
SOAP (over HTTP).
The connector receiving the data is called a Reader, for example the MLLP Reader. The
connector sending the data is called a Writer, the Database Writer as an example.
Connector types are configured under Source and Destination tabs of the Channel, which
is explained later in this chapter. As should be obvious, some settings are common
across all connectors while others are unique to a specific connector type.
If you need a connector that is not shipped with the Mirth Connect installation package,
you can develop your own one (such as a custom HTTPS connector). Some templates
and developer’s level documentation for such development are in the chapter dedicated
to Mirth extensions.
Filters
In a real world scenario, when numerous applications and channels are connected, a
channel may receive messages from several sources and these messages may have to be
processed differently, based on the message type or other criteria.
There are two paradigms for solving this problem, a Router and a Filter:
PART I – MIRTH CONNECT BASICS 20
Router connects to multiple outbound channels. The key benefit of the Router is that
the decision criteria for the destination(s) of a message are maintained in a single
location.
Filter, this is what Mirth Connect uses, is built into a message processing mechanism
and is responsible for determining whether the message should be processed or not.
The Filter inspects message properties (segments or elements) without removing the
message from the message queue. If the message cannot be consumed by this
particular pipe, it is returned to the queue unchanged for another pipe to filter or
process.
Filters can be as simple as specific elements comparison against a hard coded value or as
complex as JavaScript scripts and external Java classes. Filters can also be omitted
allowing all messages to pass through.
If a single channel needs to process more than one type of message, you can create any
number of separate pipes – Destinations - and specify none, one or more filters for each
of them.
Transformers
More often than not, messages are sent between legacy systems, custom applications
and third-party solutions, each of which is built around a proprietary data model. Even
systems that claim to support a single standard may place specific requirements on data
format and content. If we could bring all legacy systems to a single format when a new
business requirement is proposed, we would avoid conversion issues. Unfortunately, for
most legacy systems, data format, content or data sequence changes are difficult and
risky, and simply not feasible.
How do we communicate data using different formats then? In Mirth Connect this is
done by a message Transformer that translates one data format into another. As a result,
a destination application expects to receive messages it understands which can be
processed and stored in the application’s internal data format.
Mirth Connect allows message translation to occur at different levels, and to chain
message transformers to achieve a required result.
Supported transformers are:
Message Builder maps segments of the inbound message to segments in the
outbound message.
21 PART I – MIRTH CONNECT BASICS
Mapper maps segments of the inbound message to internal Mirth Connect variables.
These variables may be used later.
External Script, as the name suggests, employs external JavaScripts to transform or
map the data.
XSLT Step utilizes the XSL transformation.
JavaScript, along with External Script, is where flexibility comes into play. Here any
type of (Rhino) Java Script and Java code can be used.
Scripts
Channels also support unique features called Scripts to enhance the message processing
logic. Scripts apply to a channel itself and all messages that are passing through.
These scripts are:
Deploy script is executed each time Mirth Connect Server starts or a channel is
redeployed. This is the best place to initialize variables or create class objects.
Attachment script deals with a message in a native format and allows extracting a
part of the message to store as an attachment or to irrevocably modify a message.
Preprocessor script also allows handling each message in a native format before
Mirth Connect starts translating it into the internal format, which is XML.
Filter & Transformer scripts are the main places where you handle the inbound and
outbound messages.
Response script, as the name suggests, handles the response sent by a destination.
Postprocessor script is executed after the message has been successfully sent.
Shutdown script is launched each time Mirth Connect Server stops. This is the place
to, for example, release memory that was allocated for the classes used by the
channel.
Scripts are performed in the following order:
1. Global Deploy script;
2. Deploy;
3. Attachment script;
4. Global Preprocessor script;
5. Preprocessor script;
6. Source connector Filters script;
7. Source connector Transformer script or mapping;
8. Destination 1 connector Filters script;
9. Destination 1 connector Transformer script or mapping;
10. Destination N connector Filters script;
PART I – MIRTH CONNECT BASICS 22
11. Destination N connector Transformer script or mapping;
12. Response 1 Transformer script or mapping;
13. Response N transformer script or mapping;
14. Postprocessor script;
15. Global Postprocessor script;
16. Shutdown;
17. Global Shutdown script.
When you create a channel, by default, all scripts are empty and do nothing.
Deploy and Shutdown scripts are performed only once, when a channel is deployed or
undeployed, respectively. It is important to note that Global Deploy and Shutdown
scripts are also executed every time a channel is redeployed.
All other scripts are performed every time a message is sent through a channel or an
acknowledgement is received. Notice that the Global Preprocessor script is executed
before the channel’s Preprocessor script is executed. Similarly, after the channel’s
Postprocessor script completes, the Global Postprocessor script is run.
Next, we will explore each of these steps in detail.
This is a preview edition of the book.
The complete version is available to download at
http://mirthconnect.isarp.com
23 PART I – MIRTH CONNECT BASICS
G: Archives Content
There are five archives provided with this book each of which contains a complete set of
files required for Part II, Part III and Part IV implementations.
Eligibility.6931.NoNACK.zip
Folder Files Comment
Channels Code Template.xml
Global Script.xml
HL7v3 Verification.xml
Logging Channel.xml
Response Channel.xml
Sender Channel.xml
v2 - v3 Transformation Channel.xml
v3 - v2 Transformation Channel.xml
Channels, code templates and
global scripts for Part II
implementation.
custom-lib .... Custom-lib folder for Mirth Connect
Server installation.
DB PostgreSQL-Eligibility DB.sql
QBP_Log.accdb
PostgreSQL patients database
MS Access Log database
HL7v2\Samples QBP-45_Malformed.hl7
QBP-45_Request.hl7
RSP-45_Error.hl7
RSP-45_Success.hl7
HL7v2\Templates RSP-45_Template.hl7
RSP-45_XML.xml
HL7v2\XSLT QUCR-RSP.xslt
HL7v3 NE2012 .... Schemas for HL7v3 messages
HL7v3 NE2012\-
Samples_Annotated
QUCR_IN200101UV01_Request_Annotated.xml
QUCR_IN210101UV01_Error_Annoteated.xml
QUCR_IN210101UV01_Success_Annotated.xml
HL7v3 NE2012\-
Templates
MCCI_IN000002_template.xml
QUCR_IN200101_template.xml
QUCR_IN210101_template.xml
Eligibility.6931.ACK-NACK.zip
Folder Files Comment
Channels Code Template.xml
Global Script.xml
HL7v2 ACK Channel.xml
HL7v3 ACK Channel.xml
Logging Channel.xml
Sender Channel.xml
v2 - v3 Transformation Channel.xml
v3 Verification Channel.xml
Channels, code templates and
global scripts for Part III
implementation.
custom-lib .... Custom-lib folder for Mirth Connect
Server installation.
PART I – MIRTH CONNECT BASICS 24
DB PostgreSQL-Eligibility DB.sql
QBP_Log.accdb
PostgreSQL patients database
MS Access Log database
HL7v2\Samples ACK-A01_Negative.hl7
ACK-A01_Positive.hl7
QBP-45_Malformed.hl7
QBP-45_Request.hl7
RSP-45_Error.hl7
RSP-45_Success.hl7
HL7v2\Templates RSP-45_Template.hl7
RSP-45_XML.xml
HL7v2\XSLT QUCR-RSP.xslt
HL7v3 NE2012 .... Schemas for HL7v3 messages
HL7v3 NE2012\-
Samples_Annotated
MCCI_IN000002UV01.xml
QUCR_IN200101UV01_Request_Annotated.xml
QUCR_IN210101UV01_Error_Annoteated.xml
QUCR_IN210101UV01_Success_Annotated.xml
HL7v3 NE2012-
\Templates
MCCI_IN000002_template.xml
QUCR_IN200101_template.xml
QUCR_IN210101_template.xml
Eligibility.6931.JMS.zip
Folder Files Comment
Channels Code Template.xml
Global Script.xml
Logging Channel.xml
Sender Channel.xml
v2 - v3 Transformation Channel.xml
v3 Verification Channel.xml
Channels, code templates and
global scripts for Part IV
implementation.
custom-lib .... Custom-lib folder for Mirth Connect
Server installation.
DB PostgreSQL-Eligibility DB.sql
QBP_Log.accdb
PostgreSQL patients database
MS Access Log database
HL7v2\Samples QBP-45_Malformed.hl7
QBP-45_Request.hl7
HL7v2\Templates QBP-45_Template.hl7
HL7v3 NE2012 .... Schemas for HL7v3 messages
HL7v3 NE2012\-
Samples_Annotated
QUCR_IN200101UV01_Request_Annotated.xml
HL7v3 NE2012-
\Templates
QUCR_IN200101_template.xml
Extension.6931.JSON.zip
Folder Files Comment
Deploy json/lib/org-json.jar
json/destination.xml
JSON Writer destination connector
deployment package
25 PART I – MIRTH CONNECT BASICS
json/json-client.jar
json/json-server.jar
json/json-shared.jar
jarsigner signjar.bat Batch file with command prompts
to sign JARs
Source Code\Client JSONWriter.java Client side extension template
Source Code\Server destination.xml
JSONDispatcher.java
JSONDispatcherProperties.java
JSONWriterService.java
Server side extension templates
Source Code\ org.json
JSONArray.java
JSONException.java
JSONObject.java
JSONString.java
JSONStringer.java
JSONTokener.java
JSONWriter.java
XML.java
XMLTokener.java
XML to JSON library source code
Polling.7171.zip
Folder Files Comment
Channels Polling Channel.xml Polling channel for Chapter 19 built
for Mirth Connect verison
3.0.3.7171