You are on page 1of 31

Shamil Nizamov

Unofficial Developer’s Guide to


CDA/CCD on Mirth Connect*
* - Preview Edition
Copyright Page

Copyright © 2014-2018 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, CDA, CCD 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. The author, Mirth
Corporation, NextGen, Quality Systems Inc., Health Level Seven International, resellers
and distributors will NOT 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. The full version is available only at -
http://ccdonmirth.shamilpublishing.com

Introduction 2
Contents
PART 1 GETTING STARTED

Chapter 1 Mirth Connect Basics........................................................................................................ 13


Installation ........................................................................................................................ 13
Mirth Connect Administrator ........................................................................................... 14
Channels............................................................................................................................ 15
Connectors ........................................................................................................................ 16
Filters ................................................................................................................................ 17
Transformers..................................................................................................................... 17
Scripts................................................................................................................................ 18

Chapter 2 What is a CCD? ................................................................................................................. 20


CCD Development Approach ............................................................................................ 20
Templates ......................................................................................................................... 22
Summary ........................................................................................................................... 24

Chapter 3 System Integration Requirements ................................................................................... 26


Abstraction Layer .............................................................................................................. 26
System Integration Requirements .................................................................................... 29
Testing............................................................................................................................... 31
Summary ........................................................................................................................... 33

Chapter 4 Transforming Data with Mirth Connect .......................................................................... 35


Scenario Overview ............................................................................................................ 36
Design Considerations ...................................................................................................... 38
Summary ........................................................................................................................... 39

PART II CCD BUILDER SERVER IMPLEMENTATION

Chapter 5 Query Sender Channel ..................................................................................................... 42


Summary Tab .................................................................................................................... 42
Source Connector ............................................................................................................. 43
Destinations Connector .................................................................................................... 45
Summary ........................................................................................................................... 49
Chapter 6 CCD Builder Channel – Header ........................................................................................ 50
Summary Tab .................................................................................................................... 51

3 Introduction
Source Connector ............................................................................................................. 52
Destinations Connector .................................................................................................... 54
Code Templates ................................................................................................................ 63
Global Scripts ................................................................................................................... 65
Channel Implementation Verification .............................................................................. 65
Summary ........................................................................................................................... 66
Chapter 7 CCD Builder Channel – Allergies ..................................................................................... 67
Destinations Connector .................................................................................................... 68
Code Templates ................................................................................................................ 75
Global Scripts .................................................................................................................... 77
Channel Implementation Verification .............................................................................. 77
Summary ........................................................................................................................... 78
Chapter 8 CCD Builder Channel – Medications ............................................................................... 79
Destinations Connector .................................................................................................... 81
Global Scripts .................................................................................................................... 87
Channel Implementation Verification .............................................................................. 87
Summary ........................................................................................................................... 88

Chapter 9 CCD Builder Channel – Problems .................................................................................... 89


Destinations Connector .................................................................................................... 90
Global Scripts .................................................................................................................... 95
Channel Implementation Verification .............................................................................. 96
Summary ........................................................................................................................... 96
Chapter 10 CCD Builder Channel - Results ......................................................................................... 98
Destinations Connector .................................................................................................... 99
Global Scripts .................................................................................................................. 104
Channel Implementation Verification ............................................................................ 105
Summary ......................................................................................................................... 105

PART III CDA JAVASCRIPT PARSING LIBRARY

Chapter 11 CDA R-MIM Structure..................................................................................................... 109


Features of HL7 RIM ....................................................................................................... 110
Features of HL7 Data Types ............................................................................................ 111
Introduction 4
JavaScript Library Structure ............................................................................................ 111
Summary ......................................................................................................................... 112
Chapter 12 Defining Entity classes ................................................................................................... 113
Entity class ...................................................................................................................... 113
Entity class specializations .............................................................................................. 117
Summary ......................................................................................................................... 119
Chapter 13 Defining Role classes ...................................................................................................... 120
Role class......................................................................................................................... 120
Role class specializations ................................................................................................ 122
Summary ......................................................................................................................... 123
Chapter 14 Brining it All Together .................................................................................................... 124
Participation class .......................................................................................................... 124
Adding layers of abstraction ........................................................................................... 125
JS Library Implementation Verification .......................................................................... 129
Summary ......................................................................................................................... 131

PART IV CCD VALIDATION

Chapter 15 CCD Validation Tools ...................................................................................................... 133


XML Schema Validation .................................................................................................. 133
Schematron Validation ................................................................................................... 134
MIF Validation ................................................................................................................. 136
Conformance Validation ................................................................................................. 136
Summary ......................................................................................................................... 137
Chapter 16 CCD Validation Automation ........................................................................................... 138
XML Schema Validation .................................................................................................. 139
Schematron Validation ................................................................................................... 142
Summary ......................................................................................................................... 147
Book Resources ........................................................................................................................................ 148

APPENDICES

A: CCD Mirth Templates.................................................................................................. 151


B: Code Templates .......................................................................................................... 154

5 Introduction
C: HL7v2 Test Messages .................................................................................................. 157
D: XSLT files ..................................................................................................................... 158
E: Archive Content .......................................................................................................... 164

Introduction 6
Introduction

Introduction
As Mirth Corporation said earlier 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.”

Mirth Connect, or NextGen Connect as it is called now, was and still 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.

This book describes version 3.x of Mirth Connect to the point that reader are confident
enough to start building their own healthcare data exchange interfaces and transforming
HL7 messages to CDA/CCD documents.

As you read this book, you will be implementing a fictitious CCD Builder Server. Each
connection point (channel and destination) 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.6.1 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.

7 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 and
XSL Transformation.

Before you start reading this book, you should have a basic knowledge of Mirth Connect
development paradigm, JavaScript, Java and E4X objects; and are familiar with operating
system environment variable 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. I assume you also familiar with
Clinical Document Architecture (CDA) and, hopefully, Continuity of Care Document
(CCD).

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.6. 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 (Quality
Systems, Inc.).

This book is also not a tutorial on a specific messaging or middleware technology such
Model Driven Health Tools (MDHT) or Mirth CDAPI. 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, or trainings
and certifications provided by Mirth Corporation or its affiliates.

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 - mirthconnect@isarp.com

Introduction 8
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
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 (NextGen


Healthcare, Quality Systems, Inc.) 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 (NextGen Healthcare , Quality Systems, Inc.).

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.

The Mirth Connect is officially called “NextGen® Connect Integration Engine” now.
However, this book continues to use Mirth Connect for breviety and familiarity.

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.

I’d like to thank Philip Helger for his contribution to the development of the open-source
Schematron validator.

9 Introduction
My biggest thanks go to Wayne Zafft, who was incredibly gracious with his time and
effort in reviewing the final version of the book.

Roadmap

This book is divided into four parts:

Part I provides an introduction to Mirth Connect and a high-level overview of the CDA
document paradigm taking Continuity of Care Document (CCD) as an example.

 Chapter 1, Mirth Connect Basics


Introduces Mirth Connect at a high level, provides an overview of the channel
architecture implemented in Mirth Connect, walks the reader through the creation
and configuration of a simple channel.

 Chapter 2, What is CCD


Provides an overview of the Continuity of Care Document or CCD, the XML-based
markup standard intended to specify the encoding, structure, and semantics of a
patient summary clinical document for exchange.

 Chapter 3, Systems Integration Requirements


Provides a brief overview of system design and systems integration requirements to
demonstrate the complexity of a typical HL7 based integration project.

 Chapter 4, Transforming Data within Mirth Connect


Introduces a typical scenario as it is defined in the HL7v3 Normative Edition, presents
the implementation plan for the rest of the book and walks through the required
components.

Part II focuses on the implementation of an imaginary but complete CCD document


generating server.

 Chapter 5, Query Sender Channel


Walks the reader through the implementation of the first channel in a chain that
serves as an interface to send HL7v2 messages and handle acknowledgements.

 Chapter 6, CCD Builder Channel - Header


Explains the implementation of a channel that plays the major role in this project. The
chapter shows how to establish a MLLP connection to other channels, how to filter
messages based on some criteria and transform part of the inbound messages to
form the CCD header.

Introduction 10
 Chapter 7, CCD Builder Channel - Allergies
Expands functionality of the CCD Builder channel by adding a required segment to
the CCD document. Shows a simple transformation pattern using Mirth mapping and
XSL transformation.

 Chapter 8, CCD Builder Channel - Medications


Continues implementation of required section level templates. Shows iterations and
mapping of multiple segments.

 Chapter 9, CCD Builder Channel - Problems


Continues implementation of required section level templates. Shows iterations and
mapping of multiple segments.

 Chapter 10, CCD Builder Channel - Results


Shows how to iterate through segment groups each of which may contain repeating
segments. This chapter concludes implementation of the CCD document.

Part III describes the process of building a proof of concept JavaScript library to parse
CDA Header participants.

 Chapter 11, CDA R-MIM Structure


Introduces HL7 Reference Information Model (RIM) and HL7 data types at a high
level, provides an overview of the proposed JavaScript library structure.

 Chapter 12, Defining Entity class


Explains the implementation of an HL7 RIM Entity class and its specializations
required to handle people, organizations and places in the CDA document header.

 Chapter 13, Defining Role class


Continues implementation of the JavaScript library by adding structures to handle
Role and Patient classes.

 Chapter 14, Brining it All Together


Continues implementation of the JavaScript library by adding Participation class.
Shows how to add abstraction layers to hide complexity related to CDA Header
participants.

Part IV is dedicated to verification of the CCD document implementation.

 Chapter 15, CCD Validation Tools

11 Introduction
Introduces a message verification process using different tools and methods such as
XML schema validation, MIF validation, Schematron validation and conformance
review. Lists some open source tools and toolkits that readers may use to build and
test HL7v3 and CDA interfaces.

 Chapter 16, CCD Validation Automation


Walks the reader through the implementation of the XML Schema and Schematron
validator scripts using open-source libraries.

Appendices include:

 Archive Content
Lists folders and files included in the archive provided with the book.

 CCD Mirth Templates


Shows all outbound templates used by the CCD Builder channel’s destinations.

 Code Templates
Shows all mapping functions defined as Code Templates functions.

 XSL transformation files


Shows the XSLT file content used to build CCD segment templates.

 HL7v2 samples
Lists ADT_A28 and ORU_R01 message samples.

Introduction 12
PART I – GETTING STARTED

Getting Started
CHAPTER 1 Mirth Connect Basics

CHAPTER 2 What is CCD?

CHAPTER 3 System Integration Requirements

CHAPTER 4 Transforming Data with Mirth Connect

13 PART I – GETTING STARTED


CHAPTER 1 Mirth Connect Basics

Mirth Connect Basics


This chapter outlines the Mirth Connect basic installation procedure. All examples in
this book are based on the Windows version of Mirth Connect v3.6.1, available to
download at - http://www.mirthcorp.com/community/downloads

Make sure your computer meets minimum system requirements before you start:
 Oracle JRE version 1.6 or higher;
 1 GB of RAM is recommended;
 A web browser.

Installation

You can install Mirth Connect in either of two ways based on which package you
downloaded or which package is available on the website. In one case, the package is an
archive of all files and classes you need to run Mirth Connect on your computer. You
simply unzip and copy the package to an appropriate folder, for example to C:\Program
Files\Mirth Connect\. In the other case, there is a GUI based wizard that you start to
go through the steps in the installation. The installation process itself is quite straight
forward.

Both methods install 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 is used by the Mirth Connect Server. The
default is 8080 for unsecure communication and 8443 for the SSL connection. You can
change the ports later using the Mirth Connect Server Manager, if necessary.

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 launch page;
 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 installed Mirth Connect and are ready to continue. If not, refer to Mirth
Connect 3.6 User Guide written by “the same Mirth technical experts who developed the
software”.
PART I – GETTING STARTED 14
Configuration

The Mirth Connect Server Manager can be used as a single point to launch Mirth
Connect Service, configure ports, allocate memories, and to establish database
connections. However, a fully-fledged configuration description is beyond the scope of
this book.

As a recommended option, add a path to the \custom-lib folder in the operating


system’s CLASSPATH environment variable. This is the folder where you put Java classes,
libraries and other required files that Mirth should be working with.

If any application on your computer or firewall uses ports 8080 or 8443 you can either
change Mirth’s ports by using Mirth Connect Server Manager or by manually modifying
the configuration file located in \conf\mirth.properties. Don’t forget to restart the
Mirth Connect Server or Service to activate your changes.

Mirth Connect Administrator

The Mirth Connect Administrator is a Java application that, by default, is not explicitly
installed on a local computer in a distributed environment. It is downloaded from the
Mirth Connect Server. This ensures the Mirth Connect Administrator matches the version
of the Mirth Connect Server being used.

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 launch
page;
 Click Ok to open 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 information panels:
 Channels status and statistics – shows the number of messages Received, Filtered,
Queued, Sent, and Errored. The left sidebar of the Dashboard has tasks panel, with
menu options related to your current activity. For example, when you are developing
a channel, menu options such as Refresh, Send Messages, and Remove All Messages

15 PART I – GETTING STARTED


are displayed. These menu items can be also accessed by right clicking on a channel
name in the Channel List.
 Logs – Server Log, Connection Log and Global Maps. The Server Log is used to debug
channel 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; closing and opening the Mirth
Connect Administrator brings back all entries not explicitly purged. To clear the
Server Log click Clear Displayed Log under the Server Log or Connection Log area.

Familiarize yourself with other navigation items and tabs since this is the main tool used
to develop and configure channels throughout this book.

Channels

The Channel is an essential part of Mirth Connect and can be seen as one-to-many
abstract unidirectional pipes that 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 flexibility for
dependency, maintenance and/or performance. Some of the processing tasks can even
be external to Mirth Connect and developed independently.

FIGURE 1-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

PART I – GETTING STARTED 16


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 Destinations connector and transforming the data
representation. Deciding each 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);
 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;
 HTTP (note that HTTPS is not supported in the free version);
 SMTP;
 SOAP (over HTTP).

The connector that receives the data is called a Reader, for example the MLLP Reader.
The connector that sends the data is called a Writer, the Database Writer is an example.

Connector types are configured under Source and Destinations tabs of the channel.
Obviously, some settings are common across all connectors while others are unique to a
specific connector type.

You can develop your own connector if you need one that is not shipped with the Mirth
Connect installation package, e.g., HTTPS connector. However, this is out of scope of this
book.

17 PART I – GETTING STARTED


Filters

In a real world scenario, when numerous applications and channels are connected, a
channel may receive messages from several sources and may process these messages
differently, based on the message type or other criteria.

There are two paradigms for addressing this requirement, a Router and a Filter:
 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 determines whether or not the message should be processed. 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 comparing specific elements against a hard coded value or as
complex as a scripting language routine. Filters can also be omitted allowing all
messages to pass through. Some routing capabilities have been introduced in Mirth
Connect v3.1 by using a "destinationSet". If a destination is removed from the
destination set, this destination will not receive the message.

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
pipe.

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? Mirth Connect does this in a
message Transformer that translates one data format into another. As a result, a
destination application can receive messages it understands and which can be processed
and stored in the application’s internal data format.
PART I – GETTING STARTED 18
Mirth Connect allows message transformation 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.
 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 JavaScript routines 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 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 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 for handling 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.
 Undeploy 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.
Mirth Connect uses JavaScript as a scripting language with the ability to extend it by calls
of external Java classes. The latter may be one of those included to the Mirth installation
package or user defined.

Besides the channel level, Mirth Connect employs Global Scripts that play the same role
as channel scripts and help in separating the business logic. They have the same Deploy,

19 PART I – GETTING STARTED


Undeploy, Preprocessor and Postprocessor scripts; the only difference is that they apply to
all channels.

This concludes Mirth Connect introduction section. To find out more, you may refer to
numerous web resources, including trainings and books provided by Mirth Corporation.

You may find it helpful to read “Unofficial Mirth Connect v3.x Developer’s Guide“ eBook
which covers Mirth Connect basics and advanced topics in greater details.

This eBook is available at - http://mirthconnect.shamilpublishing.com

PART I – GETTING STARTED 20


CHAPTER 2 What is CCD?

What is CCD?
Theto specify
Continuity of Care Document or CCD, is an XML-based markup standard intended
the encoding, structure, and semantics of a patient summary clinical
document for exchange. (Wiki) From the standard development perspective “the
Continuity of Care Document is a joint effort of HL7 International and ASTM. CCD fosters
interoperability of clinical data by allowing physicians to send electronic medical
information to other providers without loss of meaning and enabling improvement of
patient care. CCD is an implementation guide for sharing Continuity of Care Record (CCR)
patient summary data using the HL7 Version 3 Clinical Document Architecture (CDA),
Release 2.” (HL7 CCD page)

Basically, what has been done is the HL7 Clinical Document Architecture (CDA) is taken
as a document markup standard and constrained by the ASTM Continuity of Care Record
(or CCR also referred to as ASTM E2369-05) data sets into specific headers and
templates. The resulting semantic equivalent was called the Continuity of Care
Document. In the U.S., this specification has been refined further by U.S. federal
incentives known as Meaningful Use.

Prerequisites

In case of any discrepancies found in this book, implementers must follow the
conformance requirements of CDA and CCD. You should have following specifications
available:
 HL7v3 Normative Edition - HL7 Clinical Document Architecture, Release 2.0;
 HL7 Implementation Guide: CDA Release 2 – Continuity of Care Document (CCD).

CCD Development Approach

Besides CCD standard specifications, the CCD distribution package includes CCD and
core HL7 XML schemas, CCD XSLT stylesheets and non-normative examples of
Schematron rules required to validate documents.

From a standard developer point of view, the approach used in this book to develops
core artifacts for the document-level templates (which is CCD in our case) is by taking a
subset of classes defined in the CDA R2 R-MIM model and constraining them to reflect
the ASTM CCR specification.

21 PART I – GETTING STARTED


In general these steps are:
 CDA document derives its classes and machine-processable meaning from the HL7
Reference Information Model (RIM) in conjunction with HL7v3 Data Types.
 CCD document derives its classes from CDA Refined Message Information Models
(R-MIM).
 CCD R-MIM classes are constrained by the ASTM CCR data requirements.
 As CCD R-MIM is finalized, the XML schema(s), possibly with other artifacts such as
Model Interchange Format (MIF) files and Hierarchical Message Descriptor (HMD)
views, are generated.
 As the last step, CCD XML schema is manually updated to include extensions
required to map ASTM CCR components for which there is no suitable mapping in
CDA R2.

Schematically this may be represented as Figure 2-1.

FIGURE 2-1 CCD development approach

As you can see, the CCD R-MIM, derived from the CDA R-MIM, follows the same
structure, i.e., it contains a required header to identify the document and participants,
and a body to represent a generic structure of a clinical content.

PART I – GETTING STARTED 22


This method for creating CCD XML schema is based on HL7v3 refinement and
localization mechanism and can be applied to any RIM based artifact (messages or
documents).

Templates

The next level of constraint is based on logical groupings or patterns defined at the
sections and entry levels to provide specific clinical context. Thus, as the HL7 NE states:
“The CDA specification is richly expressive and flexible. Document-level, section-level and
entry-level templates can be used to constrain the generic CDA specification.” Such
patterns, called templates, can “comply with a detailed implementation guide that details
the manner in which structured elements are to be represented and their intended
interpretation to a level sufficient to ensure a degree of clinical safety that is appropriate to
the use case that it is designed to address.” (HL7v3 NE)

This approach brings extended flexibility and allows the creation of a wide variety of
templates which still follow the HL7 standard and CDA defined structure. If you think this
is not enough, CDA allows including both structured and unstructured information at the
CDA Level. The CDA specification distinguishes three incremental levels of conformance
for semantical interoperability.

CDA Level 1: The simplest form of CDA, also known as CDA Level 1, includes the header
and unstructured block where the “NonXMLBody class represents a document body that is
in some format other than XML”. (HL7v3 NE) The CDA Level 1 is not allowed as defined in
the Meaningful Use initiative.

CDA Level 2: Next form is “the CDA specification with section-level templates applied”.
(HL7v3 NE) Section level templates are identified by an associated templateID and
represented in XML.

CDA Level 3: At this level “the CDA specification with entry-level (and optionally section-
level) templates applied.” (HL7v3 NE) At this level some section templates contain
discrete data elements called CDA entries.

Thus, built on templates, the CDA R2 implementation guide defines nine document-level
templates, where CCD is only one of them (others include Consultation Note, Diagnostic
Imaging Report, Procedure Note, Discharge Summary, etc.). Potentially they may be
represented as separate XML schemas.

23 PART I – GETTING STARTED


Section-level templates

CDA R2 defines more than 65 section-level templates. Among these are Allergies,
Encounters, Medications, Problem List, etc.

This is schematically1 shown in Figure 2-2. For simplicity some section-level templates are
not explicitly shown in the figure but represented with … titles.

CDA Sections
CCD sections

MU2
...
... Allergies Advance
Directives
...
Medical Medications ...
...
Equipment
Discharge Diet
Problems
Payers

Results

Consultation Notes sections


MU2
Reason for
Family History Immunizations Social History Physical Exam Present Illness Past Illness
Referral

... Encounters Vital Signs Plan of Care Reason for Visit General Status ...
... ...

FIGURE 2-2 CDA section-level templates

Document-level templates can exclusively use some section-level templates and share
others. For each document in US Realm, some subsets of section-level templates are
mandatory according to Meaningful Use Stage 2 (MU2).

Entry-level templates

CDA does not stop at the section level but additionally defines up to one hundred entry-
levels templates. Examples include, Age, Observation, Encounter Diagnosis,
Immunization Activity, etc.

1
This diagram is for illustrative purpose only. Any discrepancies depicted in the diagram and in the base
specifications are inadvertent and in all cases implementers must follow the conformance requirements of CCD,
CDA and MU2.
PART I – GETTING STARTED 24
As the name suggests, entry-level templates apply to one of the clinical act statements:
Observation, Substance Administration, Supply, Procedure and so on. All entry-level
templates are meant to be machine-processable parts of the document.

Some entry-level templates are used exclusively in one type of CDA document templates.
For example, Discharge Diet template is used only in Discharge Summary. Reason for
Referral entry-level template is required only in Referral Summary (HITSP2 C48)
document template, etc. Other entry-level templates such as Allergies or Diagnostic
Results are shared among all CDA document level templates.

For illustrative purpose only, an example of the Body Temperature entry-level template is
given in the code snippet below (see Source 2-1).

SOURCE 2-1 BodyTemperature entry-level template


<observation classCode="OBS" moodCode="EVN">
<templateId root="2.16.840.1.113883.3.1937.99.60.5.10.126"/>
<id root="....."/>
<code code="8310-5" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"
displayName="Body temperature"/>
<statusCode code="complete"/>
<effectiveTime>
<low value="....."/>
</effectiveTime>
<value xsi:type="PQ" value="....." unit="Cel"/>
</observation>

US Realm related CCD Implementation Guide may recommend additional sections for
conveying healthcare data that conforms to MU2 requirements. MU2 also applies
additional constrains on all template levels.

Summary

This chapter has barely scratched the surface, providing a general overview of one of the
CDA family templates called Continuity of Care Document (CCD) which is semantically
equivalent of ASTM Continuity of Care Record (CCR). Rather than explaining CCD in
depth, which requires a book by itself, this section gives you a basic road map for
exploring and understanding CCD.

If you are not familiar with HL7 and HL7v3 in particular, you may start with HL7v3
Normative Edition and move towards Clinical Document Architecture domain. I wrote
another book, called “Unofficial Developer's Guide to HL7v3 Basics3” to help you in this
endeavour.

2
HITSP - Healthcare Information Technology Standards Panel
3
Available to download at - http://hl7basics.shamilpublishing.com
25 PART I – GETTING STARTED
Below is a non-exhaustive list of other resources to help you educate yourself on various
aspects of CDA and CCD.

Primary Standard is available on the HL7.org site. You need to register to get access.

 CDA® Release 2;

CDA and CCD Implementation Guides are also available on the HL7.org site.

 HL7 Implementation Guide: CDA Release 2 – Continuity of Care Document


(CCD)4;

 HL7 Implementation Guide: S&I Framework Transitions of Care Companion Guide


to Consolidated-CDA for Meaningful Use Stage 2, Release 1 – US Realm;

Additionally you may find samples of section and entry level templates.

 IHE CDA Section Templates -


wiki.ihe.net/index.php?title=Category:CDA_Section_Templates

Below are listed quite a few books that I found helpful in this topic. If you are not familiar
with HL7 or CDA in particular, start with Tim Benson’s book then continue with the book
written by Keith Boone.

 Principles of Health Interoperability HL7 and SNOMED by Tim Benson.

 The CDA Book by Keith W. Boone.

You may also find some technical files. These are provided in the package that is part of
this book:

 Non-normative MU2 constrained CCD R-MIM diagram in Visio format (for


illustrative purpose only);

 Hierarchical Message Descriptions (HMD) in Excel View derived from the CCD R-
MIM (for illustrative purpose only).

4
Referred in this book as HL7 CCD.
PART I – GETTING STARTED 26
This is a preview edition of the book.

The full versions of this and other related books are available to
download at
http://ccdonmirth.shamilpublishing.com

27 PART I – GETTING STARTED


Book Resources

Book Resources
Other titles you may be interested in:

Unofficial Mirth Connect v3.x Developer's


Guide

This book introduces readers to version 3.x of Mirth


Connect to the point that they are confident enough
to start building their own healthcare data exchange
interfaces.

By implementing an imaginary Eligibility Query


Service, this book covers some of the topics on XML
schema and Schematron validation, XSL
Transformation, database connection pool creation,
acknowledgements implementation, Mirth Connect
extensions implementation and sending objects via
the ActiveMQ Message Broker.

The book is available to download at –


http://mirthconnect.shamilpublishing.com

Unofficial Developer's Guide to FHIR on Mirth


Connect

This book describes version 3.x of Mirth Connect to


the point that reader are confident enough to start
building their own healthcare data exchange
interfaces using a new HL7 standard called FHIR or
Fast Healthcare Interoperability Resources.

This book may be interesting for those implementing


HL7 FHIR based solutions.

The book is available to download at –


http://fhironmirth.shamilpublishing.com
Unofficial Developer's Guide to HL7v3 Basics

This book introduces readers to HL7 version 3 to the


point that they are confident enough to start building
their own healthcare data exchange interfaces. The
book provides clear and easy to use, step-by-step
guidance for learning the standard, with numerous
examples covering many topics.

The book is available to download at –


http://hl7basics.shamilpublishing.com

29 PART I – GETTING STARTED


APPENDICES

Appendices
A: CCD Mirth Templates

B: Code Templates

C: HL7v2 Test Messages

D: XSLT files

E: Archive Content

These are files provided as supplementary materials required for parts II, III and IV.

Folder Files Comment


..\Channels\Compile CDA CCD Builder.xml Mirth Connect channels, code
CDA Builder Library.xml template library and global scripts to
Global Scripts.xml compile CDA discussed in the Part II
Query Sender.xml
..\Channels\Parse CDA CDA JavaScript Library.xml Mirth Connect channel, code
CDA Participants.xml template libraries to parse CDA
HL7 Data Types Library.xml discussed in the Part III
RIM Classes Library.xml
..\Models\coreschemas\ datatypes-base.xsd HL7 core XML schema files required
datatypes-rX-cs.xsd to validate CCD document instances
datatypes.xsd
infrastructureRoot.xsd
NarrativeBlock.xsd
voc.xsd
..\Models\Schemas\ CCD-Body.xsd Localized, non-normative XML
CCD-Header.xsd schemas for CCD header and CCD
POCD_MT000041SN.xsd body parts.
POCD_MT000042SN.xsd
..\Models\ExcelView\ POCD_MT000041SN.xls Document element descriptions in
POCD_MT000042SN.xls MS Excel format
..\Models\HTMLView\ POCD_MT000041SN.htm Document element descriptions in
POCD_MT000042SN.htm HTML format
..\Models\MWBModels\ Add Person or Patient Information.mwb Messaging Workbench (MWB)
Unsolicited Observation Message.mwb models to validate ADT and ORU
MsgStructure.txt message samples.
..\Models\PictureView\ POCD_RM000041SN-Header.png CCD header and body R-MIM
POCD_RM000042SN-Body.png representation
..\Models\VisioModels\ POCD_RM000041SN-Header.vsd CCD header and body R-MIM models
POCD_RM000041SN-Header.xml in Visio format
POCD_RM000042SN-Body.vsd
POCD_RM000042SN-Body.xml
..\SampleMessages\CCD\ CCD_Allergies_Mirth_Template.xml Parts of CCD document to serve as
CCD_Body_Mirth_Template.xml outbound Mirth Connect templates
CCD_Header_Mirth_Template.xml for the CCD Builder channel’s
CCD_Header_Template_annotated.xml destinations
CCD_Medications_Mirth_Template.xml
CCD_Problems_Mirth_Template.xml
CCD_Results_Mirth_Template.xml
\SampleMessages\HL7v2 ADT_A28.hl7 Samples of HL7v2.6 messages (uses
ORU_R01.hl7 v2.7 datatypes)
..\XSLT\ Allergies_Entry.xslt XSL Transformation scripts required
Medications_Entry.xslt for CCD Builder channel’s
NoResults_Entry.xslt destinations
Problems_Entry.xslt
Results_Entry.xslt

31 APPENDICES