25.01.2015 Views

Ensemble HL7 Version 2 Development Guide - InterSystems ...

Ensemble HL7 Version 2 Development Guide - InterSystems ...

Ensemble HL7 Version 2 Development Guide - InterSystems ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2<br />

<strong>Development</strong> <strong>Guide</strong><br />

<strong>Version</strong> 2008.1.1<br />

17 June 2008<br />

<strong>InterSystems</strong> Corporation 1 Memorial Drive Cambridge MA 02142 www.intersystems.com


<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong><br />

<strong>Ensemble</strong> <strong>Version</strong> 2008.1.1 17 June 2008<br />

Copyright © 2008 <strong>InterSystems</strong> Corporation<br />

All rights reserved.<br />

This book was assembled and formatted in Adobe Page Description Format (PDF) using tools and information from<br />

the following sources: Sun Microsystems, RenderX, Inc., Adobe Systems, and the World Wide Web Consortium at<br />

www.w3c.org. The primary document development tools were special-purpose XML-processing applications built<br />

by <strong>InterSystems</strong> using Caché and Java.<br />

and<br />

Caché WEBLINK, Distributed Cache Protocol, M/SQL, N/NET, and M/PACT are registered trademarks of <strong>InterSystems</strong><br />

Corporation.<br />

and<br />

<strong>InterSystems</strong> Jalapeño Technology, Enterprise Cache Protocol, ECP, and <strong>InterSystems</strong> Zen are trademarks of<br />

<strong>InterSystems</strong> Corporation.<br />

All other brand or product names used herein are trademarks or registered trademarks of their respective companies<br />

or organizations.<br />

This document contains trade secret and confidential information which is the property of <strong>InterSystems</strong> Corporation,<br />

One Memorial Drive, Cambridge, MA 02142, or its affiliates, and is furnished for the sole purpose of the operation<br />

and maintenance of the products of <strong>InterSystems</strong> Corporation. No part of this publication is to be used for any other<br />

purpose, and this publication is not to be reproduced, copied, disclosed, transmitted, stored in a retrieval system or<br />

translated into any human or computer language, in any form, by any means, in whole or in part, without the express<br />

prior written consent of <strong>InterSystems</strong> Corporation.<br />

The copying, use and disposition of this document and the software programs described herein is prohibited except<br />

to the limited extent set forth in the standard software license agreement(s) of <strong>InterSystems</strong> Corporation covering<br />

such programs and related documentation. <strong>InterSystems</strong> Corporation makes no representations and warranties<br />

concerning such software programs other than those set forth in such standard software license agreement(s). In<br />

addition, the liability of <strong>InterSystems</strong> Corporation for any losses or damages relating to or arising out of the use of<br />

such software programs is limited in the manner set forth in such standard software license agreement(s).<br />

THE FOREGOING IS A GENERAL SUMMARY OF THE RESTRICTIONS AND LIMITATIONS IMPOSED BY<br />

INTERSYSTEMS CORPORATION ON THE USE OF, AND LIABILITY ARISING FROM, ITS COMPUTER<br />

SOFTWARE. FOR COMPLETE INFORMATION REFERENCE SHOULD BE MADE TO THE STANDARD SOFTWARE<br />

LICENSE AGREEMENT(S) OF INTERSYSTEMS CORPORATION, COPIES OF WHICH WILL BE MADE AVAILABLE<br />

UPON REQUEST.<br />

<strong>InterSystems</strong> Corporation disclaims responsibility for errors which may appear in this document, and it reserves the<br />

right, in its sole discretion and without notice, to make substitutions and modifications in the products and practices<br />

described in this document.<br />

For Support questions about any <strong>InterSystems</strong> products, contact:<br />

<strong>InterSystems</strong> Worldwide Customer Support<br />

Tel: +1 617 621-0700<br />

Fax: +1 617 374-9391<br />

Email: support@<strong>InterSystems</strong>.com


Table of Contents<br />

About This Book ................................................................................................................................ 1<br />

1 Design Model for a Routing Production ....................................................................................... 3<br />

1.1 Fundamentals ......................................................................................................................... 3<br />

1.2 Configuration Items ............................................................................................................... 3<br />

1.3 Application Specification ....................................................................................................... 6<br />

1.4 Production Spreadsheet .......................................................................................................... 6<br />

1.5 Interface Design ..................................................................................................................... 8<br />

1.6 Naming Conventions ............................................................................................................ 11<br />

1.6.1 Business Services ....................................................................................................... 12<br />

1.6.2 Routing Processes ...................................................................................................... 13<br />

1.6.3 Routing Rule Sets for <strong>HL7</strong> ........................................................................................ 14<br />

1.6.4 Business Operations ................................................................................................... 14<br />

1.6.5 Data Transformations ................................................................................................. 15<br />

1.6.6 Custom Schema Categories ....................................................................................... 16<br />

1.7 Production Diagram ............................................................................................................. 16<br />

1.8 Production Settings .............................................................................................................. 17<br />

2 Elements of a Routing Production .............................................................................................. 19<br />

2.1 Namespaces .......................................................................................................................... 21<br />

2.2 Building the Production ....................................................................................................... 22<br />

2.3 <strong>HL7</strong> Business Services ........................................................................................................ 23<br />

2.3.1 Creating an <strong>HL7</strong> Business Service ............................................................................ 23<br />

2.3.2 Configuring an <strong>HL7</strong> Business Service ...................................................................... 25<br />

2.3.3 Integrating an <strong>HL7</strong> Business Service ......................................................................... 31<br />

2.4 <strong>HL7</strong> Custom Schema Categories ......................................................................................... 31<br />

2.5 <strong>HL7</strong> Routing Processes ........................................................................................................ 34<br />

2.5.1 Creating an <strong>HL7</strong> Routing Process ............................................................................. 34<br />

2.5.2 Configuring an <strong>HL7</strong> Routing Process ........................................................................ 35<br />

2.5.3 Integrating an <strong>HL7</strong> Routing Process .......................................................................... 37<br />

2.6 <strong>HL7</strong> Sequence Manager ....................................................................................................... 38<br />

2.6.1 Creating an <strong>HL7</strong> Sequence Manager ......................................................................... 38<br />

2.6.2 Configuring an <strong>HL7</strong> Sequence Manager ................................................................... 39<br />

2.6.3 Integrating an <strong>HL7</strong> Sequence Manager ..................................................................... 44<br />

2.7 Routing Rule Sets for <strong>HL7</strong> .................................................................................................. 44<br />

2.8 DTL Data Transformations for <strong>HL7</strong> .................................................................................... 53<br />

2.8.1 Utility Functions ........................................................................................................ 57<br />

2.8.2 Utility Class Methods ................................................................................................ 58<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong><br />

iii


2.9 <strong>HL7</strong> Business Operations .................................................................................................... 58<br />

2.9.1 Creating an <strong>HL7</strong> Business Operation ........................................................................ 58<br />

2.9.2 Configuring an <strong>HL7</strong> Business Operation .................................................................. 60<br />

2.9.3 Integrating an <strong>HL7</strong> Business Operation ..................................................................... 65<br />

2.10 Pager and Email Alerts ....................................................................................................... 65<br />

2.11 <strong>HL7</strong> Search Tables ............................................................................................................. 66<br />

3 Settings for a Routing Production .............................................................................................. 75<br />

3.1 <strong>HL7</strong> Message Validation and Bad Messages ....................................................................... 75<br />

3.1.1 The d Validation Flag ................................................................................................. 76<br />

3.1.2 The m Validation Flag ................................................................................................ 76<br />

3.1.3 The z Validation Flag ................................................................................................. 77<br />

3.1.4 Bad Message Handlers ............................................................................................... 78<br />

3.1.5 Overriding the Validation Sequence .......................................................................... 78<br />

3.2 <strong>HL7</strong> Acknowledgement (ACK) Mode ................................................................................. 79<br />

3.2.1 The AckMode Setting ................................................................................................ 81<br />

3.2.2 The UseAckCommitCodes Setting ............................................................................ 81<br />

3.2.3 The IgnoreInboundAck Setting ................................................................................. 82<br />

3.2.4 The AckTargetConfigNames Setting ......................................................................... 82<br />

3.2.5 The GetReply Setting ................................................................................................. 82<br />

3.2.6 The ReplyCodeActions Setting ................................................................................. 82<br />

3.2.7 The AddNackERR Setting ......................................................................................... 84<br />

3.3 <strong>HL7</strong> Dual Acknowledgement Sequences ............................................................................. 84<br />

3.3.1 Dual ACK Sequence for Incoming Messages ............................................................ 84<br />

3.3.2 Dual ACK Sequence for Outgoing Messages ............................................................ 85<br />

3.3.3 Configuring a Dual ACK Sequence ........................................................................... 87<br />

3.4 <strong>HL7</strong> Message Framing Types .............................................................................................. 88<br />

3.5 <strong>HL7</strong> Batch Messages ........................................................................................................... 90<br />

3.6 <strong>HL7</strong> Business Service Classes ............................................................................................. 95<br />

3.7 <strong>HL7</strong> Business Operation Classes ......................................................................................... 97<br />

4 Syntax for a Routing Production ................................................................................................ 99<br />

4.1 <strong>HL7</strong> Message Class .............................................................................................................. 99<br />

4.1.1 The DocType Property ............................................................................................. 100<br />

4.1.2 The TypeCategory Property ..................................................................................... 101<br />

4.1.3 The BuildMapStatus Property ................................................................................. 101<br />

4.1.4 The Name Property .................................................................................................. 102<br />

4.1.5 The RawContent Property ........................................................................................ 102<br />

4.1.6 The GetValueAt Method .......................................................................................... 102<br />

4.1.7 The SetValueAt Method ........................................................................................... 103<br />

4.2 Virtual Property Syntax ...................................................................................................... 103<br />

4.2.1 Curly Bracket {} Syntax .......................................................................................... 104<br />

iv<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


4.2.2 Square Bracket [] Syntax ......................................................................................... 107<br />

4.2.3 Parenthesis () Syntax in Business Rules .................................................................. 107<br />

4.2.4 Angle Bracket Syntax in Business Rules ........................................................... 108<br />

4.3 Literal String Syntax .......................................................................................................... 108<br />

4.3.1 <strong>HL7</strong> Separator Characters ........................................................................................ 110<br />

4.3.2 <strong>HL7</strong> Escape Sequences ............................................................................................ 111<br />

4.3.3 XML Entities ........................................................................................................... 113<br />

4.3.4 Numeric Character Codes ........................................................................................ 114<br />

4.3.5 Null Mapping Codes ................................................................................................ 114<br />

4.4 Schema Category Syntax ................................................................................................... 115<br />

4.4.1 .............................................................................................................. 118<br />

4.4.2 ................................................................................................ 119<br />

4.4.3 .......................................................................................... 120<br />

4.4.4 ................................................................................................ 121<br />

4.4.5 ....................................................................................................... 123<br />

5 Viewing and Transforming Messages ....................................................................................... 125<br />

5.1 Starting the <strong>Ensemble</strong> Management Portal ........................................................................ 126<br />

5.2 The Schema Structures Page .............................................................................................. 127<br />

5.2.1 Viewing a List of Document Types .......................................................................... 128<br />

5.2.2 Viewing a Message Structure ................................................................................... 128<br />

5.2.3 Viewing a Segment Structure ................................................................................... 130<br />

5.2.4 Viewing a Data Structure ......................................................................................... 132<br />

5.2.5 Viewing a Code Table .............................................................................................. 133<br />

5.2.6 Choosing a Different Category ................................................................................ 133<br />

5.3 The Document Viewer Page ............................................................................................... 134<br />

5.3.1 Viewing a Message .................................................................................................. 136<br />

5.3.2 Parsing the Message ................................................................................................. 138<br />

5.3.3 Displaying the Segment Address ............................................................................. 139<br />

5.3.4 Displaying the Field Address ................................................................................... 140<br />

5.3.5 Viewing Batch Messages ......................................................................................... 141<br />

5.3.6 Saving the Output to a File ...................................................................................... 143<br />

5.4 Filtering <strong>HL7</strong> Messages ..................................................................................................... 144<br />

5.5 Comparing <strong>HL7</strong> Messages ................................................................................................. 144<br />

6 Converting Interfaces to <strong>Ensemble</strong> ........................................................................................... 145<br />

6.1 Backing Up the Production ................................................................................................ 148<br />

6.1.1 Backup from Studio ................................................................................................. 148<br />

6.1.2 Backup from ObjectScript ....................................................................................... 149<br />

6.2 Describing the Interface ..................................................................................................... 150<br />

6.2.1 The Inbound Interface .............................................................................................. 151<br />

6.2.2 The Outbound Interface ........................................................................................... 151<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong><br />

v


6.3 Choosing Schema Categories ............................................................................................. 152<br />

6.3.1 Choosing an Incoming Schema Category ................................................................ 152<br />

6.3.2 Choosing an Outgoing Schema Category ................................................................ 153<br />

6.4 Creating Data Transformations .......................................................................................... 153<br />

6.5 Defining Routing Rule Sets ............................................................................................... 153<br />

6.6 Adding Business Operations .............................................................................................. 154<br />

6.7 Creating or Editing a Routing Process ............................................................................... 154<br />

6.8 Adding Business Services .................................................................................................. 155<br />

6.9 Testing the Interface ........................................................................................................... 155<br />

6.10 Deploying the Interface .................................................................................................... 156<br />

vi<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


List of Figures<br />

<strong>HL7</strong> Interface in <strong>Ensemble</strong> Terms ....................................................................................................... 4<br />

Routing Rules and Data Transformations ........................................................................................... 5<br />

Sample Production Spreadsheet .......................................................................................................... 7<br />

Sample Routing Production with Multiple Interfaces ....................................................................... 10<br />

Sample <strong>HL7</strong> Routing Production ...................................................................................................... 17<br />

<strong>HL7</strong> Routing Engine in <strong>Ensemble</strong> Terms ......................................................................................... 20<br />

<strong>Ensemble</strong> DTL Visual Editor ............................................................................................................ 54<br />

<strong>HL7</strong> Message Acknowledgement (ACK) Types ............................................................................... 80<br />

Paired Business Service and Business Operation for Incoming Dual ACK ...................................... 85<br />

Paired Business Service and Business Operation for Outgoing Dual ACK ...................................... 87<br />

Parent and Child Documents in <strong>HL7</strong> Batch Messages ..................................................................... 92<br />

<strong>HL7</strong> Business Service Class Hierarchy, Showing Inheritance of Settings ........................................ 96<br />

<strong>HL7</strong> Business Operation Class Hierarchy, Showing Inheritance of Settings .................................... 98<br />

<strong>HL7</strong> Message Class Overview Showing Inheritance ...................................................................... 100<br />

<strong>Ensemble</strong> Studio View of a Built-in <strong>HL7</strong> Category Definition ...................................................... 116<br />

<strong>Ensemble</strong> Studio View of a Custom <strong>HL7</strong> Category Definition ...................................................... 118<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.3.1:ORM_O01 ............................................. 128<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.3:ADT_A01 ................................................. 130<br />

<strong>Ensemble</strong> <strong>HL7</strong> Segment Structure Page ......................................................................................... 130<br />

<strong>Ensemble</strong> <strong>HL7</strong> Data Structure Page ................................................................................................ 132<br />

<strong>Ensemble</strong> <strong>HL7</strong> Code Table Page ..................................................................................................... 133<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.4:ORD_O04 ................................................ 134<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.5:ORD_O04 ................................................ 134<br />

Document Viewer Page ................................................................................................................... 136<br />

Source for Message Data ................................................................................................................ 137<br />

DocType or Schema for Message Data ........................................................................................... 137<br />

Applying a Data Transformation ..................................................................................................... 138<br />

Document Viewer Parsing Summary .............................................................................................. 139<br />

Document Viewer Showing Hover-Text Help for Segment Address .............................................. 139<br />

Document Viewer Showing Hover-Text Help for Field Address .................................................... 141<br />

<strong>HL7</strong> Batch Message with FHS and BHS, Top-Level Parent Document ......................................... 141<br />

<strong>HL7</strong> Batch Message with FHS and BHS, Mid-Level Parent Document ........................................ 142<br />

<strong>HL7</strong> Batch Message with FHS and BHS, Child Document ............................................................ 143<br />

Hospital IT Configuration Featuring an Interface Engine .............................................................. 146<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong><br />

vii


List of Tables<br />

Built-in Search Table Entries for <strong>HL7</strong> .............................................................................................. 67<br />

Attributes for the Element in Search Tables ......................................................................... 71<br />

Values for the Validation Setting ....................................................................................................... 76<br />

Acknowledgement (ACK) Modes for <strong>HL7</strong> Business Services ......................................................... 81<br />

Enhanced-Mode ACK Commit Codes for <strong>HL7</strong> 2.3 and Higher ....................................................... 82<br />

Code Values for Reply Code Actions ................................................................................................ 83<br />

Action Values for Reply Code Actions .............................................................................................. 83<br />

Framing Types for <strong>HL7</strong> Business Operations and Business Services ............................................... 89<br />

<strong>HL7</strong> Batch Message Handling Options ............................................................................................. 94<br />

<strong>HL7</strong> Escape Sequences Using Backslash as Escape Character ...................................................... 112<br />

XML Entities for Use in BPL and DTL Strings ............................................................................. 113<br />

Attributes for the Element in Schema Category Definitions ...................................... 118<br />

Attributes for the Element in Schema Category Definitions ........................ 119<br />

Attributes for the Element in Schema Category Definitions .................. 120<br />

Attributes for the Element in Schema Category Definitions ........................ 122<br />

Attributes for the Element in Schema Category Definitions ............................... 123<br />

Sample Comparison of Interface Terms: SeeBeyond and <strong>Ensemble</strong> ............................................. 151<br />

viii<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


About This Book<br />

This book is one of a set that describes how to build <strong>Ensemble</strong> productions that route and transform<br />

documents in Electronic Data Interchange (EDI) formats. This book explains how to route <strong>HL7</strong> <strong>Version</strong><br />

2 messages from one application to another using <strong>Ensemble</strong> as the routing engine. It also contains<br />

fundamental information that applies to all routing productions, including those for <strong>HL7</strong> <strong>Version</strong> 3,<br />

X12, and ASTM E 1394–97.<br />

This book contains the following sections:<br />

• Design Model for a Routing Production<br />

• Elements of a Routing Production<br />

• Settings for a Routing Production<br />

• Syntax for a Routing Production<br />

• Viewing and Transforming Messages<br />

• Converting Interfaces to <strong>Ensemble</strong><br />

The following books provide related information:<br />

• <strong>Ensemble</strong> Virtual Documents explains how the concept of virtual documents allows <strong>Ensemble</strong> to<br />

provide efficient support for EDI document exchange.<br />

• <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 3 <strong>Development</strong> <strong>Guide</strong> explains how to add <strong>HL7</strong> <strong>Version</strong> 3 interfaces to a<br />

routing production.<br />

• <strong>Ensemble</strong> X12 <strong>Development</strong> <strong>Guide</strong> explains how to add X12 interfaces to a routing production.<br />

• <strong>Ensemble</strong> ASTM <strong>Development</strong> <strong>Guide</strong> explains how to add ASTM E 1394–97 interfaces to a routing<br />

production.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 1


1<br />

Design Model for a Routing<br />

Production<br />

This chapter describes a design model that <strong>Ensemble</strong> customers have used successfully to build interface<br />

routing solutions. As such, it can be thought of as a collection of best practices for developing an<br />

<strong>Ensemble</strong> routing production.<br />

This chapter describes only one approach. Other implementation strategies can be successful as well.<br />

Each organization has its own standards for writing code and conducting programming projects. This<br />

chapter simply describes those aspects of a routing production that are unique to <strong>Ensemble</strong> and that<br />

benefit from a carefully structured approach.<br />

In general, the key to a good design is clarity and simplicity. Simplicity does not mean a small number<br />

of parts. Simplicity means that each part within the model has a clear function and is intuitively easy<br />

to find.<br />

1.1 Fundamentals<br />

Each member of the project must read the “<strong>Ensemble</strong> Productions” chapter in Developing <strong>Ensemble</strong><br />

Productions.<br />

1.2 Configuration Items<br />

An <strong>Ensemble</strong> production consists of configuration items. There are three types of configuration item:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 3


Design Model for a Routing Production<br />

• Business services accept incoming messages.<br />

• Business operations send outgoing messages.<br />

• Business processes direct all the work in between. There are some specialized types of business<br />

process:<br />

A routing process routes and transforms messages by invoking these key components of a routing<br />

production:<br />

- Routing rules direct messages to their destinations based on message contents.<br />

- Schema categories provide a means to validate and access message contents.<br />

- Data transformations apply changes to prepare messages for their destinations.<br />

A sequence manager ensures that related messages arrive at their targets with the proper sequence<br />

and timing<br />

<strong>HL7</strong> Interface in <strong>Ensemble</strong> Terms<br />

The following figure expands the diagram of a routing process to show how it uses routing rules to<br />

direct the flow of information through the interface. The following figure includes details about the<br />

routing rules and data transformations that are only implied by the dotted circle in the diagram above.<br />

A routing process has a routing rule set associated with it. Depending on how the rule set is defined,<br />

and depending on the type of message that arrives from the source application, the rule set identifies<br />

which of its rules should execute. More than one rule can execute, in sequence, but for simplicity the<br />

following figure shows the case where the rule set chooses only one rule. From this point, as shown,<br />

a rule can either delete the message or it can send the message to a destination within <strong>Ensemble</strong>. If<br />

4 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


this destination is a business operation, the message then leaves <strong>Ensemble</strong> on its way to the target<br />

application.<br />

Routing Rules and Data Transformations<br />

Configuration Items<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 5


Design Model for a Routing Production<br />

1.3 Application Specification<br />

Ideally, a clinical application provides an <strong>HL7</strong> application specification document, or implementation<br />

guide, that explains which types of <strong>HL7</strong> event the application can send (or receive), and which message<br />

segments and pieces of each segment the application sends (or expects) for these events.<br />

A formal document of this kind is extremely detailed, and extremely useful. If a specification document<br />

is available, the administrator for the clinical application can show it to you, and can explain to you<br />

which of the many possible events are actually in use in the enterprise. This is usually a small subset<br />

of the full list of events.<br />

Even if there is no application specification document, there is usually some informal documentation.<br />

Ask the application administrator to see any notes that are available.<br />

As an alternative to documentation, or to validate that the existing documentation is correct, you can<br />

examine the messages themselves to determine which types of <strong>HL7</strong> event the application sends or<br />

expects to receive. Ask the application administrator to provide you with a sampling of the message<br />

data, saved in files.<br />

Once you have the <strong>HL7</strong> message files, you can use the Document Viewer to view and parse them<br />

using various schema definitions. In this way you can quickly determine whether or not the application<br />

is using a standard <strong>HL7</strong> schema. If not, you can use the Message Viewer to refine and test a custom<br />

<strong>HL7</strong> schema for the application.<br />

Background information that supports these tasks can be found in subsequent chapters of this book:<br />

• “<strong>HL7</strong> Message Schema Categories” in the chapter “Elements of a Routing Production”<br />

• “Message Validation and Bad Messages” in the chapter “Settings for a Routing Production”<br />

• “Schema Category Syntax” in the chapter “Syntax for a Routing Production”<br />

• “The Document Viewer Page” in the chapter “Viewing and Transforming Messages”<br />

• “Choosing Schema Categories” in the chapter “Converting Interfaces to <strong>Ensemble</strong>”<br />

1.4 Production Spreadsheet<br />

It is helpful to maintain a spreadsheet that organizes your information system, application by application.<br />

You can create the spreadsheet on paper, or using any software tool that you prefer.<br />

6 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Production Spreadsheet<br />

Sample Production Spreadsheet<br />

As a general guideline, you should provide a row for each application that provides an incoming or<br />

outgoing data feed. In each row, the following columns are useful:<br />

• Feed — An interface engine or server often feeds messages from several applications into the<br />

routing production. When this is the case, note the engine or server name here.<br />

• Application — Briefly identify a specific application, its role in your system, and the person to<br />

contact about any issues or problems with this application. Ideally, this description makes sense<br />

to members of your organization who do not use <strong>Ensemble</strong>, but who are generally familiar with<br />

how the system works.<br />

• Name — A unique 3– to 6–character name for this application.<br />

• Type — The protocol that the application uses for external communications.<br />

• Connection — Connection details, such as an IP address and port number.<br />

• Sends — The <strong>HL7</strong> <strong>Version</strong> 2 message structures that this application contributes to the information<br />

system.<br />

Consider the incoming message structure after it enters the information system. Does it need to<br />

be routed or transformed differently depending on the destination system or other factors If so,<br />

list it multiple times, with a note regarding the differences. This way, your spreadsheet can serve<br />

as a checklist while you create the necessary routing rules, data transformations, and custom<br />

schemas for each case.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 7


Design Model for a Routing Production<br />

• Receives — The <strong>HL7</strong> <strong>Version</strong> 2 message structures that this application consumes from the<br />

information system.<br />

• ACKs — Acknowledgement details. Are ACK and NACK messages expected Is there a separate<br />

interface for sending and receiving them Should <strong>Ensemble</strong> generate the ACKs and NACKs, or<br />

will the receiving application do so<br />

When you begin the project, your initial spreadsheet does not need to describe every application in<br />

the information system. You can add to the spreadsheet as you deploy each new interface.<br />

1.5 Interface Design<br />

This topic outlines an effective way to keep interface designs modular so that your <strong>Ensemble</strong> production<br />

remains easy to understand, scale, and maintain at each stage of its development:<br />

• Provide one business service for each application that sends <strong>HL7</strong> messages into <strong>Ensemble</strong>. This<br />

is an application that has at least one entry in the Sends column of the production spreadsheet.<br />

One business service can receive all of the message structures for the same application. This is<br />

usually the appropriate design. When you set up a business service for this purpose you generally<br />

intend for it to stay connected to its application system all the time.<br />

There might be aspects of the configuration that require you to provide additional business services<br />

connected to the same application. For example, if the source application is already configured<br />

to send messages to two different TCP/IP ports, you could set up one business service to receive<br />

all the messages from one port, and another business service for the other port. This is generally<br />

consistent with the model of one business service per application, since there is one business service<br />

per communication source.<br />

Alternatively, when hundreds of users of the same clinical application are sending data into the<br />

enterprise, it can be useful to route all of these messages into <strong>Ensemble</strong> via one business service<br />

that may or may not stay permanently connected to any single instance of the application.<br />

• Provide one routing process for each business service. The routing process can route messages<br />

based on the contents of the message itself, or information stored in <strong>Ensemble</strong>. If the routing<br />

depends on the contents of other messages, or requires invocation of external applications to<br />

determine the routing, the routing process should be a BPL business process that calls out to other<br />

classes. However, in most cases a routing process based on the built-in routing rule engine is<br />

sufficient.<br />

Consider using a sequence manager when it is vital that related messages arrive at their targets in<br />

the proper sequence.<br />

8 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Interface Design<br />

• Provide one business operation for each application that receives <strong>HL7</strong> messages from <strong>Ensemble</strong>.<br />

This is an application that has at least one entry in the Receives column of the production<br />

spreadsheet.<br />

One business operation can send all the different message structures for the same application.<br />

This is usually the appropriate design. When you set up a business service for this purpose you<br />

generally intend for it to stay connected to its application system all the time. However, as for<br />

business services, there might be variations on this model.<br />

The guiding principle is to keep your design modular. That is, develop one interface at a time and use<br />

one routing process for each interface. This contrasts with a model in which a single large routing<br />

process serves as the routing engine for all interfaces. There are a number of reasons why many routing<br />

processes are better than one:<br />

• Each routing rule set is simpler and easier to maintain because it only covers the cases required<br />

by one interface. It is easier to share and reuse work that is self-contained and solves a simple set<br />

of problems.<br />

• Interfaces become easy to develop, replace, and maintain individually. If the enterprise must<br />

remove or upgrade a particular application, only those routing processes that deal with that<br />

application need to be touched. If an interface goes down, only that interface needs to be disabled,<br />

diagnosed, repaired, and retested before you can bring it back up.<br />

This is much cleaner than requiring you to retest and validate all of the rules in one large routing<br />

process every time you need to add, remove, or repair one interface. These considerations become<br />

especially important as some of your interfaces go live, while others are still in development. Each<br />

addition to a routing process that is already in production might require you to retest and validate<br />

hundreds of existing rules.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 9


Design Model for a Routing Production<br />

Sample Routing Production with Multiple Interfaces<br />

Each configuration item in the production has a specific role to play. Keep each item to its role:<br />

• Keep business services and business operations simple. In general, it is not necessary to write<br />

your own code for business services or business operations. Choose the built-in classes that<br />

<strong>Ensemble</strong> provides. This choice gives you the correct adapters automatically. Configure these<br />

classes using <strong>Ensemble</strong> Management Portal settings.<br />

• Place all complex activities under control of a routing process. If an interface is simple, its routing<br />

processes need not be complex, but if complexity exists, it belongs in a routing process, not in a<br />

business service or business operation. To accomplish tasks, a routing process can chain to other<br />

routing processes, or it can invoke business rules, routing rules, data transformations, business<br />

processes, or custom code. For details, see the chapter “Elements of a Routing Production. ”<br />

10 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Naming Conventions<br />

1.6 Naming Conventions<br />

This topic explains the importance of naming conventions and provides examples.<br />

Typically you will develop your <strong>Ensemble</strong> production incrementally, one interface at a time. There is<br />

a temptation to name items “as you go,” and to allow naming conventions to grow incrementally along<br />

with the project. <strong>InterSystems</strong> recommends you do not take this incremental approach to naming<br />

conventions.<br />

Remember that a full HIS system can involve hundreds of interfaces. Anticipate the task of managing<br />

the routing production once all of these interfaces are included. The name of each component should<br />

clearly identify its purpose. This way, developers and system administrators can easily predict a<br />

component’s name based on its function.<br />

<strong>InterSystems</strong> recommends that you establish a full set of naming conventions at the start of the project,<br />

then stick with them. This alleviates the need to backtrack into your production configuration just to<br />

correct names.<br />

Any convention that clearly identifies components by function is fine. The following is a full set of<br />

naming conventions that several <strong>Ensemble</strong> customers have used successfully:<br />

• List the individual segments that you will assemble to create names. These might include:<br />

- Keywords:<br />

• From for incoming<br />

• To for outgoing<br />

• Router for routing<br />

• Rules for rule sets<br />

• A base schema category number — 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5 — for schemas<br />

- A short name for each application<br />

- Keywords that identify a general class of message structures (ADT, ORM, etc)<br />

- Full message structure names (ADT_A01, ADT_A04, ORM_O01, etc)<br />

• Keep each segment of the name brief (3–6 characters)<br />

• Remember that names are case-sensitive<br />

• Use only alphanumeric characters<br />

• Do not use the characters ;:|,<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 11


Design Model for a Routing Production<br />

• Do not use underscore characters (_) in data transformation names, because for data transformations<br />

the configuration name must be the same as the class name, and class names cannot use underscores.<br />

You may use underscores in the names of configuration items that are business hosts, because in<br />

that case the configuration name can be different from the class name.<br />

For each element of the production, assemble a name from the segments that you have defined:<br />

• Business services: FromSourceAppName<br />

• Business operations: ToTargetAppName<br />

• Routing processes: SourceAppNameRouter<br />

• Routing rule sets: SourceAppNameRules<br />

• Data transformations:<br />

SourceAppNameSourceMessageTypeToTargetAppNameTargetMessageType<br />

• Custom schema categories: SourceAppNameBaseSchemaNumber<br />

For more complex designs:<br />

• Business services: FromSourceAppNameMessageTypes<br />

• Business operations: ToTargetAppNameMessageTypes<br />

• Routing processes: SourceAppNameMessageTypesRouter<br />

• Routing rule sets: SourceAppNameMessageTypesRules<br />

The following topics provide explanations and examples for these naming conventions.<br />

1.6.1 Business Services<br />

Convention<br />

Examples<br />

FromERChart, FromFineOR, FromDeskAdm<br />

12 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Naming Conventions<br />

Variation<br />

If you have decided to organize an interface so that one application sends messages into <strong>Ensemble</strong> via<br />

more than one business service, also include a keyword that classifies the MessageTypes that pass<br />

through each business service. A typical MessageTypes keyword uses the first three letters of the <strong>HL7</strong><br />

<strong>Version</strong> 2 message structure, such as ADT, ORM, or ORU. In this case the convention for the business<br />

service name is FromSourceAppNameMessageTypes.<br />

Examples<br />

FromERChartADT, FromERChartORM, FromERChartOther<br />

1.6.2 Routing Processes<br />

Convention<br />

Examples<br />

ERChartRouter, FineORRouter, DeskAdmRouter<br />

If you have decided to organize an interface so that one application sends messages into <strong>Ensemble</strong> via<br />

more than one business service, also include a keyword that classifies the MessageTypes that pass<br />

through each business service to its routing process. In this case the format for the routing process<br />

name is as follows:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 13


Design Model for a Routing Production<br />

Variation<br />

Examples<br />

ERChartADTRouter, ERChartORMRouter, ERChartOtherRouter<br />

1.6.3 Routing Rule Sets for <strong>HL7</strong><br />

Convention<br />

Each routing process has an associated rule set whose rules determine message destinations. The rules<br />

direct the messages to data transformations or business operations based on message type, message<br />

contents, time of day, or other factors. Name each rule set to match its routing process. That is, for<br />

each SourceAppNameRouter, call the rule set SourceAppNameRules. For each<br />

SourceAppNameMessageTypesRouter, call the rule set SourceAppNameMessageTypesRules.<br />

Examples<br />

DeskAdmRules<br />

DeskAdmORMRules<br />

1.6.4 Business Operations<br />

Convention<br />

Examples<br />

ToImagit, ToFineOR, ToPindex<br />

14 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Naming Conventions<br />

Variation<br />

If you have decided to organize an interface so that one application receives messages from <strong>Ensemble</strong><br />

via more than one business operation, also include a keyword that classifies the MessageTypes that<br />

passes through each business operation. A typical MessageTypes keyword uses the first three letters<br />

of the <strong>HL7</strong> <strong>Version</strong> 2 message structure, such as ADT, ORM, or ORU. In this case the convention for<br />

the business operation name is as follows:<br />

Examples<br />

ToMainLabADT, ToMainLabORM, ToMainLabOther<br />

1.6.5 Data Transformations<br />

Convention<br />

Remember that the SourceMessageType and TargetMessageType may have the same name, but represent<br />

the same message structure in different schema categories.<br />

Examples<br />

ERChartADTA03ToMainLabADTA03, ERChartADTA02ToMainLabADTA01<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 15


Design Model for a Routing Production<br />

1.6.6 Custom Schema Categories<br />

Convention<br />

The ApplicationName can represent a sending application or a receiving application.<br />

Examples<br />

ERChart2.2, Imagit2.3.1, OurFavorite2.5<br />

1.7 Production Diagram<br />

The following production diagram illustrates some of the best practices described in this chapter. This<br />

is the type of diagram that you can build and view from the <strong>Ensemble</strong> Management Portal [<strong>Ensemble</strong>]<br />

> [Productions] page, as described in the next chapter, “Elements of a Routing Production.” Keep in<br />

mind that only true configuration items are shown: business services, business processes, and business<br />

operations. Supporting the business processes are the other production components, including business<br />

rules, data transformations, and custom schema definitions.<br />

16 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Production Settings<br />

Sample <strong>HL7</strong> Routing Production<br />

1.8 Production Settings<br />

When you are viewing a configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, you can click<br />

on one of the production items in the diagram. Its full range of settings display in a panel below the<br />

diagram. For details about these settings, see “The Configuration Page” chapter in Managing<br />

<strong>Ensemble</strong> Productions.<br />

In an <strong>Ensemble</strong> production, Pool Size controls how many system jobs a configuration item can consume<br />

at the same time. Many jobs can be running at once, but a Pool Size of 1 ensures that each configuration<br />

item gets only one of these jobs at a time. A Pool Size of 1 prevents the possibility that a message from<br />

a particular source could “skip over” other messages from the same source by using a faster, parallel<br />

job to arrive at its destination sooner. This ensures first-in, first-out (FIFO) processing so that each<br />

message from a given source arrives at its configured destination in the same order in which it was<br />

sent.<br />

Proper message sequence is essential for many <strong>HL7</strong> applications. Suppose a patient enters a hospital<br />

and requires care. System A sends out an admit event, followed by a treatment order, but System B<br />

receives the order first. System B cannot process the order without an admit, so upon receiving the<br />

order, it produces an error. This may delay patient care or require the information system to execute<br />

complex logic to associate admit with the order after the admit finally arrives at System B. For this<br />

reason, it is generally the case that every configuration item in an <strong>HL7</strong> routing production should have<br />

its Pool Size setting configured to 1.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 17


2<br />

Elements of a Routing Production<br />

This chapter explains how to build each element of an <strong>HL7</strong> message routing production based on the<br />

starter production that you can create from the <strong>Ensemble</strong> Management Portal [<strong>Ensemble</strong>] > [Productions]<br />

page. Topics include:<br />

• Namespaces<br />

• Building the Production<br />

• <strong>HL7</strong> Business Services<br />

• <strong>HL7</strong> Message Schema Categories<br />

• <strong>HL7</strong> Routing Processes<br />

• <strong>HL7</strong> Sequence Manager<br />

• Routing Rule Sets for <strong>HL7</strong><br />

• DTL Data Transformations for <strong>HL7</strong><br />

• <strong>HL7</strong> Business Operations<br />

• Pager and Email Alerts<br />

• <strong>HL7</strong> Search Tables<br />

Note:<br />

If you are replacing an existing interface engine (such as eGate) with <strong>Ensemble</strong>, also see the<br />

chapter “Converting Interfaces to <strong>Ensemble</strong>.”<br />

The following figure illustrates the flow of an <strong>HL7</strong> <strong>Version</strong> 2 message through an <strong>Ensemble</strong> production.<br />

This figure expands the simple view of a single interface shown in the “Configuration Items” section<br />

of the previous chapter, by adding elements that are referenced by configuration items, but that are<br />

not themselves configuration items. These include routing rule sets, data transformations, virtual doc-<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 19


Elements of a Routing Production<br />

uments, and schema definitions. You will create these items when you follow the instructions in this<br />

chapter.<br />

<strong>HL7</strong> Routing Engine in <strong>Ensemble</strong> Terms<br />

An <strong>HL7</strong> <strong>Version</strong> 2 message flows through the elements of an <strong>Ensemble</strong> <strong>HL7</strong> routing production as<br />

follows:<br />

1. An <strong>HL7</strong> business service receives an incoming message from the specific source application<br />

whose messages it is configured to accept.<br />

20 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Namespaces<br />

2. The business service passes the message to a specific <strong>HL7</strong> routing process. This is an <strong>Ensemble</strong><br />

business process that prepares incoming messages from a <strong>HL7</strong> business service for delivery outside<br />

<strong>Ensemble</strong> via a specific <strong>HL7</strong> business operation.<br />

3. The routing process may validate the message against an expected <strong>HL7</strong> schema definition. This<br />

may be a standard <strong>HL7</strong> schema or a custom schema.<br />

(Not shown) If validation fails, the <strong>HL7</strong> routing process passes the message to its configured bad<br />

message handler. This is an <strong>HL7</strong> business operation that disposes of any incoming <strong>HL7</strong> messages<br />

that fail validation, usually by saving the messages to a file. It may also enter an error in the Even<br />

Log or alert an operator.<br />

4. The <strong>HL7</strong> routing process applies a routing rule set to the message. The routing rule set chooses<br />

one or more target business operations and applies any data transformations that may be needed<br />

to prepare the message for the target application.<br />

5. In the typical case, some data transformation is required to prepare the message for the target.<br />

The routing rule set may invoke transformations that are custom coded, but commonly transformations<br />

are constructed using the <strong>Ensemble</strong> Data Transformation Language (DTL). DTL can call<br />

out to utility functions or utility class methods for more complex calculations.<br />

6. When the outgoing message is ready, the routing process passes it to an <strong>HL7</strong> business operation.<br />

The business operation provides the address and framing information required to send <strong>HL7</strong> messages<br />

to the target application.<br />

(Not shown) By default, all <strong>HL7</strong> messages that pass through the production are retained in the<br />

<strong>Ensemble</strong> message warehouse for as long as wanted. While in the message warehouse, the contents<br />

of <strong>HL7</strong> messages are available for tracking and viewing using <strong>Ensemble</strong> Management Portal<br />

features such as the EDI / <strong>HL7</strong> Manager, Message Browser, and Visual Trace, or by issuing an<br />

SQL query. Old messages can be purged automatically or at an administrator’s discretion,<br />

depending on how you configure the production.<br />

2.1 Namespaces<br />

In <strong>InterSystems</strong> products, a namespace is a collection of data and programs in a virtual work space.<br />

<strong>Ensemble</strong> documentation frequently refers to something called an <strong>Ensemble</strong> namespace or an<br />

<strong>Ensemble</strong>-enabled namespace. This is a namespace that has the <strong>Ensemble</strong> classes loaded into it. Of<br />

the system-provided namespaces, only the following are <strong>Ensemble</strong>-enabled: ENSLIB, ENSEMBLE,<br />

and ENSDEMO. Once you have successfully installed <strong>Ensemble</strong>, any new namespace that you create<br />

is automatically <strong>Ensemble</strong>-enabled.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 21


Elements of a Routing Production<br />

Important:<br />

<strong>InterSystems</strong> recommends that you always create new namespaces in which to work,<br />

rather than placing data or custom code in any of these system-provided namespaces<br />

where it could be overwritten and lost.<br />

You can create a new namespace by using the System Management Portal [Home] > [Configuration] ><br />

[Namespaces] > [New Namespace] page.<br />

2.2 Building the Production<br />

You can construct a new <strong>HL7</strong> message routing production as follows:<br />

1. Start the <strong>Ensemble</strong> Management Portal.<br />

2. Choose your working namespace from the selection box at the top right of the [<strong>Ensemble</strong>] home<br />

page.<br />

3. From the main menu choose Productions. The [<strong>Ensemble</strong>] > [Productions] page displays.<br />

4. Click Create New Production. The [<strong>Ensemble</strong>] > [Productions] > [Production Wizard] page displays.<br />

5. Enter a Package Name, Production Name, and Description.<br />

6. Choose the <strong>HL7</strong> Messaging option.<br />

7. Click OK. The [<strong>Ensemble</strong>] > [Productions] > [Production Model] page displays the “starter elements”<br />

for <strong>HL7</strong> message routing productions.<br />

8. Click Configure Production. The [<strong>Ensemble</strong>] > [Productions] page displays the configuration diagram<br />

with the production name (Package Name.Production Name) and Description that you entered in<br />

previous steps. You may now begin to configure the production.<br />

The starter production has one interface, whose elements are:<br />

• <strong>HL7</strong>FileService — A disabled <strong>HL7</strong> file service with default settings<br />

• MsgRouter — An <strong>HL7</strong> routing process with an empty routing rule set<br />

• <strong>HL7</strong>FileOperation — A disabled <strong>HL7</strong> file operation with default settings<br />

In building an <strong>HL7</strong> routing production, you will create and configure many such interfaces. You can<br />

start by enabling these starter elements, copying them, renaming them, and modifying them to suit<br />

your needs. As you build an interface, it frequently happens that while configuring one item you must<br />

enter the name of another item that you have not yet created. A clear naming convention is essential<br />

to avoid confusion. For suggestions, see the “Naming Conventions” section in the chapter “Design<br />

Model for a Routing Production.”<br />

22 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Business Services<br />

Note:<br />

You can only use alphanumeric characters, periods (.) and underscores (_) in configuration<br />

names. Do not use underscores in the names of data transformations.<br />

In addition to interface elements, the starter production provides several elements that do not route<br />

<strong>HL7</strong> messages, but that provide supporting functionality for the production:<br />

• Bad Message Handler — A built-in destination for messages that fail validation.<br />

• Ens.Alert — A routing process with a routing rule set that you can configure to route alert messages<br />

to different email business operations depending on the source of the alert (that is, which element<br />

is in trouble) and various conditions (such as the time of day) to suit your corporate schedules and<br />

procedures.<br />

• PagerAlert and EmailAlert — Email business operations that can be configured to send a text<br />

message (such as an alert) to a pager or email address.<br />

The next several topics explain how to build a complete <strong>HL7</strong> message routing production beginning<br />

from this foundation.<br />

2.3 <strong>HL7</strong> Business Services<br />

An inbound adapter receives an incoming <strong>HL7</strong> message from a source outside <strong>Ensemble</strong>, and relays<br />

it to an <strong>HL7</strong> business service. The business service parses the message and provides all of the information<br />

necessary to route the message to a destination inside <strong>Ensemble</strong>.<br />

To build an <strong>HL7</strong> business service for use in an <strong>HL7</strong> message routing production, you must create it,<br />

configure it, and integrate it into the production. This topic explains each step.<br />

2.3.1 Creating an <strong>HL7</strong> Business Service<br />

For your <strong>HL7</strong> routing production to receive <strong>HL7</strong> messages from outside <strong>Ensemble</strong>, you must add an<br />

<strong>HL7</strong> business service to the production configuration. <strong>Ensemble</strong> provides built-in business services<br />

that accept messages from external sources over TCP, File, FTP, and HTTP connections. Generally,<br />

you will choose one of these built-in business services rather than write your own.<br />

For your convenience, in addition to the <strong>HL7</strong> business services, two simple business services are also<br />

built into <strong>Ensemble</strong>: EnsLib.File.PassthroughService and EnsLib.FTP.PassthroughService. You can<br />

choose either of these business services if you simply need to pass a file through the <strong>HL7</strong> routing<br />

production, and do not want to parse or format the file as <strong>HL7</strong>.<br />

Additionally, you might want your <strong>HL7</strong> routing production to receive data from outside <strong>Ensemble</strong><br />

that is not an <strong>HL7</strong> message. This can be accomplished by creating a business service class associated<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 23


Elements of a Routing Production<br />

with an inbound adapter for some specific technology, as described in Developing <strong>Ensemble</strong> Productions<br />

and in each of the <strong>Ensemble</strong> Adapter <strong>Guide</strong>s.<br />

To add a business service to an <strong>HL7</strong> routing production:<br />

1. Start the <strong>Ensemble</strong> Management Portal.<br />

2. Add an FTP, File, or TCP business service for <strong>HL7</strong> as follows:<br />

• Start the Business Service Wizard in one of the following ways:<br />

- On the [<strong>Ensemble</strong>] > [Productions] > [Production Model] page, click Add Business Service.<br />

- While viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, do one<br />

of the following:<br />

• Left-click on the diagram background. A row of buttons displays below the diagram.<br />

Click Add Service.<br />

• Right-click on the diagram to reveal the context menu. Choose Add, then Business<br />

Service.<br />

• Choose <strong>HL7</strong> Input.<br />

• Enter information in the following fields:<br />

- Choose TCP, File, or FTP to determine the host class. Each class already exists and requires<br />

no programming. Simply choose one.<br />

- Give the item a configuration Name.<br />

- Use the Target Name field to identify the routing process or business operation to which<br />

this business service will send the <strong>HL7</strong> messages that it receives.<br />

• Click OK to save your changes, Cancel to ignore them.<br />

3. Add other types of <strong>HL7</strong> business service as follows:<br />

• Start the Business Service Wizard in one of the following ways:<br />

- On the [<strong>Ensemble</strong>] > [Productions] > [Production Model] page, click Add Business Service.<br />

- While viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, do one<br />

of the following:<br />

• Left-click on the diagram background. A row of buttons displays below the diagram.<br />

Click Add Service.<br />

• Right-click on the diagram to reveal the context menu. Choose Add, then Business<br />

Service.<br />

24 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Business Services<br />

• Choose Other.<br />

• Enter information in the following fields:<br />

- Choose the host class. Each class already exists and requires no programming. Choices<br />

include:<br />

• EnsLib.File.PassthroughService<br />

• EnsLib.FTP.PassthroughService<br />

• EnsLib.<strong>HL7</strong>.Service.HTTPService<br />

• EnsLib.<strong>HL7</strong>.Service.TCPService<br />

• EnsLib.<strong>HL7</strong>.Service.HTTPAckInService<br />

• EnsLib.<strong>HL7</strong>.Service.TCPAckInService<br />

• Any other business service class in the namespace<br />

- Give the item a configuration Name. For suggestions, see the “Naming Conventions”<br />

section in the chapter “Design Model for a Routing Production.”<br />

• Click OK to save your changes, Cancel to ignore them.<br />

4. To add a business service of any type, by copying another business service:<br />

• Display the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page.<br />

• Select the business service in the diagram.<br />

• Click the Copy button. A dialog prompts you to enter a configuration name.<br />

• Enter a unique name and click OK. Your new business service appears in the diagram<br />

• When first created, the copy has the same host class and settings as the original; only the<br />

name is different. You must make the new copy different by configuring it.<br />

Note:<br />

The Copy button works only within the same production. You cannot copy a business<br />

service from one production to another.<br />

2.3.2 Configuring an <strong>HL7</strong> Business Service<br />

You can configure an <strong>HL7</strong> business service by clicking on it while viewing the configuration diagram<br />

on the [<strong>Ensemble</strong>] > [Productions] page. The following fields display below the diagram; you can edit<br />

these fields to configure the routing process.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 25


Elements of a Routing Production<br />

Note:<br />

To navigate to the configuration diagram from the [<strong>Ensemble</strong>] > [Productions] > [Production<br />

Model] page, where the previous topic ended, click Configure Production, then continue.<br />

You may configure an <strong>HL7</strong> business service by entering values in the following fields. When you are<br />

done editing, click Apply to save your changes, or Cancel to ignore them.<br />

• General Settings — This column of settings appears at left. These are settings that configure the<br />

<strong>HL7</strong> business service as a production item. The most important of these for <strong>HL7</strong> are as follows.<br />

For descriptions of the other General Settings, see the section “Business Service Settings” in<br />

“The Configuration Page” chapter of Managing <strong>Ensemble</strong> Productions.<br />

- PoolSize — The default PoolSize value of 1 ensure FIFO (First In, First Out) processing. In<br />

many cases, multiple patient demographic updates must be received in order. For example,<br />

many applications require receipt of an ADT Registration message before they can process<br />

an Order message, an Order message must be received before a Result message, and so on.<br />

- Category — This text label permits configuration items to be sorted in the configuration diagram.<br />

For example, you can assign the same Category name to all items in the same interface.<br />

You may enter multiple category names separated by commas. Space characters count (do<br />

not use them around the commas).<br />

• Specific Settings — This column of settings appears at right. The column is organized into settings<br />

that configure the <strong>HL7</strong> business service (at top) and settings that configure its associated adapter<br />

(at bottom). The specific settings will be different depending on which <strong>HL7</strong> business service you<br />

are configuring, and which adapter that business service is using. The following list describes<br />

how to configure the most important of these settings. For details about which class provides<br />

which settings, see the “<strong>HL7</strong> Business Service Classes” section in the chapter “Settings for a<br />

Routing Production.”<br />

The Specific Settings for an <strong>HL7</strong> business service are as follows:<br />

AckMode<br />

Helps to establish the format and conventions for issuing <strong>HL7</strong> acknowledgement messages<br />

in response to <strong>HL7</strong> messages received. For a list of codes to enter in this field, see the “<strong>HL7</strong><br />

Acknowledgement (ACK) Mode” section in the chapter “Settings for a Routing Production.”<br />

Ack Target Config Names<br />

(File and FTP only) Unlike TCP business services, File and FTP business services have no<br />

persistent connection on which to send <strong>HL7</strong> acknowledgement messages (ACK or NACK).<br />

For this reason, the default AckMode for File and FTP business services is Never, which is<br />

usually appropriate. However, when you do want to send ACKs from a File or FTP business<br />

service, use the Ack Target Config Names setting to identify an <strong>Ensemble</strong> routing process or<br />

business operation that will receive the ACK messages. For AckMode details, see the “<strong>HL7</strong><br />

Acknowledgement (ACK) Mode” section in the chapter “Settings for a Routing Production.”<br />

26 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Business Services<br />

Adapter Class<br />

AddNackERR<br />

Identifies the TCP, File, or FTP inbound adapter for <strong>HL7</strong>.<br />

If True, add ERR error code segment when generating NACK messages; otherwise do not<br />

embed internal error state information in NACK messages. For details and related settings,<br />

see the “<strong>HL7</strong> Acknowledgement (ACK) Mode” section in the chapter “Settings for a<br />

Routing Production.”<br />

Alert Grace Period<br />

Alert On Error<br />

Archive IO<br />

Business services can be configured with an Alert Grace Period during which errors relating<br />

to external connections do not trigger alerts, even if Alert On Error is True. The Alert Grace<br />

Period is allowed to elapse, giving the business service and the external source time to<br />

reestablish their connection. If the error condition still exists after the Alert Grace Period, the<br />

business service triggers an alert; otherwise no alert is triggered.<br />

Setting Alert Grace Period to 0 disables this feature for the business service.<br />

If True, the <strong>HL7</strong> business service automatically triggers an alert upon encountering an error.<br />

See the “ “Pager and Email Alerts” ” section in this chapter.<br />

If True, the adapter associated with this business service will log in the <strong>Ensemble</strong> I/O archive<br />

each input and output communication it shares with the external system. This is not related<br />

to the ArchivePath. See the section “Working with the I/O Archive” in the “What to Manage”<br />

chapter of Managing <strong>Ensemble</strong> Productions.<br />

Batch Handling<br />

How to treat received message batches. The options are:<br />

• Whole Batch — Do not process message documents individually; accumulate and<br />

send the whole batch as one composite document.<br />

• Single-Session Batch — Forward all messages in the batch together in one session;<br />

the session includes objects representing the batch header and trailer segments. This is<br />

the default.<br />

• Multi-Session Batch — Forward each message in the batch in its own session;<br />

each session includes objects representing the batch header and trailer segments.<br />

• Individual — Forward each child message in the batch in its own session; do not<br />

forward objects representing the batch header and trailer segments.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 27


Elements of a Routing Production<br />

For more about batch handling, see the “<strong>HL7</strong> Batch Messages” section in the chapter<br />

“Settings for a Routing Production.”<br />

DefCharEncoding<br />

Framing<br />

The default character encoding to use when reading or writing <strong>HL7</strong> messages. If any incoming<br />

<strong>HL7</strong> message has an empty MSH:18 (Character Set) field, <strong>Ensemble</strong> uses the DefCharEncoding<br />

value in its place. Supported values are UTF-8 or any member of the Latinn family. The<br />

value Native means to use the native default encoding installed on the <strong>Ensemble</strong> server.<br />

The default value for DefCharEncoding is Latin1.<br />

Placing a ! (exclamation point) character at the beginning of this field forces <strong>Ensemble</strong> to<br />

use the DefCharEncoding value and ignore any value found in MSH:18. For example: !UTF-8<br />

Placing a @ (at sign) character at the beginning of this field means that the field identifies an<br />

internal NLS Translation Table instead of a logical character encoding.<br />

Controls how the <strong>HL7</strong> business service interprets the incoming <strong>HL7</strong> message packet. For a<br />

list of framing options, see the “<strong>HL7</strong> Message Framing Types” section in the chapter “Settings<br />

for a Routing Production.” If you are unsure what value to use, accept the default of<br />

Flexible framing for <strong>HL7</strong> business services.<br />

IgnoreInboundAck<br />

If True, the business service ignores any inbound ACK messages to avoid creating an ACK<br />

feedback loop. For details and related settings, see the “ “<strong>HL7</strong> Acknowledgement (ACK)<br />

Mode” ” section in the chapter “Settings for a Routing Production.”<br />

ImmediateByteAck<br />

(TCPAckIn and HTTPAckIn only) If this value is set to True, then in addition to forwarding a<br />

full ACK message according to the AckMode setting, the business service also returns an<br />

immediate 1–byte ACK on its TCP connection. For details, see the “Dual Acknowledgement<br />

Sequences” section in the chapter “Settings for a Routing Production.”<br />

Local Facility Application<br />

Colon-separated LocalFacility:LocalApplication code that represents the facility and application<br />

that receive <strong>HL7</strong> messages via this business service. If this business service constructs<br />

its own ACK, Local Facility Application provides the SendingFacility:SendingApplication<br />

codes for the ACK message; otherwise, this setting is ignored.<br />

Message Schema Category<br />

The name of one of the following items:<br />

28 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Business Services<br />

• A standard <strong>HL7</strong> schema: 2.1, 2.2, 2.3, 2.3.1, 2.4, or 2.5.<br />

• A custom <strong>HL7</strong> schema<br />

For example, if your custom schema definition looks like this:<br />

<br />

Then in the Message Schema Category field, enter the value:<br />

myCustomCategory<br />

If you have not yet prepared a custom schema definition for the <strong>HL7</strong> business service, you<br />

may leave this field blank for now. However, do not leave it blank permanently unless you<br />

also disable validation for the routing process, or validation errors will automatically occur.<br />

See the “Message Validation and Bad Messages” section in the chapter “Settings for a<br />

Routing Production.”<br />

PartnerOperation<br />

(TCPAckIn and HTTPAckIn only) The EnsLib.<strong>HL7</strong>.Service.TCPAckInService is a specialized<br />

<strong>HL7</strong> TCP business service that receives ACKs on behalf of a paired <strong>HL7</strong> TCP business<br />

operation. This enables the dual ACK sequence required by some client applications. There<br />

is also an EnsLib.<strong>HL7</strong>.Service.HTTPAckInService. For details, see the “Dual Acknowledgement<br />

Sequences” section in the chapter “Settings for a Routing Production.”<br />

When TCPAckIn or HTTPAckIn is the business service class, PartnerOperation identifies the<br />

paired business operation. The business operation must exist and have the underlying class<br />

EnsLib.<strong>HL7</strong>.Operation.TCPAckOutOperation or EnsLib.<strong>HL7</strong>.Operation.HTTPAckOutOperation,<br />

respectively.<br />

Search Table Class<br />

The package and class name of a search table class that you have defined in this <strong>Ensemble</strong><br />

namespace. A search table class is a specialized tool that you can create to work with virtual<br />

documents, such as <strong>HL7</strong> messages. A virtual document is efficient because it contains a large<br />

amount of raw data but no instantiated properties. Creating a search table enables <strong>Ensemble</strong><br />

to efficiently index a few of the fields in a virtual document so that these fields are available<br />

to be searched as if they were properties in a standard message body.<br />

To create a search table class, see the “<strong>HL7</strong> Search Tables” section in this chapter. For<br />

conceptual information, see the book <strong>Ensemble</strong> Virtual Documents.<br />

Target Config Names<br />

The configured name of one or more of the following items:<br />

• An <strong>HL7</strong> routing process (for a routing interface)<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 29


Elements of a Routing Production<br />

• An <strong>HL7</strong> business operation (if your design bypasses a routing process for this interface<br />

and simply relays messages from the incoming business service to the outgoing business<br />

operation)<br />

Use Ack Commit Codes<br />

True or False. If True, when constructing an ACK message for <strong>HL7</strong> messages version 2.3 or<br />

higher, the business service places one of the “enhanced-mode” ACK commit codes in the<br />

MSA segment AcknowledgmentCode field. For a list of codes, see “The UseAckCommitCodes<br />

Setting” in the chapter “Settings for a Routing Production.”<br />

The remaining entries in the Specific Settings column are determined by the type of adapter: FTP, File,<br />

TCP, or HTTP. The following adapter settings are especially important for <strong>HL7</strong> business services:<br />

AppendTimestamp<br />

ArchivePath<br />

CallInterval<br />

(File only) If True, the <strong>HL7</strong> business service automatically appends a time stamp to filenames<br />

in the ArchivePath. The format for this time stamp is %f_%Q where:<br />

• %f is the name of the data source, in this case the input filename<br />

• _ is the literal underscore character, which will appear in the output filename<br />

• %Q indicates ODBC format date and time<br />

In substituting a value for the format code %f, <strong>Ensemble</strong> strips out any of the characters<br />

|,,\,/,:,[,],,&,,,;,NUL,BEL,TAB,CR,LF, replacing spaces with underscores (_) and slashes<br />

(/) with hyphens (-). When the output file is being saved on an OpenVMS system, <strong>Ensemble</strong><br />

replaces colons with hyphens (-). Otherwise, colons (:) become dots (.).<br />

(File and FTP only) If this field is not empty, <strong>Ensemble</strong> creates a copy of each <strong>HL7</strong> message<br />

received via this business service and saves it as a file in the specified ArchivePath. The<br />

archived filename is the same as the input filename.<br />

The number of seconds to wait before looking for more input.<br />

For further information about any setting, hovering the cursor over the setting name, or consult these<br />

references:<br />

• “Adapter Settings” in the “FTP Inbound Adapter” chapter of Using FTP Adapters with <strong>Ensemble</strong><br />

• “Adapter Settings” in the “File Inbound Adapter” chapter of Using File Adapters with <strong>Ensemble</strong><br />

• “Adapter Settings” in the “TCP Inbound Adapter” chapter of Using TCP Adapters with<br />

<strong>Ensemble</strong>, which describes the settings for the general-purpose TCP inbound adapter. The difference<br />

30 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Custom Schema Categories<br />

for the special-purpose adapter called EnsLib.<strong>HL7</strong>.Adapter.TCPInboundAdapter is that it has<br />

JobPerConnection set to False, which is usually appropriate for <strong>HL7</strong>.<br />

• The “Using the HTTP Inbound Adapter” chapter in Using HTTP Adapters with <strong>Ensemble</strong><br />

2.3.3 Integrating an <strong>HL7</strong> Business Service<br />

To integrate a new <strong>HL7</strong> business service into an <strong>Ensemble</strong> production, you must associate it with the<br />

routing process or business operation to which it relays messages. Additionally, if you expect the<br />

business service to receive non-standard message structures you will need to create a custom <strong>HL7</strong><br />

schema definition to parse and validate these messages. To do this:<br />

1. Complete the instructions for creating any TargetConfigNames or Message Schema Category items<br />

that your <strong>HL7</strong> business service needs. The items might be:<br />

• An <strong>HL7</strong> routing process (for a routing interface)<br />

• An <strong>HL7</strong> business operation (if your design bypasses a routing process for this interface and<br />

simply relays messages from the incoming business service to the outgoing business operation)<br />

• A custom <strong>HL7</strong> schema definition, to parse the incoming <strong>HL7</strong> messages<br />

The next several topics provide instructions for creating these items.<br />

2. Return to the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page. Select the new <strong>HL7</strong><br />

business service. If the TargetConfigNames and Message Schema Category fields were previously<br />

blank, configure them now, and Apply your changes.<br />

2.4 <strong>HL7</strong> Custom Schema Categories<br />

The <strong>HL7</strong> standard is easily extensible, and many of the clinical applications that produce and consume<br />

<strong>HL7</strong> data take advantage of this feature. The common practice in customizing <strong>HL7</strong> is to add custom<br />

segments to an otherwise standard <strong>HL7</strong> message structure. By convention, the custom segments have<br />

names that begin with the letter Z (ZEK, ZPM, etc.), so custom segments are called Z-segments. A<br />

custom message structure often consists of a standard message with a few Z-segments added to it.<br />

If a clinical application uses no non-standard messages, there is no need to create a custom schema.<br />

However, this is rarely the case. For non-standard message structures, a custom schema is needed in<br />

order for <strong>Ensemble</strong> to be able to:<br />

• Perform structural message validation<br />

• Use segment and field path names in BPL, DTL, and routing rule syntax.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 31


Elements of a Routing Production<br />

<strong>Ensemble</strong> provides a built-in schema category definition for each published version of the <strong>HL7</strong> standard.<br />

These <strong>HL7</strong> category definitions can be viewed and edited in XML format by opening the corresponding<br />

.<strong>HL7</strong> file in <strong>Ensemble</strong> Studio. Each .<strong>HL7</strong> file consists of a set of XML statements which define the<br />

<strong>HL7</strong> messages.<br />

To create your own custom schema category, simply create a new .<strong>HL7</strong> file and add XML statements<br />

to it. You can do this by creating a new file or copying an existing file, as follows:<br />

1. Start <strong>Ensemble</strong> Studio and change to an <strong>Ensemble</strong>-enabled user namespace.<br />

Important:<br />

<strong>InterSystems</strong> recommends that you do not place custom code or data in the systemprovided<br />

namespaces ENSLIB or ENSDEMO where it will be deleted the next<br />

time you upgrade <strong>Ensemble</strong>. The ENSEMBLE namespace and any new namespace<br />

that you create to hold your work is preserved across <strong>Ensemble</strong> upgrades.<br />

2. From the File menu, choose New.<br />

3. The New dialog displays. Select the Custom tab.<br />

4. Select the <strong>HL7</strong> Schema icon and click OK.<br />

5. Enter a New Schema Name. This is the name of the new schema. When you save the<br />

schema definition, it becomes the name of the new *.<strong>HL7</strong> file.<br />

6. Enter a Base Schema Name. Specify the name of the schema base. Use one of the<br />

built–in categories: 2.1, 2.2, 2.3, 2.3.1, 2.4, or 2.5.<br />

7. Click OK.<br />

If you have already created a custom schema category that matches your requirements closely, you<br />

might prefer to copy and edit this custom schema instead of creating a new custom schema. Use the<br />

following steps:<br />

1. Open any existing custom schema category file as follows:<br />

• Start Studio.<br />

• Select File Open.<br />

• For the Look in field choose an <strong>Ensemble</strong>-enabled user namespace.<br />

• In the Files of type field select All files.<br />

• In the File name field enter the extension *.hl7 or *.<strong>HL7</strong>. The names of several schema<br />

category files appear.<br />

• Select an existing custom schema category file as the model for your new file. Do not select<br />

any of the built–in schema category files (2.1.<strong>HL7</strong>, 2.2.<strong>HL7</strong>, 2.3.<strong>HL7</strong>, 2.3.1.<strong>HL7</strong>,<br />

2.4.<strong>HL7</strong>, or 2.5.<strong>HL7</strong>). If there are no custom schema category files to choose from, create<br />

a new file as described in the previous procedure.<br />

32 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Custom Schema Categories<br />

• Click Open.<br />

2. From the File menu, choose Save As. Enter a new filename with the *.<strong>HL7</strong> extension. For<br />

example:<br />

myCustomCategory.<strong>HL7</strong><br />

3. Edit the name and base attributes for :<br />

• For name specify the new *.<strong>HL7</strong> filename.<br />

• For base specify the name of the schema base. Use one of the built–in categories:<br />

2.1, 2.2, 2.3, 2.3.1, 2.4, or 2.5.<br />

For example:<br />

<br />

You are now ready to edit your new file to add and remove XML statements from the <br />

block. You may open and study existing .<strong>HL7</strong> schema files using <strong>Ensemble</strong> Studio. The editing steps<br />

for the new .<strong>HL7</strong> schema file are as follows:<br />

1. Define Z-segments using elements.<br />

2. Define custom elements that contain the Z-segments.<br />

3. Define custom elements that contain the custom message structures.<br />

4. Remove any unneeded XML statements that remain from examples you have copied.<br />

5. From the File menu, choose Save. This action both saves and compiles the new category definition.<br />

6. Try viewing the new category definition from the <strong>Ensemble</strong> Management Portal. Select EDI / <strong>HL7</strong><br />

Manager and then Schema Structures. You should see your new custom category listed along with<br />

the standard categories.<br />

7. You can use the new custom schema definition in an <strong>HL7</strong> routing production as follows:<br />

• When creating a DTL data transformation, identify the custom schema category as the<br />

sourceDocType or targetDocType<br />

• When configuring an <strong>HL7</strong> business service, identify the custom schema category as the<br />

Message Schema Category<br />

For a formal syntax guide to the XML used in schema category definitions, see the “Schema Category<br />

Syntax” section in the chapter “Settings for a Routing Production.”<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 33


Elements of a Routing Production<br />

2.5 <strong>HL7</strong> Routing Processes<br />

To build an <strong>HL7</strong> routing process for use in an <strong>HL7</strong> message routing production, you must create it,<br />

configure it, and integrate it into the production. This topic explains each step.<br />

2.5.1 Creating an <strong>HL7</strong> Routing Process<br />

To create an <strong>HL7</strong> routing process:<br />

1. Start the <strong>Ensemble</strong> Management Portal.<br />

2. If the production already contains a similar <strong>HL7</strong> routing process, you may copy it using the following<br />

sequence of steps:<br />

• Display the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page.<br />

• Select the routing process in the diagram.<br />

• Click the Copy button. A dialog prompts you to enter a configuration name.<br />

• Enter a unique name and click OK. Your new routing process appears in the diagram<br />

• When first created, the copy has the same host class and settings as the original; only the<br />

name is different. Your next step is to configure the copy.<br />

Note:<br />

The Copy button works only within the same production. You cannot copy a routing<br />

process from one production to another.<br />

3. To create an entirely new <strong>HL7</strong> routing process, without copying, use the following sequence of<br />

steps:<br />

• Start the Business Process Wizard in one of the following ways:<br />

- On the [<strong>Ensemble</strong>] > [Productions] > [Production Model] page, click Add Business Process.<br />

- While viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, do one<br />

of the following:<br />

• Left-click on the diagram background. A row of buttons displays below the diagram.<br />

Click Add Process.<br />

• Right-click on the diagram to reveal the context menu. Choose Add, then Business<br />

Process.<br />

• Choose <strong>HL7</strong> Message Router. The following fields display:<br />

- Accept the default Router Class of EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine.<br />

34 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


- Give the routing process a configuration Name. Use a simple name that contains no dot<br />

(.) separators or space characters.<br />

- The Routing Rule Name field identifies the routing rule set that the routing process will<br />

execute to decide where to send the messages that it receives.<br />

• Click OK to save your changes, Cancel to ignore them.<br />

<strong>HL7</strong> Routing Processes<br />

2.5.2 Configuring an <strong>HL7</strong> Routing Process<br />

You can configure an <strong>HL7</strong> routing process of the class EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine by<br />

clicking on it while viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page. The<br />

following fields display below the diagram; you can edit these fields to configure the routing process.<br />

Note:<br />

To navigate to the configuration diagram from the [<strong>Ensemble</strong>] > [Productions] > [Production<br />

Model] page, where the previous topic ended, click Configure Production, then continue.<br />

You may configure an <strong>HL7</strong> routing process by entering values in the following fields. When you are<br />

done editing, click Apply to save your changes, or Cancel to ignore them.<br />

AckType<br />

AddNackERR<br />

Determines the ACK type (that is, AA or CA) if constructing an ACK or NACK reply message<br />

locally. A is the default code. For further details, see the “<strong>HL7</strong> Acknowledgement (ACK)<br />

Mode” section in the chapter “Settings for a Routing Production.”<br />

True or False. If True, add an ERR error code segment when generating NACK messages. If<br />

False, do not embed internal error state information in NACK messages.<br />

Alert On Bad Message<br />

If True, any message that fails validation automatically triggers an alert.<br />

Bad Message Handler<br />

Identifies the <strong>HL7</strong> business operation that disposes of any incoming <strong>HL7</strong> messages that fail<br />

validation.<br />

Business Rule Name<br />

The full name of the routing rule set for this routing process. If you generated the routing<br />

process using the Business Process Wizard, use the default value provided by the wizard.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 35


Elements of a Routing Production<br />

ForceSyncSend<br />

If True, make synchronous calls for all “send” actions from this routing process. If False,<br />

allow these calls to be made asynchronously. The ForceSyncSend setting is intended to ensure<br />

FIFO ordering in the following case: This routing process and its target business operations<br />

all have Pool Size set to 1, and ancillary business operations might be called asynchronously<br />

from within a data transformation or business operation called from this routing process.<br />

If ForceSyncSend is True, this can cause deadlock if another business process is called by a<br />

target that is called synchronously from this routing process.<br />

Note that if there are multiple “send” targets, ForceSyncSend means these targets will be<br />

called one after another in serial fashion, with the next being called after the previous call<br />

completes. Also note that synchronous calls are not subject to the Response Timeout setting.<br />

Local Facility Application<br />

NackCode<br />

Colon-separated LocalFacility:LocalApplication code that represents the facility and application<br />

that receive <strong>HL7</strong> messages via this routing process. If this routing process constructs<br />

its own ACK or NACK messages, Local Facility Application provides the<br />

SendingFacility:SendingApplication codes for the messages; otherwise, this setting is ignored.<br />

Determines the NACK code type (that is, AE or AR) if constructing a NACK reply message<br />

locally to report an error. E is the default code. For further details, see the “<strong>HL7</strong> Acknowledgement<br />

(ACK) Mode” section in the chapter “Settings for a Routing Production.”<br />

Response From<br />

A comma-separated list of configured items within the production. This list identifies the<br />

targets from which a response may be forwarded back to the original caller, if the caller<br />

requested a response.<br />

If a Response From string is specified, the response returned to the caller is the first response<br />

that arrives back from any target in the list, and if there are no responses, an empty “OK”<br />

response header is returned. If the Response From value is empty, nothing is returned.<br />

The Response From string allows special characters as follows:<br />

• The * character by itself matches any target in the production, so the first response from<br />

any target is returned. If there are no responses, an empty “OK” response header is<br />

returned.<br />

• If the list of targets begins with a + character, the responses from all targets return together,<br />

as a list of message header IDs in the response header. If none of the targets responds,<br />

an empty “OK” response header is returned.<br />

36 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Routing Processes<br />

• If the list of targets begins with a - character, only error responses will be returned, as<br />

a list of message header IDs in the response header. If none of the targets responds with<br />

an error, an empty “OK” response header is returned.<br />

Response Target Config Names<br />

A comma-separated list of configured items within the production. If specified, this list<br />

identifies the destinations, in addition to the caller, to which responses will be forwarded. If<br />

empty, responses are only returned to the caller. This setting takes effect only if the Response<br />

From field has a value.<br />

Response Timeout<br />

Validation<br />

Maximum length of time to wait for asynchronous responses before returning a “timed-out<br />

error” response header. A value of -1 means to wait forever. Note that a value of 0 is not<br />

useful, because every response would time out. This setting takes effect only if the Response<br />

From field has a value.<br />

If blank, the routing process skips validation and simply routes messages. For details about<br />

validation conventions when this field contains a value, see the “Message Validation and<br />

Bad Messages” section in the chapter “Settings for a Routing Production.”<br />

An <strong>HL7</strong> routing process has other configurable settings that apply to all business hosts. Documentation<br />

for these common settings is available in the section “Business Process Settings” in “The Configuration<br />

Page” chapter of Managing <strong>Ensemble</strong> Productions.<br />

2.5.3 Integrating an <strong>HL7</strong> Routing Process<br />

To integrate a new <strong>HL7</strong> routing process into an <strong>Ensemble</strong> production, you must associate it with the<br />

business service that receives its incoming messages, and with the routing rule set that determines its<br />

actions based on those messages. To do this:<br />

1. Select the <strong>HL7</strong> business service. In the TargetConfigNames field enter the name of the new <strong>HL7</strong><br />

routing process.<br />

2. Create a routing rule set for the routing process. Select the routing process in the configuration<br />

diagram. In the BusinessRuleName field enter the full name of the new routing rule set.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 37


Elements of a Routing Production<br />

2.6 <strong>HL7</strong> Sequence Manager<br />

An <strong>HL7</strong> sequence manager is a business process that accepts incoming <strong>HL7</strong> messages from multiple<br />

sources, then forwards the messages to a target configuration item in the order specified by the MSH:13<br />

SequenceNumbers field in the messages.<br />

The sequence manager has the ability to detect duplicate messages and timing gaps between messages.<br />

It also determines when the timing gaps between sequential messages are sufficiently large to indicate<br />

a problem. Its level of sensitivity can be adjusted using its configuration settings.<br />

To build an <strong>HL7</strong> sequence manager for use in an <strong>HL7</strong> message routing production, you must create<br />

it, configure it, and integrate it into the production. This topic explains each step.<br />

2.6.1 Creating an <strong>HL7</strong> Sequence Manager<br />

To create an <strong>HL7</strong> sequence manager:<br />

1. Start the <strong>Ensemble</strong> Management Portal.<br />

2. If the production already contains a similar <strong>HL7</strong> sequence manager, you may copy it using the<br />

following sequence of steps:<br />

• Display the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page.<br />

• Select the sequence manager in the diagram.<br />

• Click the Copy button. A dialog prompts you to enter a configuration name.<br />

• Enter a unique name and click OK. Your new sequence manager appears in the diagram<br />

• When first created, the copy has the same host class and settings as the original; only the<br />

name is different. Your next step is to configure the copy.<br />

Note:<br />

The Copy button works only within the same production. You cannot copy a sequence<br />

manager from one production to another.<br />

3. To create an entirely new <strong>HL7</strong> sequence manager, without copying, use the following sequence<br />

of steps:<br />

• Start the Business Process Wizard in one of the following ways:<br />

- On the [<strong>Ensemble</strong>] > [Productions] > [Production Model] page, click Add Business Process.<br />

- While viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, do one<br />

of the following:<br />

• Left-click on the diagram background. A row of buttons displays below the diagram.<br />

Click Add Process.<br />

38 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Sequence Manager<br />

• Right-click on the diagram to reveal the context menu. Choose Add, then Business<br />

Process.<br />

• Choose Other.<br />

• Enter information in the following fields:<br />

- For the ProcessClass choose EnsLib.<strong>HL7</strong>.SequenceManager.<br />

- Give the item a configuration Name. For suggestions, see the “Naming Conventions”<br />

section in the chapter “Design Model for a Routing Production.”<br />

• Click OK to save your changes, Cancel to ignore them.<br />

2.6.2 Configuring an <strong>HL7</strong> Sequence Manager<br />

A sequence manager is a business process of the class EnsLib.<strong>HL7</strong>.SequenceManager. You can configure<br />

a sequence manager by clicking on it while viewing the configuration diagram on the [<strong>Ensemble</strong>] ><br />

[Productions] page. The following fields display below the diagram; you can edit these fields to configure<br />

the sequence manager.<br />

Note:<br />

To navigate to the configuration diagram from the [<strong>Ensemble</strong>] > [Productions] > [Production<br />

Model] page, where the previous topic ended, click Configure Production, then continue.<br />

You may configure an <strong>HL7</strong> sequence manager by entering values in the following fields. When you<br />

are done editing, click Apply to save your changes, or Cancel to ignore them.<br />

AlertOnError<br />

If True, the <strong>HL7</strong> sequence manager automatically triggers an alert upon encountering errors<br />

trying to connect with its external target. The default is False.<br />

DuplicatedMessageTarget<br />

The configured Name of an item within the production, usually a business operation. If<br />

specified, this is where the sequence manager sends any duplicate messages that it receives.<br />

EnableDuplicatedMessageCheck<br />

If True, the sequence manager checks to see if any incoming messages are duplicates of a<br />

previously received message. It does this by checking the following three fields in the MSH<br />

segment of each message:<br />

• MSH:3 SendingApplication<br />

• MSH:4 SendingFacility<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 39


Elements of a Routing Production<br />

LargeGapSize<br />

• MSH:10 MessageControlId<br />

A sequence manager can check for duplicate messages and messages out of sequence,<br />

duplicate messages or messages out of sequence, or neither. This makes EnableDuplicatedMessageCheck<br />

entirely independent of PerformSequenceNumberCheckOn in that either, one, or<br />

both of these settings may be True.<br />

A number that indicates a significant gap in the sequence of messages.<br />

A late message is a message that arrives with a sequence number larger than the previously<br />

received message in the sequence, but not exactly sequential. For example, when message<br />

102 arrives after message 101, 102 is not late; it is the next message in sequence. However,<br />

when message 110 arrives after message 101, 110 is a late message.<br />

When there is a late message, and the sequence numbering gap between the preceding and<br />

subsequent messages is less than the configured LargeGapSize, this is a small gap. A gap<br />

larger than this is a large gap.<br />

• For any small gap, the sequence manager waits for MessageWaitTimeout seconds to see<br />

if messages will arrive to fill the gap. If the messages arrives within the waiting period,<br />

the sequence manager aligns them in their proper sequence. If they do not arrive and the<br />

MessageWaitTimeout expires, the sequence manager stops waiting and sends whatever<br />

it has for messages in the current sequence.<br />

• When there is a large gap, the sequence manager does not wait for any period of time.<br />

It immediately sends an alert, then sends whatever it has for messages in the current<br />

sequence.<br />

The default LargeGapSize is 100.<br />

MessageResendableTimeWindow<br />

Time window during which the sequence manager considers a duplicate message to be a<br />

duplicate. The reason for the MessageResendableTimeWindow is that sometimes a duplicate<br />

message is not a mistake. Sometimes it is the result of deliberately resending a message<br />

sequence.<br />

Suppose a message arrives and the sequence manager detects that it is a duplicate of a previously<br />

received message. In this case:<br />

• If it has been more than MessageResendableTimeWindow seconds since the sequence<br />

manager first saw this message, it interprets the new arrival as a deliberately resent copy.<br />

The sequence manager begins tracking the messages in this resent sequence independently<br />

from its tracking of the main sequence of messages.<br />

40 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Suppose the sequence manager is processing a sequence that includes numbers such as<br />

1001, 1002, 1003, and 1004, but at the same time it begins receiving messages with the<br />

sequence numbers 1, 2, and 3. If the older messages with smaller sequence numbers were<br />

first received more than MessageResendableTimeWindow seconds ago, the sequence<br />

manager interprets them as messages in a resent sequence, rather than as messages out<br />

of sequence. It begins tracking the main sequence and the resent sequence simultaneously.<br />

While doing so, it keeps the two sequences separate, appropriately ignoring gaps between<br />

unrelated sequence numbers such as 2 and 1001.<br />

• If it has been less than MessageResendableTimeWindow seconds since the sequence<br />

manager first saw this message, the new arrival is understood to be a true duplicate, and<br />

the sequence manager handles it appropriately. See EnableDuplicatedMessageCheck.<br />

The default MessageResendableTimeWindow is 300 seconds (5 minutes).<br />

MessageWaitTimeout<br />

For definitions of large gaps, small gaps, and late messages, see the LargeGapSize setting.<br />

For any small gap, the sequence manager waits for MessageWaitTimeout seconds to see if<br />

messages will arrive to fill the gap between the preceding message and the late message. If<br />

they do not arrive and the MessageWaitTimeout expires, the sequence manager stops waiting<br />

and sends whatever it has for messages in the current sequence.<br />

The default MessageWaitTimeout is 60.<br />

OutOfSequenceMessageTarget<br />

The configured Name of an item within the production, usually a business operation. If<br />

specified, this is where the sequence manager will send any out-of-sequence messages that<br />

it receives.<br />

OutputFacilityApplication<br />

Specifies the facility and application to be used in the message transformation when PerformOutputTransformationOn<br />

is set to Sender or Receiver.<br />

The format for the OutputFacilityApplication value is:<br />

Facility:Application<br />

OutputTargetConfigNames<br />

<strong>HL7</strong> Sequence Manager<br />

A comma-separated list of configured items within the production. If specified, this list<br />

identifies the destinations to which the sequence manager will send any message that passes<br />

its tests.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 41


Elements of a Routing Production<br />

PassThroughMessageTypes<br />

A comma-separated list of message types that are exempt from duplicate checks, sequence<br />

checks, or output transformations. The sequence manager always passes these messages<br />

through unchanged. The default list is:<br />

QBP_Q21,QBP_Q22,RSP_K21,RSP_K22,ACK<br />

PerformOutputTransformationOn<br />

Fields for the sequence manager to transform before sending out a message. The output<br />

transformation provides new facility, application, and sequence number fields as described<br />

in the following list, then sends the message to its configured targets. Possible values for<br />

PerformOutputTransformationOn are:<br />

• Sender — This is the default. The sequence manager copies Facility and Application<br />

from the OutputFacilityApplication setting and assigns a new sequence number. The result<br />

is that the following fields are changed in the outgoing message:<br />

- MSH:3 SendingApplication<br />

- MSH:4 SendingFacility<br />

- MSH:13 SequenceNumber<br />

• Receiver — The sequence manager copies Facility and Application from the Output-<br />

FacilityApplication setting and assigns a new sequence number. The result is that the<br />

following fields are changed in the outgoing message:<br />

- MSH:5 ReceivingApplication<br />

- MSH:6 ReceivingFacility<br />

- MSH:13 SequenceNumber<br />

• None — The sequence manager does not perform any transformation before sending the<br />

message.<br />

PerformSequenceNumberCheckOn<br />

Fields for the sequence manager to check to see if any of the incoming messages are out of<br />

sequence. If so, the sequence manager resequences the messages and sends them to its configured<br />

targets.<br />

Possible values for PerformSequenceNumberCheckOn are:<br />

• Sender — This is the default. The sequence manager checks:<br />

- MSH:3 SendingApplication<br />

- MSH:4 SendingFacility<br />

42 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Sequence Manager<br />

- MSH:13 SequenceNumber<br />

• SendingFacility — The sequence manager checks:<br />

- MSH:4 SendingFacility<br />

- MSH:13 SequenceNumber<br />

• SendingApplication — The sequence manager checks:<br />

- MSH:3 SendingApplication<br />

- MSH:13 SequenceNumber<br />

• Receiver — The sequence manager checks:<br />

- MSH:5 ReceivingApplication<br />

- MSH:6 ReceivingFacility<br />

- MSH:13 SequenceNumber<br />

• ReceivingFacility — The sequence manager checks:<br />

- MSH:6 ReceivingFacility<br />

- MSH:13 SequenceNumber<br />

• ReceivingApplication — The sequence manager checks:<br />

- MSH:5 ReceivingApplication<br />

- MSH:13 SequenceNumber<br />

• None — The sequence manager does not check for messages out of sequence.<br />

A sequence manager can check for duplicate messages and messages out of sequence,<br />

duplicate messages or messages out of sequence, or neither. This makes EnableDuplicatedMessageCheck<br />

entirely independent of PerformSequenceNumberCheckOn in that either, one, or<br />

both of these settings may be True.<br />

An <strong>HL7</strong> sequence manager has other configurable settings that apply to all business hosts. Documentation<br />

for these common settings is available in the section “Business Process Settings” in “The<br />

Configuration Page” chapter of Managing <strong>Ensemble</strong> Productions.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 43


Elements of a Routing Production<br />

2.6.3 Integrating an <strong>HL7</strong> Sequence Manager<br />

To integrate a new <strong>HL7</strong> sequence manager into an <strong>Ensemble</strong> production, you must associate it with<br />

the business service that receives its incoming messages, and with the target destination for the messages<br />

that it sends, once it has sorted out their proper sequence. To do this:<br />

1. Select the <strong>HL7</strong> business service. In the TargetConfigNames field enter the name of the new <strong>HL7</strong><br />

sequence manager.<br />

2. Return to configuring the <strong>HL7</strong> sequence manager. Provide it with a list of OutputTargetConfigNames<br />

for successful messages.<br />

3. If you want the sequence manager to check for duplicate messages, set EnableDuplicatedMessageCheck<br />

to True.<br />

If you want to save the duplicate messages for troubleshooting purposes, create a <strong>HL7</strong> business<br />

operation to receive them. In the DuplicatedMessageTarget field enter the name of the new <strong>HL7</strong><br />

business operation.<br />

4. If you want the sequence manager to check for out-of-sequence messages, set PerformSequenceNumberCheckOn<br />

to Sender or Receiver and configure the details of sequence checking by<br />

setting values for LargeGapSize and MessageWaitTimeout. Otherwise, set PerformSequenceNumberCheckOn<br />

to None.<br />

If you want to save the out-of-sequence messages for troubleshooting purposes, create a <strong>HL7</strong><br />

business operation to receive them. In the OutOfSequenceMessageTarget field enter the name of<br />

the new <strong>HL7</strong> business operation.<br />

5. If you want the sequence manager to transform messages before sending them outside <strong>Ensemble</strong>,<br />

set PerformOutputTransformationOn to Sender or Receiver and set a value for the OutputFacilityApplication.<br />

Otherwise, set PerformOutputTransformationOn to None.<br />

6. Identify any PassThroughMessageTypes that the sequence manager should simply send to the<br />

OutputTargetConfigNames without checking or transforming them.<br />

2.7 Routing Rule Sets for <strong>HL7</strong><br />

When creating a routing rule set for an <strong>HL7</strong> interface, your goal is to tell <strong>Ensemble</strong> what to do with<br />

the source message based on the segments found within it. Sometimes it matters which segments are<br />

found; sometimes it matters which values are found within those segments.<br />

In ordinary rule sets, each Action returns a value to the business process that invoked the rule set. In<br />

a routing rule set, an Action usually directs an <strong>HL7</strong> message to a destination, possibly transforming<br />

the <strong>HL7</strong> message before sending it.<br />

44 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The following figure illustrates the [<strong>Ensemble</strong>] > [Business Rules] > [Message Routing Rule Editor]<br />

page, which is used to create routing rule sets. The format of the Message Routing Rule Editor is the<br />

same as the Business Rule Editor in the following ways:<br />

• The top row of buttons: Rule List, Rule Log, Edit or Revert, Save, Delete<br />

Routing Rule Sets for <strong>HL7</strong><br />

• The basic information table: Package Name, Rule Name, Routing Engine Class and so on<br />

•<br />

Activity buttons in the bottom display:<br />

This topic explains how to use the features of the Message Routing Rule Editor that are different from<br />

those of the Business Rule Editor. For background information about the Business Rule Editor, see<br />

the chapters “Managing Business Rules” and “Creating Rule Sets” in Using Business Rules with<br />

<strong>Ensemble</strong>.<br />

To build a routing rule set for use with an <strong>HL7</strong> routing process:<br />

1. Start the <strong>Ensemble</strong> Management Portal.<br />

2. Display the Message Routing Rule Editor in one of the following ways:<br />

• While viewing a configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, click on a<br />

routing process in the Business Processes column. Click the View Rules button. The [<strong>Ensemble</strong>]<br />

> [Business Rules] > [Message Routing Rule Editor] page displays.<br />

Click Edit.<br />

• From the main menu, choose Business Rules. The [<strong>Ensemble</strong>] > [Business Rules] page displays<br />

a list of rule sets. Find a routing rule set and click Edit next to its name.<br />

• From the main menu, choose Business Rules. The [<strong>Ensemble</strong>] > [Business Rules] page displays<br />

a list of rule sets. Click the Create New Message Routing Rule button.<br />

3. When you create a new <strong>HL7</strong> routing process using the Business Process Wizard, <strong>Ensemble</strong> creates<br />

a new, empty routing rule set to accompany the new routing process. Its information table contain<br />

the following values acquired from the Business Process Wizard:<br />

• Package Name — The package that contains the production class. For example, if you used<br />

the wizard to add a routing process to a production called TestRule.MyTest, the associated<br />

routing rule has a Package Name of:<br />

TestRule<br />

• Rule Name — The simple Routing Rule Name that you chose in the wizard, such as:<br />

MyRule<br />

The combination of the Package Name and Rule Name identify the rule uniquely within the<br />

<strong>Ensemble</strong> namespace. The full name for any rule definition is the Package Name and Rule<br />

Name connected by a dot (.) as in:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 45


Elements of a Routing Production<br />

TestRule.MyRule<br />

This full name, rather than the Rule Name, is the correct value to use in the BusinessRuleName<br />

field when configuring an <strong>HL7</strong> routing process. The Business Process Wizard sets this up<br />

automatically.<br />

• Routing Engine Class — The default Router Class from the wizard; do not change it:<br />

EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine<br />

If you did not use the wizard to create your routing rule set, then in the top half of the Message<br />

Routing Rule Editor screen you must enter basic information for the rule as follows:<br />

• Package Name — Similar in principle to the package name you use to organize host classes<br />

in Studio, this name may contain dot (.) separators, as in:<br />

MyClassPackage.Organization.Levels<br />

• Rule Name — A simple name that contains no dot (.) separators, as in:<br />

MyRule<br />

The combination of the Package Name and Rule Name identify the rule uniquely within the<br />

<strong>Ensemble</strong> namespace. The full name for any rule definition is the Package Name and Rule<br />

Name connected by a dot (.) as in:<br />

MyClassPackage.Organization.Levels.MyRule<br />

This full name, rather than the Rule Name, is the correct value to use in the BusinessRuleName<br />

field when configuring an <strong>HL7</strong> routing process.<br />

• Routing Engine Class — This field tells the Message Routing Rule Editor which object<br />

properties to offer as drop-down choices in the Value Editor window while a user is editing<br />

a rule. For an <strong>HL7</strong> routing rule set, use:<br />

EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine<br />

4. Type a Description of the rule definition and its purpose. For example, you might list the types of<br />

message segments that travel over this interface.<br />

5. Do All Rules — If the Do All Rules check box is selected, <strong>Ensemble</strong> will begin at Rule 1 and evaluate<br />

all of the rules in sequence. In this case <strong>Ensemble</strong> executes every rule that evaluates to True.<br />

If the Do All Rules check box is clear, <strong>Ensemble</strong> stops evaluating rules immediately after executing<br />

the first rule in the sequence that evaluates to True.<br />

6. The bottom half of the Message Routing Rule Editor page contains fields that describe the logic<br />

of the routing rule using Rules, Conditions, and Actions. The following close-up views show<br />

details of this part of the user interface.<br />

On the left are the columns that identify Rules:<br />

46 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Routing Rule Sets for <strong>HL7</strong><br />

On the right are the columns that define Conditions and their resulting Actions:<br />

7. If you expect many of your rules to share fields in common, for example a Message Class of<br />

EnsLib.<strong>HL7</strong>.Message, you can streamline the editing process by providing a Base rule for the set.<br />

A rule called Base always appears at the top of a list of routing rules. Base serves as a convenient<br />

template for creating new rules for the set. It is not a default value of any kind, but a starting point<br />

for editing rules. You can use it or leave it blank.<br />

Any part of the Base rule that you define appears automatically in every other rule in the set.<br />

Wherever text is italicized in the Message Routing Rule Editor display, this indicates that the<br />

value is inherited from the Base rule. As an example, see the Source and Message Class columns<br />

in the figures above.<br />

Any rule in the set may override the values it inherits from the Base rule.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 47


Elements of a Routing Production<br />

8.<br />

To add a rule to the set, in the Rules column, click . The Routing Rule Wizard displays. Use<br />

this dialog to configure the rule Source, Message Class, Document Name, Schema Category, and<br />

Schema Doc Type, as described in the following steps.<br />

9. Source is the configured name of one of the following items:<br />

• An <strong>HL7</strong> business service (for a routing interface)<br />

• An <strong>HL7</strong> routing process (if another rule chains to this routing rule set)<br />

Click the More (...) icon next to the Source field to see a popup list of possible Source items in<br />

the namespace, organized by production name. For example:<br />

Select an item and click OK to save your changes to the Source field.<br />

If you have not yet prepared the item you need as a Source, you may leave this field blank and<br />

return to it when the item is ready.<br />

If you leave the Source field permanently blank, <strong>Ensemble</strong> considers input from all sources to be<br />

a match for that rule. You can configure this case deliberately for any rule that needs it.<br />

10. Message Class identifies the <strong>Ensemble</strong> message object that is being routed by this rule. Click the<br />

More (...) icon next to the Message Class field to view a popup list of possible Message Class<br />

choices.<br />

To route <strong>HL7</strong> <strong>Version</strong> 2 messages, choose EnsLib.<strong>HL7</strong>.Message.<br />

Important:<br />

The next three fields in the Routing Rule Wizard, and the next three steps in this<br />

procedure, apply only when the Message Class is EnsLib.<strong>HL7</strong>.Message or any<br />

other virtual document class, such as for X12 or ASTM. For other types of message,<br />

skip to Step 14.<br />

The next three fields in the Routing Rule Wizard are:<br />

• Document Name<br />

48 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Routing Rule Sets for <strong>HL7</strong><br />

• Schema Category<br />

• Schema Doc Type<br />

The distinctions between these properties are as follows:<br />

• Document Name is the <strong>HL7</strong> message structure that the source application identifies in the<br />

MSH:9 field, such as ADT_A08 or ORM_O01. To allow easy retrieval, this MSH:9 value<br />

resides in the EnsLib.<strong>HL7</strong>.Message property called Name.<br />

There is a problem with relying on the message header segment, MSH, for message validation.<br />

What the application says it is sending, and what the application actually sends, can be different.<br />

In theory, the values in MSH always correctly identify the contents of the message, but<br />

in practice, this is not always the case.<br />

For example, the message header MSH:12 field may state that the message is version 2.2,<br />

but the message contents may actually conform to the 2.3.1 standard or to some custom<br />

schema category. Thus, in addition to Document Name the Routing Rule Wizard also offers<br />

Schema Category and Schema Doc Type as values that the <strong>Ensemble</strong> validation sequence can<br />

attempt to match. These values should have been correctly assigned by the business service<br />

that accepted the message into <strong>Ensemble</strong>. If the values in the message DocType do not match<br />

those in the rule, then the rule does not execute.<br />

• Schema Category and Schema Doc Type represent the actual <strong>HL7</strong> message structure. These<br />

values reside in the EnsLib.<strong>HL7</strong>.Message property called DocType. DocType is a two-part<br />

string separated by a colon, such as 2.4:ADT_A08.<br />

- At left is the Schema Category. This is the name of a built-in schema category such as<br />

2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, or the name of a custom schema definition.<br />

- At right is the Schema Doc Type. This is an <strong>HL7</strong> message structure within the identified<br />

schema, such as ADT_A08 or ORM_O01.<br />

If validation is enabled for the routing process, and if values are provided for Schema Category<br />

or Schema Doc Type, <strong>Ensemble</strong> parses the message to determine if its structure matches the<br />

schema specified. The Schema Doc Type does not need to be the same as the Document Name<br />

for the message to be accepted as valid.<br />

Steps 11, 12, and 13 explain how to fill in these fields in the Routing Rule Wizard.<br />

11. For the Document Name, you can:<br />

• Leave the field blank, to match any Document Name.<br />

• Enter a value, to cause the rule to match only messages with the specified Document Name.<br />

• Enter more than one value in the Document Name text entry field, pressing Enter between<br />

values to place one value on each line of text. This causes the rule to match any of the specified<br />

Document Name values, and no others.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 49


Elements of a Routing Production<br />

When viewing the rule after you have edited it, the value you entered in the Document Name field<br />

appears as the Message Type for the rule.<br />

12. For the Schema Category, you can:<br />

• Leave the field blank, to match any Schema Category.<br />

• Enter or choose a single value using the More (...) icon, to cause the rule to match only messages<br />

with the specified Schema Category.<br />

When viewing the rule after you have edited it, the value you entered in the Schema Category<br />

field appears as the Category for the rule.<br />

13. For the Schema Doc Type, you can:<br />

• Leave the field blank, to match any Schema Doc Type.<br />

• Enter a value, to cause the rule to match only messages with the specified Schema Doc Type.<br />

• Enter more than one value in the Schema Doc Type text entry field, pressing Enter between<br />

values to place one value on each line of text. This causes the rule to match any of the specified<br />

Schema Doc Type values, and no others.<br />

• Enter either a simple Schema Doc Type (ORM_O01) or a full value separated by a colon<br />

(2.3.1:ORM_O01). A full value in the Schema Doc Type field temporarily overrides whatever<br />

is in the Schema Category field.<br />

When viewing the rule after you have edited it, the value you entered in the Schema Doc Type<br />

field appears as the Schema Doc Type for the rule.<br />

Important:<br />

If you are uncertain how to use the Document Name (Step 11), Schema Category<br />

(Step 12), or Schema Doc Type (Step 13), return to Step 10 for an overview of<br />

these fields.<br />

14. Click OK to save changes in the Routing Rule Wizard. Click Cancel to discard them.<br />

15. Once you have created a new rule, you may add Conditions and Actions to it. For details, see the<br />

“Creating Rule Sets” chapter in Using Business Rules with <strong>Ensemble</strong>. As you add Conditions to<br />

each rule, remember these tips:<br />

• Conditions evaluate AND operators first, then OR.<br />

• Conditions can refer to properties of the <strong>HL7</strong> message object. Within Conditions, the special<br />

variable Document represents the <strong>HL7</strong> message object, as in the following examples. For<br />

<strong>HL7</strong> batch documents, you can use the special variable Document.Parent to represent the<br />

parent message object.<br />

Document.Name<br />

Document.Parent.DocType<br />

50 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Routing Rule Sets for <strong>HL7</strong><br />

Document.{PIDgrp.PV1grp.PV1:18}<br />

Document.{PIDgrp.PID:PatientName.familylastname}<br />

Document.{ORCgrp(1).OBRuniongrp.OBRunion.OBR:4.3}<br />

Note:<br />

For compatibility with past releases, the special variables <strong>HL7</strong> and <strong>HL7</strong>.Parent<br />

are supported as alternatives to Document and Document.Parent.<br />

A dot separates the Document variable from the property name. This name may be:<br />

- Any of the class properties: DocType, TypeCategory, BuildMapStatus, or Name.<br />

- A virtual property, referenced using any of the following conventions:<br />

• Curly brackets<br />

{segmentPath:field}<br />

• Square brackets<br />

[segmentName:field]<br />

• Round brackets or parentheses<br />

(multi-valued-property-path)<br />

• Angle brackets<br />

<br />

Details are available in the “Virtual Property Syntax” section in the chapter “Syntax<br />

for a Routing Production.” However, you do not need to enter properties by typing; you<br />

can browse for properties as described in the “Creating Rule Sets” chapter in Using<br />

Business Rules with <strong>Ensemble</strong>.<br />

16. To specify an Action for a rule, click the Add or Send buttons in the Action column. The Routing<br />

Rule Wizard displays a dialog in which you can configure Action details as follows:<br />

• Type — Choose an option, one of the following:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 51


Elements of a Routing Production<br />

Type<br />

send<br />

delete<br />

stop<br />

continue<br />

Meaning<br />

Send the message to the target.This is appropriate for most cases.<br />

Discard the message.<br />

If the Do All Rules check box is selected, <strong>Ensemble</strong> evaluates every<br />

rule in the set, and all rules that are True have their actions<br />

executed. On the other hand, if any rule that is True provides a final<br />

action of stop, this overrides the Do All Rules setting and causes<br />

<strong>Ensemble</strong> to stop evaluating rules immediately. All subsequent<br />

rules in the set are skipped.<br />

If the Do All Rules check box is clear, <strong>Ensemble</strong> stops evaluating<br />

rules after executing the actions provided by the first rule that<br />

evaluates to True. However, if one of the actions in the rule is<br />

continue, this overrides the Do All Rules setting and causes<br />

<strong>Ensemble</strong> to continue evaluating more rules, in sequence, until it<br />

finds the next rule that evaluates to True, and then stop.<br />

• Target — For send you may enter the configured name of one or more of the following items.<br />

- An <strong>HL7</strong> business operation, to route the message to an external application<br />

- An <strong>HL7</strong> routing process, to chain to another routing rule set<br />

Click the More (...) icon next to the Target field to see a list of possible Target items in the<br />

namespace, organized by production name. You may select items from this list, one at a time.<br />

If you need to enter multiple items in the Target field, separate each name with a comma.<br />

This happens automatically when you select multiple items from the list.<br />

• Transform — To transform the <strong>HL7</strong> message before sending it to the Target, enter the full<br />

package and class name of one or more DTL data transformations.<br />

Click the More (...) icon next to the Transform field to see a list of data transformation classes<br />

in the namespace. You may select items from this list, one at a time. If you need to enter<br />

multiple items in the Transform field, separate each name with a comma. This happens automatically<br />

when you select multiple items from the list.<br />

• Click OK to save your changes, Cancel to discard them.<br />

If you have not yet created the configuration items that you want to specify in the Target or<br />

Transform fields, you may leave the Action field blank and return to it when these items are ready.<br />

Note that the Target and Transform fields each support multiple values. Multiple data transformations<br />

are chained in the order in which they appear, from left to right. Any transformations listed<br />

52 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


after the first one should be defined with create="existing" so as not to discard the results<br />

of the previous transformation in the chain.<br />

If you leave the Action, Transform, and Target fields permanently blank, <strong>Ensemble</strong> takes no action<br />

when this rule is true. You can configure this case deliberately for any rule that needs it.<br />

17. To save changes to the routing rule set, click Save. If you wish to discard changes and return to<br />

the previously saved version of the rule set, click Revert.<br />

18. Complete the instructions in the next several topics for creating any Source, Target, or Transform<br />

items that your routing rule set needs. The items might be:<br />

• An <strong>HL7</strong> business service, to route messages to the rule<br />

• A DTL data transformation, to transform the message before sending it<br />

• An <strong>HL7</strong> business operation, to route the message to an external application<br />

• An <strong>HL7</strong> routing process may be either a Source or a Target<br />

As you create items, return to the Message Routing Rule Editor to add them to the appropriate<br />

fields of the rule definition.<br />

19. Repeat from step 5 as needed to refine the logic of the routing rule set.<br />

DTL Data Transformations for <strong>HL7</strong><br />

20. Return to the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page. Select the corresponding<br />

<strong>HL7</strong> routing process. In the BusinessRuleName field enter the full name of the new routing<br />

rule set.<br />

2.8 DTL Data Transformations for <strong>HL7</strong><br />

Each data transformation invoked by the production must be an instance of a <strong>Ensemble</strong> Data Transformation<br />

Language (DTL) class — that is, a subclass of Ens.DataTransformDTL. Each interface may<br />

require more than one data transformation.<br />

Data transformations are used to modify an <strong>HL7</strong> message or create a new message from an existing<br />

message. You can edit a DTL data transformation in <strong>Ensemble</strong> Studio using the DTL Visual Editor<br />

or by editing the class code directly.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 53


Elements of a Routing Production<br />

<strong>Ensemble</strong> DTL Visual Editor<br />

To build a DTL data transformation for use in an <strong>HL7</strong> message routing production:<br />

1. Start Studio and change to an <strong>Ensemble</strong>-enabled user namespace.<br />

Important:<br />

<strong>InterSystems</strong> recommends that you do not place custom code or data in the systemprovided<br />

namespaces ENSLIB or ENSDEMO where it will be deleted the next<br />

time you upgrade <strong>Ensemble</strong>. Any new namespace that you create to hold your<br />

work is preserved across <strong>Ensemble</strong> upgrades.<br />

2. Find an existing <strong>Ensemble</strong> data transformation that seems similar to the one you are converting.<br />

After converting several interfaces, you might discover a specific data transformation that tends<br />

to be useful as a starting point when nothing else is similar. Use this class, or use the data transformation<br />

class Demo.<strong>HL7</strong>.Router.SampleTransformation from the ENSDEMO namespace of sample<br />

classes. This class is illustrated above.<br />

3. Choose Tools, then Copy Class. A dialog pops up. Edit it using the following sequence of steps:<br />

• In the Copy Class Definition From field, browse to the data transformation class that you chose<br />

as a starting point.<br />

• In the To field, enter the full package and class name for the new data transformation.<br />

54 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


DTL Data Transformations for <strong>HL7</strong><br />

Important:<br />

<strong>InterSystems</strong> recommends that you do not use the package names Demo,<br />

Ens, EnsLib, EnsPortal, or CSPX. This causes your work to be deleted the<br />

next time you upgrade <strong>Ensemble</strong>.<br />

• Select the Add New Class to Project check box.<br />

• Click OK.<br />

4. Have the <strong>Ensemble</strong> Data Transformation Language Reference handy. This book lists and explains<br />

the available DTL elements.<br />

5. Be clear about the value you want for the create attribute of the element. create may<br />

have one of the following values:<br />

• “new” — Create a new object of the target type, before executing the elements within the<br />

data transformation. Any source segments that you do not explicitly assign to the target object<br />

are ignored. This is the default.<br />

• “copy” — Create a copy of the source object to use as the target object, before executing the<br />

elements within the transform.<br />

• “existing” — Use an existing object, provided by the caller of the data transformation, as the<br />

target object.<br />

To create a target object that is an exact copy of the source, do not use:<br />

<br />

Instead use the create='copy' attribute in the containing element.<br />

6. Ensure that the DTL element identifies the correct schema category for:<br />

• The sourceDocType attribute<br />

• The targetDocType attribute<br />

The schema category may be the same or different for the source and target objects.<br />

7. Ensure that the DTL element sets the scripting language that you want to use for all<br />

of the conditional expressions and elements within that data transformation. ObjectScript<br />

is the default language. If you want Caché Basic, you can specify it as follows:<br />


Elements of a Routing Production<br />

If you want to type elements into the DTL code directly, you may do so. Your changes<br />

in the DTL code view become visible each time you click on the DTL diagram view in the DTL<br />

Visual Editor.<br />

Possibly, you will want to use a combination of techniques. You can first generate a line of code<br />

by dragging, then fine-tune the code by editing the text.<br />

9. The data transformation can refer to properties of the <strong>HL7</strong> message object, including:<br />

• The class properties DocType, TypeCategory, BuildMapStatus, and Name.<br />

• Virtual document properties as described in “Curly Bracket {} Syntax” in the “Virtual<br />

Property Syntax” section in the chapter “Syntax for a Routing Production.”<br />

Within the data transformation class code, the special variables source and target represent<br />

the respective <strong>HL7</strong> message objects, as in the following examples:<br />

source.Name<br />

target.DocType<br />

source.{PIDgrp.PV1grp.PV1:18}<br />

target.{PIDgrp.PID:PatientName.familylastname}<br />

source.{ORCgrp(1).OBRuniongrp.OBRunion.OBR:4.3}<br />

10. Assign any literal string values, or make conditional assignments, as described in the “Literal<br />

String Syntax” section of the chapter “Syntax for a Routing Production.” Highlights include:<br />

• The syntax required to assign a literal string in DTL is as follows:<br />

value='"string"'<br />

• Do not insert a literal <strong>HL7</strong> separator string for MSH 2 in the target. <strong>HL7</strong> separators are handled<br />

in the <strong>HL7</strong> business operation.<br />

• Do not manually change <strong>HL7</strong> escape sequences such as \F\ or \S\ in the data transformation.<br />

The <strong>HL7</strong> business operation handles these appropriately.<br />

• Be aware of XML entities and other special characters. If you run into trouble with quotes<br />

you can use the entities &quot; and &apos;<br />

• A value can be a simple literal string, as in:<br />

value='"string"'<br />

A value can be a complex string expression in the language being used for the data transformation.<br />

The language for this expression depends on the value of the language attribute for<br />

the DTL element. If not specified, the default language is ObjectScript.<br />

• The ObjectScript concatenation operator is the underscore character, as in:<br />

value='"string1"_"string2"'<br />

56 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


In Caché Basic, the concatenation operator is & (ampersand).<br />

• To learn about useful ObjectScript string functions, such as $CHAR and $PIECE, see the<br />

Caché ObjectScript Reference. For Basic equivalents, see the Caché Basic Reference.<br />

• The <strong>HL7</strong> null mapping code "" requires special handling. The following example tests for<br />

the null mapping code in the source message and replaces it with a blank string in the target<br />

message:<br />

<br />

<br />

<br />

<br />

<br />

For details, see “Null Mapping Codes” in the “Literal String Syntax” section in the chapter<br />

“Syntax for a Routing Production.”<br />

11. For simple calculations, the DTL data transformation can:<br />

• Invoke <strong>Ensemble</strong> utility functions<br />

• Use ObjectScript or Caché Basic expressions in the DTL element<br />

• Invoke the DTL element<br />

For more complex calculations, you can write utility class methods and invoke them from the<br />

DTL element, or from the value string in another DTL element.<br />

12. You can comment your DTL code. For your comments to be permanently visible in both class<br />

code and DTL Visual Editor views, you must provide comments within a block.<br />

For details and examples, see the section “Documentation and Comments” in the “<strong>Ensemble</strong><br />

Productions” chapter of Developing <strong>Ensemble</strong> Productions.<br />

13. Compiling the data transformation also saves it.<br />

DTL Data Transformations for <strong>HL7</strong><br />

14. To use the DTL data transformation in the production, simply enter its full package and class<br />

name in the Transform field of a routing rule set.<br />

2.8.1 Utility Functions<br />

<strong>Ensemble</strong> provides a large number of built-in utility functions that include mathematical or string<br />

processing functions such as you may be accustomed to using in other programming languages. These<br />

functions are available for use in business rules or DTL data transformations.<br />

For example, the following DTL statement uses the built-in function ToUpper to convert a<br />

string to all uppercase characters. This statement references ToUpper using double-dot<br />

syntax, as if it were a method in the DTL data transformation class:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 57


Elements of a Routing Production<br />

<br />

For syntax details and a list of functions, see the section “Utility Functions” in the “Creating a New<br />

Production” chapter of Developing <strong>Ensemble</strong> Productions. The topic also explains how to extend the<br />

list of built-in utility functions by adding custom code.<br />

2.8.2 Utility Class Methods<br />

Instead of invoking a utility function from DTL directly, as shown above for ToUpper, for more<br />

complete calculations you can provide utility class methods and then invoke them from a DTL <br />

element. The steps are:<br />

1. Write the methods in a utility class in the same package as the other <strong>Ensemble</strong> element; for<br />

example:<br />

MyPackageName.TransformUtils<br />

2. Invoke these methods from the DTL data transformation using the element.<br />

2.9 <strong>HL7</strong> Business Operations<br />

An <strong>HL7</strong> business operation constructs an outgoing <strong>HL7</strong> message and relays it to an outbound adapter<br />

along with all of the information necessary to transmit the message. The adapter knows nothing about<br />

the contents of the outgoing message and simply relays it to a specific external system using the<br />

information provided.<br />

To build an <strong>HL7</strong> business operation for use in an <strong>HL7</strong> message routing production, you must create<br />

it, configure it, and integrate it into the production. This topic explains each step.<br />

2.9.1 Creating an <strong>HL7</strong> Business Operation<br />

To send <strong>HL7</strong> messages outside <strong>Ensemble</strong>, you must add an <strong>HL7</strong> business operation to the production<br />

configuration. <strong>Ensemble</strong> provides built-in business operations that take care of these tasks over TCP,<br />

File, FTP, and HTTP connections. Generally, you will choose one of these built-in business operations<br />

rather than write your own.<br />

For your convenience in working with <strong>HL7</strong> productions, two simple business operations are also built<br />

into <strong>Ensemble</strong>: EnsLib.File.PassthroughOperation and EnsLib.FTP.PassthroughOperation. You can<br />

choose either of these business operations if you simply need to send a file out from the <strong>HL7</strong> routing<br />

production, and do not want to parse or format it in any special way.<br />

58 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Additionally, you might want to send data outside <strong>Ensemble</strong> that is not an <strong>HL7</strong> message. This can be<br />

accomplished by creating a business operation class that communicates with an adapter as described<br />

in Developing <strong>Ensemble</strong> Productions and in each of the <strong>Ensemble</strong> Adapter <strong>Guide</strong>s.<br />

To add a business operation to an <strong>HL7</strong> routing production:<br />

1. Start the <strong>Ensemble</strong> Management Portal.<br />

2. Add an FTP, File, or TCP business operation for <strong>HL7</strong> as follows:<br />

• Start the Business Operation Wizard in one of the following ways:<br />

<strong>HL7</strong> Business Operations<br />

- On the [<strong>Ensemble</strong>] > [Productions] > [Production Model] page, click Add Business Operation.<br />

- While viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, do one<br />

of the following:<br />

• Left-click on the diagram background. A row of buttons displays below the diagram.<br />

Click Add Operation.<br />

• Right-click on the diagram to reveal the context menu. Choose Add, then Business<br />

Operation.<br />

• Choose <strong>HL7</strong> Output.<br />

• Enter information in the following fields:<br />

- Choose TCP, File, or FTP to determine the host class. Each class already exists and requires<br />

no programming. Simply choose one.<br />

- Give the item a configuration Name.<br />

• Click OK to save your changes, Cancel to ignore them.<br />

3. Add other types of <strong>HL7</strong> business operation as follows:<br />

• Start the Business Operation Wizard in one of the following ways:<br />

- On the [<strong>Ensemble</strong>] > [Productions] > [Production Model] page, click Add Business Operation.<br />

- While viewing the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page, do one<br />

of the following:<br />

• Left-click on the diagram background. A row of buttons displays below the diagram.<br />

Click Add Operation.<br />

• Right-click on the diagram to reveal the context menu. Choose Add, then Business<br />

Operation.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 59


Elements of a Routing Production<br />

• Choose Other.<br />

• Enter information in the following fields:<br />

- Choose the host class. Each class already exists and requires no programming. Choices<br />

include:<br />

• EnsLib.File.PassthroughOperation<br />

• EnsLib.FTP.PassthroughOperation<br />

• EnsLib.<strong>HL7</strong>.Operation.HTTPOperation<br />

• EnsLib.<strong>HL7</strong>.Operation.HTTPAckOutOperation<br />

• EnsLib.<strong>HL7</strong>.Operation.TCPAckOutOperation<br />

• Any other business operation class in the namespace<br />

- Give the item a configuration Name.<br />

• Click OK to save your changes, Cancel to ignore them.<br />

4. To add a business operation of any type, by copying another business operation:<br />

• Display the configuration diagram on the [<strong>Ensemble</strong>] > [Productions] page.<br />

• Select the business operation in the diagram.<br />

• Click the Copy button. A dialog prompts you to enter a configuration name.<br />

• Enter a unique name and click OK. Your new business operation appears in the diagram<br />

• When first created, the copy has the same host class and settings as the original; only the<br />

name is different. You must make the new copy different by configuring it.<br />

Note:<br />

The Copy button works only within the same production. You cannot copy a business<br />

operation from one production to another.<br />

2.9.2 Configuring an <strong>HL7</strong> Business Operation<br />

You can configure an <strong>HL7</strong> business operation by clicking on it while viewing the configuration diagram<br />

on the [<strong>Ensemble</strong>] > [Productions] page. The following fields display below the diagram; you can edit<br />

these fields to configure the routing process.<br />

Note:<br />

To navigate to the configuration diagram from the [<strong>Ensemble</strong>] > [Productions] > [Production<br />

Model] page, where the previous topic ended, click Configure Production, then continue.<br />

60 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


You may configure an <strong>HL7</strong> business operation by entering values in the following fields. When you<br />

are done editing, click Apply to save your changes, or Cancel to ignore them.<br />

• General Settings — This column of settings appears at left. These are settings that configure the<br />

<strong>HL7</strong> business operation as a production item. The most important of these for <strong>HL7</strong> are as follows.<br />

For descriptions of the other General Settings, see the section “Business Operation Settings” in<br />

“The Configuration Page” chapter of Managing <strong>Ensemble</strong> Productions.<br />

- PoolSize — The default PoolSize value of 1 ensure FIFO (First In, First Out) processing.<br />

FIFO processing is important to ensure correct data in the receiving applications. Multiple<br />

patient demographic updates must be received in order; otherwise, obsolete, incorrect data<br />

may appear in the receiving application. Also, many applications require receipt of an ADT<br />

Registration message before they can process an Order message, an Order message must be<br />

received before a Result message, and so on.<br />

- FailureTimeout — The number of seconds during which to continue retry attempts. After this<br />

number of seconds has elapsed, the business operation gives up and returns an error code.<br />

<strong>HL7</strong> business operations automatically set this value to –1 for “never time out” to ensure that<br />

no <strong>HL7</strong> message is skipped.<br />

- Category — This text label permits configuration items to be sorted in the configuration diagram.<br />

For example, you can assign the same Category name to all items in the same interface.<br />

You may enter multiple category names separated by commas. Space characters count (do<br />

not use them around the commas).<br />

• Specific Settings — This column of settings appears at right. The column is organized into settings<br />

that configure the <strong>HL7</strong> business operation (at top) and settings that configure its associated adapter<br />

(at bottom). The specific settings will be different depending on which <strong>HL7</strong> business operation<br />

you are configuring, and which adapter that business operation is using. The following list describes<br />

how to configure the most important of these settings. For details about which class provides<br />

which settings, see the “<strong>HL7</strong> Business Operation Classes” section in the chapter “Settings for<br />

a Routing Production.”<br />

The Specific Settings for an <strong>HL7</strong> business operation are as follows:<br />

Adapter Class<br />

Alert On Error<br />

Identifies the TCP, File, or FTP outbound adapter for <strong>HL7</strong>.<br />

<strong>HL7</strong> Business Operations<br />

If True, the <strong>HL7</strong> business operation automatically triggers an alert upon encountering errors<br />

connecting with its external target. See the “Pager and Email Alerts” section in this chapter.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 61


Elements of a Routing Production<br />

Alert Retry Grace Period<br />

Archive IO<br />

Business operations can be configured with an Alert Retry Grace Period during which errors<br />

relating to external connections do not trigger alerts, even if Alert On Error is True. This grace<br />

period accommodates a business operation that attempts an external connection with a configured<br />

Retry Interval and Failure Timeout. During its retry sequence, the business operation<br />

may encounter connection failures that become unimportant after one of its retry attempts<br />

succeeds. Thus, if a business operation first encounters an error, but later achieves success<br />

within the time allotted by the Alert Retry Grace Period, no alert is triggered even though an<br />

error occurred. Setting Alert Retry Grace Period to 0 disables this feature for the business<br />

operation.<br />

If True, the adapter associated with this business operation will log in the <strong>Ensemble</strong> I/O<br />

archive each input and output communication it shares with the external system. See the<br />

section “Working with the I/O Archive” in the “What to Manage” chapter of Managing<br />

<strong>Ensemble</strong> Productions.<br />

AutoBatchParentSegs<br />

(File and FTP only) If True, when writing a message that has a batch parent, output the batch<br />

headers first, then child documents, then follow up with the batch trailers when triggered by<br />

the final batch header message or by a file name change. If False, omit headers and trailers<br />

and output child documents only. The default is False.<br />

For more about batch handling, see the “<strong>HL7</strong> Batch Messages” section in the chapter<br />

“Settings for a Routing Production.”<br />

DefCharEncoding<br />

File Name<br />

The default character encoding to use when reading or writing <strong>HL7</strong> messages. If any incoming<br />

<strong>HL7</strong> message has an empty MSH:18 (Character Set) field, <strong>Ensemble</strong> uses the DefCharEncoding<br />

value in its place. Supported values are UTF-8 or any member of the Latinn family. The<br />

value Native means to use the native default encoding installed on the <strong>Ensemble</strong> server.<br />

The default value for DefCharEncoding is Latin1. Placing a ! (exclamation point) character<br />

at the beginning of the encoding name forces <strong>Ensemble</strong> to use the DefCharEncoding value<br />

and ignore any value found in MSH:18. For example: !UTF-8<br />

(File and FTP only) The target file name. The File Path adapter setting determines the path<br />

for this file; File Name determines the name. File Name can include <strong>Ensemble</strong> time stamp<br />

specifiers. If you leave File Name blank, the default uses the time stamp specifier %f_%Q<br />

where:<br />

• %f is the name of the data source, in this case the input filename<br />

62 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


• _ is the literal underscore character, which will appear in the output filename<br />

• %Q indicates ODBC format date and time<br />

<strong>HL7</strong> Business Operations<br />

In substituting a value for the format code %f, <strong>Ensemble</strong> strips out any of the characters<br />

|,,\,/,:,[,],,&,,,;,NUL,BEL,TAB,CR,LF, replacing spaces with underbars (_) and slashes<br />

(/) with hyphens (-). When the output file is being saved on an OpenVMS system, <strong>Ensemble</strong><br />

replaces colons with hyphens (-). Otherwise, colons (:) become dots (.).<br />

For full details about time stamp conventions, including a variety of codes you can use instead<br />

of the default %f_%Q, see the section “Time Stamps in Filenames” in the “Creating a New<br />

Production” chapter of Developing <strong>Ensemble</strong> Productions.<br />

Framing<br />

Controls how the <strong>HL7</strong> business operation constructs the outgoing <strong>HL7</strong> message packet. For<br />

a list of framing options, see the “<strong>HL7</strong> Message Framing Types” section in the chapter<br />

“Settings for a Routing Production.” If you are unsure what value to use, accept the default<br />

of MLLP framing for <strong>HL7</strong> business operations.<br />

NoFailWhileDisconnected<br />

(TCP only) If True, suspend counting seconds toward the Failure Timeout while disconnected<br />

from the TCP server. The NoFailWhileDisconnected setting does not apply if Failure Timeout<br />

is –1 or if StayConnected is 0.<br />

PartnerAckTimeout<br />

(TCPAckOut or HTTPAckOut only) The EnsLib.<strong>HL7</strong>.Operation.TCPAckOutOperation is a specialized<br />

<strong>HL7</strong> TCP business operation that sends ACKs on behalf of a paired <strong>HL7</strong> TCP business<br />

service. There is also an EnsLib.<strong>HL7</strong>.Operation.HTTPAckOutOperation. For details, see the<br />

“Dual Acknowledgement Sequences” section in the chapter “Settings for a Routing Production.”<br />

When EnsLib.<strong>HL7</strong>.Operation.TCPAckOutOperation or<br />

EnsLib.<strong>HL7</strong>.Operation.HTTPAckOutOperation is the business operation class, PartnerAckTimeout<br />

tells the business operation the number of seconds to wait for its partner business service to<br />

supply an ACK that corresponds to the normal outbound message that the business operation<br />

sent. The default PartnerAckTimeout is 600 seconds (10 minutes).<br />

ReplyCodeActions<br />

(TCP only) When the adapter setting Get Reply is True, ReplyCodeActions allows you to<br />

supply a comma-separated list of code-action pairs, specifying which action the business<br />

operation will take on receipt of various types of ACK response messages. The format of the<br />

list is:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 63


Elements of a Routing Production<br />

Retry Interval<br />

code=action,code=action, ... code=action<br />

For possible code and action values, see the “<strong>HL7</strong> Acknowledgement (ACK) Mode” section<br />

in the chapter “Settings for a Routing Production.”<br />

Number of seconds to wait between attempts to connect with a destination outside <strong>Ensemble</strong>.<br />

Search Table Class<br />

Separators<br />

The package and class name of a search table class that you have defined in this <strong>Ensemble</strong><br />

namespace. A search table class is a specialized tool that you can create to work with virtual<br />

documents, such as <strong>HL7</strong> messages. A virtual document is efficient because it contains a large<br />

amount of raw data but no instantiated properties. Creating a search table enables <strong>Ensemble</strong><br />

to efficiently index a few of the fields in a virtual document so that these fields are available<br />

to be searched as if they were properties in a standard message body.<br />

To create a search table class, see the “<strong>HL7</strong> Search Tables” section in this chapter. For further<br />

background information, see the book <strong>Ensemble</strong> Virtual Documents.<br />

<strong>HL7</strong> separator characters to use in the outgoing message. If you leave this field blank, the<br />

default is:<br />

|^~\&<br />

For further details, see “<strong>HL7</strong> Separator Characters” in the “Literal String Syntax” section<br />

in the chapter “Syntax for a Routing Production.”<br />

The remaining entries in the Specific Settings column are determined by the type of adapter: FTP, File,<br />

TCP, or HTTP. The following adapter settings are especially important for <strong>HL7</strong> business operations:<br />

Reconnect Retry<br />

(TCP only) Number of retries at which to drop the connection and try reconnecting again. A<br />

value of 0 (zero) means never disconnect. The default is 5.<br />

StayConnected<br />

A zero value means to disconnect immediately after every input event. The default of –1<br />

means to stay permanently connected, even during idle times. Adapters are assumed idle at<br />

startup and therefore only auto-connect if they are configured with a StayConnected value of<br />

–1. The only StayConnected values that are useful in the normal case are 0 and –1. However,<br />

StayConnected can also be a positive number. If the StayConnected time is longer than the<br />

CallInterval, the adapter stays connected all the time. If the StayConnected time is shorter than<br />

the CallInterval, the adapter disconnects and reconnects at each CallInterval.<br />

64 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Pager and Email Alerts<br />

For further information about any setting, hovering the cursor over the setting name, or consult these<br />

references:<br />

• “Adapter Settings” in the “FTP Outbound Adapter” chapter of Using FTP Adapters with<br />

<strong>Ensemble</strong><br />

• “Adapter Settings” in the “File Outbound Adapter” chapter of Using File Adapters with<br />

<strong>Ensemble</strong><br />

• “Adapter Settings” in the “TCP Outbound Adapter” chapter of Using TCP Adapters with<br />

<strong>Ensemble</strong>, which describes the settings for the general-purpose TCP outbound adapter. The difference<br />

for the special-purpose adapter called EnsLib.<strong>HL7</strong>.Adapter.TCPOutboundAdapter is that it<br />

has the following settings configured appropriately for <strong>HL7</strong>:<br />

- GetReply is set to True. This means the adapter will wait to read a reply message back from<br />

the socket before returning.<br />

- ConnectTimeout has its usual default of 5 seconds, but has a maximum limit of 30,000 seconds.<br />

- ResponseTimeout has a default of 30 instead of its usual 15, and has a maximum limit of<br />

30,000 seconds.<br />

• The “Using the HTTP Outbound Adapter” chapter in Using HTTP Adapters with <strong>Ensemble</strong><br />

2.9.3 Integrating an <strong>HL7</strong> Business Operation<br />

To integrate a new <strong>HL7</strong> business operation into an <strong>Ensemble</strong> production, simply identify it as a target<br />

that receives messages. To do this, you must configure the item that sends messages to the <strong>HL7</strong> business<br />

operation and enter the configured Name of the <strong>HL7</strong> business operation into the appropriate field:<br />

• For a routing interface, enter the name in the Target field of the routing rule set.<br />

• If your design uses a pass-through interface that simply relays messages from the incoming business<br />

service to the outgoing business operation, enter the name in the TargetConfigNames field of the<br />

<strong>HL7</strong> business service.<br />

2.10 Pager and Email Alerts<br />

Alerts provide the ability to send notification to a user device while an <strong>Ensemble</strong> production is running.<br />

The intention is to alert a system administrator or service technician to the presence of a problem.<br />

Alerts may be sent via email, text pager, or another mechanism. Alerts may be sent using:<br />

• The SendAlert method from Caché Basic or ObjectScript code<br />

• The element from a BPL business process<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 65


Elements of a Routing Production<br />

• The Alert On Error setting to enable automatic alerts from business hosts<br />

All alert messages are automatically written to the <strong>Ensemble</strong> event log as entries of type Alert. However,<br />

the real purpose of an alert is to contact an external entity, such as a human user (via email or page)<br />

or a management tool (via WMI or SNMP). A production does this by directing all alert messages to<br />

a configuration item called Ens.Alert, which has been set up with all the information necessary to<br />

contact user devices outside <strong>Ensemble</strong>. For details, see the section “Alerts” in the “<strong>Ensemble</strong> Productions”<br />

chapter of Developing <strong>Ensemble</strong> Productions.<br />

The starter <strong>HL7</strong> routing production provides the following elements to support alerts:<br />

• Ens.Alert — The starter <strong>HL7</strong> routing production provides a built-in Ens.Alert element. This<br />

Ens.Alert is a routing process with an associated routing rule set called AlertRule.<br />

You can configure AlertRule to route alert messages to different business operations depending<br />

on the source of the alert message (that is, which element is in trouble) and various conditions<br />

(such as time of day).<br />

Tip:<br />

To view time-of-day function examples, start Studio and change to the ENSDEMO<br />

namespace. Look at the sample functions in the class Demo.<strong>HL7</strong>.MsgRouter.Functions.<br />

To configure AlertRule, follow a similar procedure to the one for <strong>HL7</strong> routing rule sets, except:<br />

- For the Message Class, choose Ens.AlertRequest<br />

- In the Target field, choose or type the configured name of an email business operation.<br />

• PagerAlert and EmailAlert — These are ordinary email operations that can be configured to send<br />

a text message (such as the body of an alert) to a pager or email address. PagerAlert and EmailAlert<br />

are initially identical, other than their names. Both are provided to emphasize the fact that alerts<br />

have different priorities. Generally the higher-priority alerts go to a pager, lower-priority to email.<br />

You can configure any number of destinations that copy these starter operations. At runtime, your<br />

AlertRule routing rule set determines which destination is appropriate to use.<br />

2.11 <strong>HL7</strong> Search Tables<br />

In writing a search table class, your goal is to provide one search table entry for each virtual property<br />

that you want to search and filter in the Message Browser, Rules Editor, and other parts of the<br />

<strong>Ensemble</strong> Management Portal.<br />

The built-in search table class EnsLib.<strong>HL7</strong>.SearchTable already provides entries for popular <strong>HL7</strong><br />

properties. When you choose EnsLib.<strong>HL7</strong>.SearchTable as your search table class, it enables <strong>Ensemble</strong><br />

to search <strong>HL7</strong> messages for the following virtual properties.<br />

66 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Search Tables<br />

Built-in Search Table Entries for <strong>HL7</strong><br />

Choose...<br />

MSHTypeName<br />

To refer to this value...<br />

The message structure name. To construct this string, <strong>Ensemble</strong> concatenates<br />

the following values from the <strong>HL7</strong> message:<br />

• The MSH message header segment<br />

Field 9 (message type)<br />

Subfield 1 (message type: ADT, ORM, etc)<br />

• The literal character _<br />

• The MSH message header segment<br />

Field 9 (message type)<br />

Subfield 2 (trigger event: A01, A12, O01_2, etc)<br />

The result is a message structure name in the format ADT_A01,<br />

ADT_A12, ORM_O01_2, etc.<br />

MSHControlID<br />

The unique identifying number for this message. <strong>Ensemble</strong> retrieves<br />

this value from:<br />

• The MSH message header segment<br />

Field 10 (message control ID)<br />

<strong>Ensemble</strong> interprets this value as a case-sensitive string.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 67


Elements of a Routing Production<br />

Choose...<br />

PatientID<br />

To refer to this value...<br />

The patient identifier for this message. This is a field whose location<br />

has shifted as the <strong>HL7</strong> standard has evolved. For this reason, <strong>Ensemble</strong><br />

looks for this value in all of the following locations. That way, the patient<br />

identifier can be found regardless of which <strong>HL7</strong> schema category the<br />

message conforms to:<br />

• The PID patient identifier segment<br />

Field 2 (patient external identifier)<br />

Subfield 1 (patient identifier)<br />

• The PID patient identifier segment<br />

Field 3 (patient identifier list), all entries in the list<br />

Subfield 1 (patient identifier)<br />

• The PID patient identifier segment<br />

Field 4 (patient identifier list), all entries in the list<br />

Subfield 1 (patient identifier)<br />

PatientName<br />

PatientAcct<br />

The PID patient identifier segment<br />

Field 5 (patient name)<br />

The PID patient identifier segment<br />

Field 18 (patient account number)<br />

Subfield 1 (ID)<br />

If you need more than this minimal list of virtual properties, you may subclass EnsLib.<strong>HL7</strong>.SearchTable<br />

to create new search table classes. Any subclass of EnsLib.<strong>HL7</strong>.SearchTable inherits the entries described<br />

in the previous table, plus the infrastructure that makes search tables work.<br />

To create a new search table class for your message routing production:<br />

1. Start Studio and choose an <strong>Ensemble</strong>-enabled user namespace.<br />

Important:<br />

<strong>InterSystems</strong> recommends that you do not place custom code or data in the systemprovided<br />

namespaces ENSLIB or ENSDEMO where it will be deleted the next<br />

time you upgrade <strong>Ensemble</strong>. Any new namespace that you create to hold your<br />

work is preserved across <strong>Ensemble</strong> upgrades.<br />

2. Choose File, then New. A dialog pops up. Edit it as follows:<br />

68 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


• Click on the General tab. Select the Caché Class Definition icon and click OK.<br />

• Enter a package and class name and click Next.<br />

<strong>HL7</strong> Search Tables<br />

Important:<br />

<strong>InterSystems</strong> recommends that you do not use the package names Demo,<br />

Ens, EnsLib, EnsPortal, or CSPX. This causes your work to be deleted the<br />

next time you upgrade <strong>Ensemble</strong>.<br />

• For Class type, choose Extends.<br />

• Beside the Name of super class field, click the Browse button. Choose the EnsLib package<br />

and under <strong>HL7</strong>, choose SearchTable. Click OK.<br />

• Click Finish.<br />

The result is a template class like the following:<br />

Class Susan.Test.NewClass2<br />

Extends EnsLib.<strong>HL7</strong>.SearchTable<br />

{<br />

}<br />

3. Position the cursor in the line between the curly brackets and select Class, then Add, then New<br />

XData. A dialog pops up.<br />

When prompted to enter a name, type:<br />

SearchSpec<br />

Click Finish. The result is a template XData SearchSpec block:<br />

Class Susan.Test.NewClass2<br />

Extends EnsLib.<strong>HL7</strong>.SearchTable<br />

{<br />

XData SearchSpec<br />

}<br />

{<br />

}<br />

4. Place an empty container inside the XData SearchSpec block:<br />

Class Susan.Test.NewClass2<br />

Extends EnsLib.<strong>HL7</strong>.SearchTable<br />

{<br />

XData SearchSpec<br />

}<br />

{<br />

<br />

<br />

}<br />

5. Now you may add entries inside the container.<br />

The XData SearchSpec block lists the virtual properties whose values you want users to be able to<br />

search.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 69


Elements of a Routing Production<br />

The following code excerpt shows the XData SearchSpec block that defines the entries in<br />

EnsLib.<strong>HL7</strong>.SearchTable. These are the entries described in the previous table, “Built-in Search Table<br />

Entries for <strong>HL7</strong>.” You do not need to repeat any of these entries in your search table subclass, because<br />

it inherits them from EnsLib.<strong>HL7</strong>.SearchTable:<br />

XData SearchSpec<br />

{<br />

<br />

{1:9.1}_"_"_{1:9.2}<br />

{1:10}<br />

[PID:2.1]<br />

[PID:3().1]<br />

[PID:4().1]<br />

[PID:5]<br />

[PID:18.1]<br />

<br />

}<br />

As you can see from the above example, an XData SearchSpec block contains one block,<br />

which may contain one or more elements. Each element contains a string expression,<br />

such as {1:10} in the above example. This string expression may include the following components<br />

in any combination:<br />

• Literal characters within double quotes.<br />

• Virtual property syntax within {} or []. This resolves to the value of the specified field in the <strong>HL7</strong><br />

message. Square brackets differ from curly brackets in that square brackets enclose a segment:field<br />

combination that does not require you to identify its containing message structure.<br />

• ObjectScript string operators, such as the underscore (_) for concatenation.<br />

• ObjectScript string functions, such as $PIECE or $EXTRACT.<br />

The following example consists of one virtual property path that uses {} syntax. This element<br />

refers to the value at Segment 1, Field 10 of the <strong>HL7</strong> message:<br />

<br />

{1:10}<br />

<br />

The following more complex element uses the ObjectScript _ operator to concatenate three<br />

strings. From left to right, these are:<br />

• The value within Segment 1, Field 4<br />

• A literal | character<br />

• The value within Segment 1, Field 3<br />

70 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Search Tables<br />

<br />

{1:4}_"|"_{1:3}<br />

<br />

The following example uses most of the possible syntax options: concatenation, virtual properties,<br />

a literal hyphen character (-), and the ObjectScript string function $PIECE:<br />

XData SearchSpec<br />

{<br />

<br />

<br />

$P(<br />

{ORCgrp(1).OBRuniongrp.OBRunion.OBR:UniversalServiceID.text},"-",1,2<br />

)_"-"_{MSH:12}<br />

<br />

}<br />

The element has the following attributes.<br />

Attributes for the Element in Search Tables<br />

Attribute<br />

DocType<br />

Description<br />

Required. A valid schema category name<br />

and message structure name, separated<br />

by a colon. If the category is missing, any<br />

schema is matched; if the structure is<br />

missing; any structure is matched. A value<br />

of "" (a blank string) matches any schema<br />

category and any message structure, as in<br />

the example above. For valid DocType<br />

strings, see “The DocType Property” in<br />

the “<strong>HL7</strong> Message Class” section of the<br />

chapter “Syntax for a Routing Production.”<br />

Value<br />

A string that includes any of<br />

the following combinations:<br />

• "category:structure"<br />

• "category:"<br />

• ":structure"<br />

• ""<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 71


Elements of a Routing Production<br />

Attribute<br />

PropName<br />

PropType<br />

Description<br />

Required. An arbitrary name that you wish<br />

to assign to this virtual property. This is the<br />

name that <strong>Ensemble</strong> will present for you to<br />

select from a list when configuring the<br />

Message Browser, Rules Editor, and other<br />

parts of the <strong>Ensemble</strong> Management Portal.<br />

If you assign the same PropName to different<br />

elements, this has an additive<br />

effect: When the user selects this<br />

PropName for a search, all of the entries<br />

with the same PropName are searched.<br />

The built-in search table entry PatientID<br />

uses this convention.<br />

Optional. All fields are assumed to be<br />

case-insensitive strings unless you specify<br />

a PropType value. If your data type is a<br />

case-insensitive string, you may omit<br />

PropType.<br />

Value<br />

Any string that you expect to<br />

be unique and meaningful,<br />

when viewed with others in<br />

the list.<br />

The PropType may be one of<br />

the following literal strings:<br />

• String:CaseSensitive<br />

• String:CaseInsensitive<br />

• Integer<br />

• Numeric<br />

• Boolean<br />

• DateTime:ODBC<br />

• DateTime:<strong>HL7</strong><br />

StoreNulls<br />

Optional. Controls what happens when a<br />

search encounters an empty field in the<br />

<strong>HL7</strong> message. If true, the search returns a<br />

valid pointer to an empty string. If false, it<br />

returns a Not Found status and a null<br />

pointer.<br />

A Boolean value: 1 (true) or 0<br />

(false).The default is 0 (false).<br />

The following sample search table class provides several examples of valid entries. This class<br />

inherits from EnsLib.<strong>HL7</strong>.SearchTable, as is required for <strong>HL7</strong> search tables. Comments above each<br />

group of entries describe the purpose of that set of entries. For details about {} or [] syntax,<br />

see the “Virtual Property Syntax” section in the chapter “Syntax for a Routing Production.”<br />

Class Demo.<strong>HL7</strong>.MsgRouter.SearchTable<br />

Extends EnsLib.<strong>HL7</strong>.SearchTable [ ClassType = persistent, ProcedureBlock ]<br />

{<br />

72 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Search Tables<br />

XData SearchSpec<br />

{<br />

<br />

<br />

{1:4}_"|"_{1:3}<br />

{1:6}_"|"_{1:5}<br />

{1:7}<br />

<br />

[PID:5]<br />

[IN1:4]<br />

<br />

{3:5}<br />

<br />

<br />

<br />

<br />

{ORCgrp().OBRuniongrp.OBRunion.OBR:UniversalServiceID.text}<br />

<br />

<br />

{PIDgrpgrp().ORCgrp(1).OBR:UniversalServiceID.text}<br />

<br />

<br />

}<br />

}<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 73


3<br />

Settings for a Routing Production<br />

This chapter explains the details of important configuration settings within an <strong>HL7</strong> message routing<br />

production. Topics include:<br />

• <strong>HL7</strong> Message Validation and Bad Messages<br />

• <strong>HL7</strong> Acknowledgement (ACK) Mode<br />

• <strong>HL7</strong> Dual Acknowledgement Sequences<br />

• <strong>HL7</strong> Message Framing Types<br />

• <strong>HL7</strong> Batch Messages<br />

• <strong>HL7</strong> Business Service Classes<br />

• <strong>HL7</strong> Business Operation Classes<br />

3.1 <strong>HL7</strong> Message Validation and Bad Messages<br />

When a routing process receives an incoming <strong>HL7</strong> message from its associated <strong>HL7</strong> business service,<br />

it may or may not perform message validation before attempting to route the message. This topic<br />

describes the cascading list of conventions that <strong>Ensemble</strong> uses to validate a message.<br />

• Any message that is labeled a bad message during this sequence is routed to a bad message handler<br />

rather than to its usual destination.<br />

• Any message that survives this cascade without being declared a bad message is validated. The<br />

routing process sends a validated message to its usual destination. This could happen even if the<br />

message is not perfect, as long as you disable certain tests. For example, frequently you want to<br />

allow messages with “extra” segments such as Z-segments.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 75


Settings for a Routing Production<br />

An <strong>HL7</strong> routing process has a configuration setting called Validation that controls the validation<br />

sequence. The following table lists the possible values for the Validation string:<br />

Values for the Validation Setting<br />

Value<br />

dm-z<br />

1<br />

(a blank string)<br />

Other combinations of<br />

the flags d, m, z, or –z<br />

Meaning<br />

This is the default setting. See the discussions of d, m, and z.<br />

Same as dm-z, for backward compatibility with previous<br />

releases.<br />

The routing process skips validation and routes all messages.<br />

Enables or disables various steps in the validation cascade.<br />

The flags may appear in any combination, except that z and<br />

–z are mutually exclusive, and m includes z, so m is the same<br />

as mz.<br />

The message validation sequence is as follows. If a flag is not present in the string, its associated step<br />

is disabled:<br />

1. Test for issues controlled by d (if present).<br />

2. Test for issues controlled by m (if present). Exclude issues controlled by z (if –z is present).<br />

3. Test for issues controlled by z (if z is present without m).<br />

If at any time during this cascade the message fails validation, the <strong>HL7</strong> routing process passes the<br />

message to its bad message handler (if present). If there is no bad message handler, the routing process<br />

simply stops the validation sequence without routing the message. On the other hand, any message<br />

that does not explicitly fail validation is allowed through. You can use the various options to control<br />

how many tests you want applied by each <strong>HL7</strong> routing process.<br />

3.1.1 The d Validation Flag<br />

If the d flag is present in the Validation string, validation examines the Message Schema Category<br />

defined in the <strong>HL7</strong> business service and compares it with the message DocType. If the Message Schema<br />

Category in the business service configuration is blank, the message is automatically declared bad.<br />

However, if Message Schema Category is not blank, but does not match the message DocType, validation<br />

can continue, as long as there are more Validation flags defined, such as m or z.<br />

3.1.2 The m Validation Flag<br />

If the m flag is present in the Validation string, validation searches for a way to either validate the<br />

message, or declare it bad, by cascading through the following tests:<br />

76 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


1. In the DTL data transformation, the element has a sourceDocType attribute. If different<br />

from the Message Schema Category setting, the sourceDocType is used.<br />

2. If Message Schema Category is a standard category such as 2.3.1, the inbound message MSH:9<br />

value is matched against a message type defined in that <strong>HL7</strong> Category. For example, if the Message<br />

Schema Category is 2.3.1 and the MSH:9 value in the message is ORU;R01 the message is verified<br />

against the ORU_R01 message type under the 2.3.1 category. If the message data is missing some<br />

required segments or fields, or if it has extra undefined segments or fields, as compared to the<br />

2.3.1 ORU_R01, then it is a bad message. Z segments may be an exception, depending on the<br />

presence or absence of the m, z, or -z flags.<br />

3. If the Message Schema Category is a custom schema (defined in Studio with a .<strong>HL7</strong> extension),<br />

the same rules apply as in Step 4, except that the message is verified against the custom definition.<br />

Each custom schema has a base category defined (for example base="2.3.1"). If a message<br />

arrives that is not explicitly defined in the custom schema, the base category is used.<br />

In order to avoid a specious bad message condition, a custom schema is necessary when MSH:9<br />

does not contain a standard value. For example, if MSH 9 is just ORU instead of ORU^R01 a custom<br />

schema is required to specify that the message name ORU needs to be verified against the structure<br />

ORU_R01.<br />

The m flag also performs all the validation performed as a result of the z flag, unless the -z flag is<br />

present to stop this. Thus, m is the same as mz, and dm is the same as dmz. For example, the default<br />

Validation setting is dm-z, which includes d and m but excludes the validation indicated by z.<br />

3.1.3 The z Validation Flag<br />

<strong>HL7</strong> Message Validation and Bad Messages<br />

If the z flag is present in the Validation string, or if the m flag is present without the -z flag, there may<br />

be error conditions relating to extra segments found in an incoming message. “Extra” segments are<br />

segments within the message data that parse reasonably well as <strong>HL7</strong> message segments, but do not<br />

match the structure of the message as defined in the schema. These may be Z segments, or non-Z<br />

segments. <strong>Ensemble</strong> determines whether or not to declare bad message status based on extra segments<br />

as follows:<br />

• If the message contains extra Z segments, and the schema defines those Z segments, the message<br />

is accepted.<br />

• If the message contains extra trailing Z segments when the schema does not define any Z segments,<br />

the message is accepted. However, extra Z segments in the middle of the message are not accepted.<br />

• If the message contains extra Z segments, and the schema defines Z segments, but the Z segments<br />

found in the message do not match the Z segments defined in the schema, it is a bad message.<br />

• If the message contains extra non-Z segments, then regardless of Z segments, it is a bad message.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 77


Settings for a Routing Production<br />

3.1.4 Bad Message Handlers<br />

If the message is bad, and if the <strong>HL7</strong> routing process has a configured Bad Message Handler, it sends<br />

the bad message to this business operation instead of its usual target for validated messages.<br />

For example, the starter <strong>HL7</strong> message routing production is configured with a file business operation<br />

called BadMessageHandler. When this business operation is configured as the Bad Message Handler<br />

for an <strong>HL7</strong> routing process, the BadMessageHandler handles any bad messages it receives as follows:<br />

• It writes the contents of the message to the output File Path and File Name defined in its configuration<br />

settings. The File Name can include time stamp specifiers. For details, see the section “Time<br />

Stamps in Filenames” in the “Creating a New Production” chapter of Developing <strong>Ensemble</strong><br />

Productions.<br />

• If the configuration setting Alert On Error is True, the business operation automatically triggers<br />

an alert whenever it encounters a bad message.<br />

3.1.5 Overriding the Validation Sequence<br />

The normal range of Validation options might not provide the type of validation that you need. If this<br />

is the case, you can subclass EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine and override the OnValidate<br />

method in the subclass. Then, when adding a routing process, choose the subclass as your base class<br />

rather than the default EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine.<br />

Subclassing EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine to override OnValidate allows you to:<br />

• Extend or replace the list of accepted values for the Validation setting.<br />

• Determine how the routing process will validate messages, as controlled by your own Validation<br />

options.<br />

Whenever you override the OnValidate method, you must also override the Validation property definition<br />

in the same subclass. Pay careful attention to the following details:<br />

• Its InitialExpression value. This sets the default for the Validation configuration setting.<br />

• The comments that precede the Validation property definition. Use the /// convention and leave<br />

no white space lines between the last comment line and the property definition. This allows<br />

<strong>Ensemble</strong> Management Portal users to view your comments as hover-text help for the Validation<br />

setting.<br />

As an example, the following excerpt shows some of the comments that appear with the Validation<br />

property definition in the EnsLib.<strong>HL7</strong>.MsgRouter.RoutingEngine class:<br />

78 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Acknowledgement (ACK) Mode<br />

/// 'd' - require DocType<br />

/// 'm' - don't tolerate BuildMap errors (includes 'z' by default;<br />

/// specify '-z' to tolerate unrecognized trailing Z-segments)<br />

/// 'z' - don't tolerate unrecognized trailing Z-segments<br />

Property Validation As %String(MAXLEN = 20)<br />

[ InitialExpression = "dm-z", Transient ];<br />

3.2 <strong>HL7</strong> Acknowledgement (ACK) Mode<br />

An <strong>HL7</strong> acknowledgement (ACK) message acknowledges that a destination has received an <strong>HL7</strong><br />

message. A negative ACK (NACK) message acknowledges that the destination is aware of the transmission<br />

but did not capture the message.<br />

The following figure illustrates how <strong>Ensemble</strong> upholds <strong>HL7</strong> message conventions for sending of ACK<br />

and NACK messages:<br />

• Commit ACK — The <strong>Ensemble</strong> business service returns an ACK to the source application as<br />

soon as it commits the transaction that saves the data received from that source. It sends a NACK<br />

if this proves impossible for some reason. The <strong>Ensemble</strong> business operation may be set up to<br />

interpret an ACK or NACK from the target application, but it does not return those messages to<br />

the source.<br />

• Application ACK — The <strong>Ensemble</strong> business service does not send an ACK or NACK to the<br />

source application until one returns from the target application by way of the <strong>Ensemble</strong> business<br />

operation. The business service returns the ACK or NACK that it receives from the business<br />

operation.<br />

• Commit and Application ACK — Both of the above. The <strong>Ensemble</strong> business service returns an<br />

ACK upon transaction commit. It also subsequently returns the ACK or NACK that the <strong>Ensemble</strong><br />

business operation returns from the target application.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 79


Settings for a Routing Production<br />

<strong>HL7</strong> Message Acknowledgement (ACK) Types<br />

Any of these acknowledgement conventions can be used to send one of the three main types of ACK<br />

message content:<br />

• Accept — The message arrived, and was accepted.<br />

• Reject — The message arrived, but has been rejected.<br />

• Error — The message did not arrive successfully; try again.<br />

80 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Acknowledgement (ACK) Mode<br />

3.2.1 The AckMode Setting<br />

<strong>HL7</strong> business services have an AckMode setting that can have one of the following values.<br />

Acknowledgement (ACK) Modes for <strong>HL7</strong> Business Services<br />

AckMode<br />

Never<br />

Immediate<br />

Application<br />

MSH-determined<br />

Meaning<br />

Do not send back any ACK.<br />

Return a Commit ACK reply message immediately upon receipt of<br />

the inbound message. This is the default if nothing is specified.<br />

If message passes validation, wait for the ACK reply message from<br />

the target application and return this ACK when it arrives.<br />

Return ACK reply messages as requested in the MSH header fields<br />

15 and 16. Either field may contain one of the following four control<br />

codes:<br />

• AL — Always<br />

• NE — Never<br />

• ER — Error or reject conditions only<br />

• SU — Successful completion only<br />

MSH 15 (AcceptAcknowledgementType) controls Commit ACK. MSH<br />

16 (ApplicationAcknowledgementType) controls Application ACK.<br />

Depending on how they are set in the incoming message MSH segment,<br />

one, both or neither may occur.<br />

Byte<br />

Send back a single ACK-code byte instead of an ACK message,<br />

immediately upon receipt of the inbound message. ASCII 6 means<br />

OK; ASCII 21 means Error. This option is not available for any of the<br />

built-in <strong>HL7</strong> business services (TCP, File, HTTP, and so on) but it is<br />

available if you write a custom business service that subclasses<br />

EnsLib.<strong>HL7</strong>.Service.Standard without overriding the AckMode setting.<br />

3.2.2 The UseAckCommitCodes Setting<br />

<strong>HL7</strong> business services have a UseAckCommitCodes setting that applies if the Message Schema Category<br />

is 2.3 or higher. UseAckCommitCodes may be True or False. If True, when constructing an ACK<br />

message for <strong>HL7</strong> messages version 2.3 or higher, the business service places one of the “enhanced-<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 81


Settings for a Routing Production<br />

mode” ACK commit codes in the MSA segment AcknowledgmentCode field. This code may be one<br />

of the following two-letter sequences:<br />

Enhanced-Mode ACK Commit Codes for <strong>HL7</strong> 2.3 and Higher<br />

Code<br />

AA<br />

AE<br />

AR<br />

CA<br />

CE<br />

CR<br />

Meaning in Original Mode<br />

Application Accept<br />

Application Error<br />

Application Reject<br />

—<br />

—<br />

—<br />

Meaning in Enhanced Mode<br />

Application acknowledgment: Accept<br />

Application acknowledgment: Error<br />

Application acknowledgment: Reject<br />

Accept acknowledgment: Commit Accept<br />

Accept acknowledgment: Commit Error<br />

Accept acknowledgment: Commit Reject<br />

3.2.3 The IgnoreInboundAck Setting<br />

Setting IgnoreInboundAck to True causes a business service to ignore any inbound ACK messages to<br />

avoid creating an ACK feedback loop.<br />

3.2.4 The AckTargetConfigNames Setting<br />

Unlike TCP business services, File and FTP business services have no persistent connection on which<br />

to send ACK messages. For this reason, the default AckMode for File and FTP business services is<br />

Never, which is usually appropriate. However, when you do want to send ACKs from a File or FTP<br />

business service, use the AckTargetConfigNames setting to identify an <strong>Ensemble</strong> routing process or<br />

business operation that will receive the ACK messages.<br />

3.2.5 The GetReply Setting<br />

For TCP business operations only, if the adapter setting GetReply setting is True, the business operation<br />

waits to read an ACK or other reply message back from the socket before returning. It also applies<br />

any ReplyCodeActions that have been defined.<br />

3.2.6 The ReplyCodeActions Setting<br />

For TCP business operations only, if the adapter setting Get Reply is True, ReplyCodeActions allows<br />

you to supply a comma-separated list of code-action pairs, specifying which action the business operation<br />

will take on receipt of various types of response messages. The format of the list is:<br />

code=action,code=action, ... code=action<br />

82 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Where code represents a literal value found in the MSA:1 (Acknowledgement Code) field of the<br />

response message, or one of the following special code values:<br />

Code Values for Reply Code Actions<br />

<strong>HL7</strong> Acknowledgement (ACK) Mode<br />

Code<br />

A<br />

E<br />

R<br />

~<br />

_<br />

*<br />

I<br />

T<br />

Meaning<br />

Matches AA or CA values (Accept)<br />

Matches AE or CE values (Error)<br />

Matches AR or CR values (Reject)<br />

The tilde character matches replies that do not contain an MSA segment<br />

The underscore character matches replies with an empty MSA:1 field. An empty<br />

or whitespace code value is the same as _<br />

The asterisk character matches any MSA:1 value not matched otherwise<br />

(default=F)<br />

Matches where the reply MSA:2 ControlId does not match the ControlId of the<br />

original message<br />

Matches where the reply MSH:9 Type name does not match the schema’s<br />

declared reply type for the original message<br />

The following values for action may be used alone or combined to form strings. F is the default action<br />

if no other is given, except for A whose default action is C:<br />

Action Values for Reply Code Actions<br />

Action<br />

C<br />

W<br />

R<br />

S<br />

D<br />

F<br />

Meaning<br />

Treat the message as Completed OK.<br />

Log a warning but treat the message as Completed OK.<br />

Retry the message according to the configured RetryInterval and<br />

FailureTimeout; finally Fail unless a different action is also specified<br />

Suspend the message, log an error, and move on to try the next message<br />

Disable the Operation, log an error and restore the outbound message to the<br />

front of the Operation’s queue<br />

Fail with an error and move on to try the next message<br />

The default value for ReplyCodeActions is:<br />

R=RF,E=S,~=S,I=W,T=C<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 83


Settings for a Routing Production<br />

This means that NACKs received with error code AR or CR retry, while codes AE or CE suspend the<br />

outbound message and move on to the next.<br />

3.2.7 The AddNackERR Setting<br />

If the AddNackERR setting is True, add ERR error code segment when generating NACK messages;<br />

otherwise do not embed internal error state information in NACK messages.<br />

3.3 <strong>HL7</strong> Dual Acknowledgement Sequences<br />

Some systems require a dual acknowledgement sequence from <strong>Ensemble</strong>: an immediate 1–byte ACK,<br />

followed later by the full ACK message. One such system is the dual-channel iSoft iCM application.<br />

If your configuration includes a client system such as iCM that requires a dual acknowledgement<br />

sequence, you must set up a paired business service and business operation to enable <strong>Ensemble</strong> to<br />

provide the expected ACKs. <strong>Ensemble</strong> supports a dual acknowledgement sequence over TCP and<br />

HTTP.<br />

EnsLib.<strong>HL7</strong>.Service.TCPAckInService is a specialized <strong>HL7</strong> business service that receives ACKs on<br />

behalf of a paired <strong>HL7</strong> TCP business operation. It also depends on this partner to send ACKs on its<br />

behalf. EnsLib.<strong>HL7</strong>.Operation.TCPAckOutOperation is a specialized <strong>HL7</strong> TCP business operation that<br />

sends out ACKs on behalf of a paired <strong>HL7</strong> TCP business service. It also depends on this partner to<br />

collect ACKs on its behalf. Each of these configuration items plays its usual role in addition to the<br />

work it does for its partner item.<br />

An EnsLib.<strong>HL7</strong>.Service.HTTPAckInService and EnsLib.<strong>HL7</strong>.Operation.HTTPAckOutOperation are also<br />

available.<br />

3.3.1 Dual ACK Sequence for Incoming Messages<br />

For messages entering <strong>Ensemble</strong>, the dual acknowledgement sequence works as shown in the following<br />

figure:<br />

1. The client application sends a message into <strong>Ensemble</strong>.<br />

2. The inbound ACK business service sends an immediate 1–byte ACK to the client application.<br />

3. The inbound ACK business service sends the message to its routing process.<br />

4. The routing process routes the message to its target via a business operation.<br />

5. The target application returns an ACK message to the business operation.<br />

6. <strong>Ensemble</strong> relays the ACK to the inbound ACK business service.<br />

7. The business service relays the ACK to its paired business operation.<br />

84 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Dual Acknowledgement Sequences<br />

8. The business operation relays the ACK to the client application.<br />

9. The client application acknowledges the ACK message by returning a 1–byte ACK.<br />

Paired Business Service and Business Operation for Incoming Dual ACK<br />

3.3.2 Dual ACK Sequence for Outgoing Messages<br />

For messages leaving <strong>Ensemble</strong>, the dual acknowledgement sequence works as shown in the following<br />

figure:<br />

1. A business service sends a message to its routing process.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 85


Settings for a Routing Production<br />

2. The routing process routes the message to the outbound ACK business operation.<br />

3. The outbound ACK business operation relays the message to the target application.<br />

4. The target application acknowledges the message by returning a 1–byte ACK.<br />

5. The target application returns an ACK message to the inbound ACK business service.<br />

6. The business service sends an immediate 1–byte ACK to the target application.<br />

7. The business service relays the ACK to its paired business operation.<br />

8. The business operation relays the ACK message back to the business service.<br />

9. The business service receives the ACK to its original message.<br />

86 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Dual Acknowledgement Sequences<br />

Paired Business Service and Business Operation for Outgoing Dual ACK<br />

3.3.3 Configuring a Dual ACK Sequence<br />

To configure an <strong>Ensemble</strong> routing production to use the dual acknowledgement feature:<br />

1. Add a business service to the production.<br />

Choose EnsLib.<strong>HL7</strong>.Service.TCPAckInService or EnsLib.<strong>HL7</strong>.Service.HTTPAckInService as the<br />

business service class. It is not one of the standard <strong>HL7</strong> Input options available from the Business<br />

Service Wizard, but you can choose it by selecting the Other option and identifying the class.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 87


Settings for a Routing Production<br />

2. Add a business operation to the production.<br />

Choose EnsLib.<strong>HL7</strong>.Operation.TCPAckOutOperation or EnsLib.<strong>HL7</strong>.Service.HTTPAckOutOperation<br />

as the business operation class. It is not one of the standard <strong>HL7</strong> Output options available from the<br />

Business Operation Wizard, but you can choose it by selecting the Other option and identifying<br />

the class.<br />

3. When configuring the business service:<br />

• Set ImmediateByteAck to True. Then, in addition to forwarding a full ACK message according<br />

to the AckMode setting, the business service also returns an immediate 1-byte ACK on its<br />

TCP or HTTP connection.<br />

• For a PartnerOperation choose the business operation that you added in Step 2. Whenever<br />

you specify a PartnerOperation value, the business service ignores any inbound ACK messages<br />

that it receives directly, to avoid creating an ACK feedback loop.<br />

4. When configuring the business operation:<br />

• Identify a PartnerAckTimeout. This value tells the business operation the number of seconds<br />

to wait for its partner business service to supply an ACK that corresponds to the normal outbound<br />

message that the business operation sent. The default PartnerAckTimeout is 600 seconds<br />

(10 minutes).<br />

3.4 <strong>HL7</strong> Message Framing Types<br />

Framing controls the kind of wrapper packets used to transport <strong>HL7</strong> messages. The <strong>HL7</strong> business<br />

services and business operations each have a configurable Framing setting. On the inbound side, it<br />

controls how the <strong>HL7</strong> business service interprets the incoming <strong>HL7</strong> message packet; on the outbound<br />

side, it controls how the <strong>HL7</strong> business operation constructs the outgoing <strong>HL7</strong> message packet. The<br />

following table lists the valid Framing values. If you are unsure what value to use, accept the defaults:<br />

• Flexible for <strong>HL7</strong> business services<br />

• MLLP for <strong>HL7</strong> business operations<br />

Note:<br />

ASCII values must be given as numeric values when you enter them in Framing fields. ASCII<br />

120 followed by some other ASCII character value is not allowed as an ASCII framing convention.<br />

88 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Framing Types for <strong>HL7</strong> Business Operations and Business Services<br />

<strong>HL7</strong> Message Framing Types<br />

Framing Type<br />

Flexible<br />

None<br />

XML<br />

MLLP<br />

MLLP[nn]/[mm]<br />

AsciiLF<br />

AsciiCR<br />

Ascii[nn]<br />

Ascii[nn]/[mm]<br />

LLP<br />

Meaning<br />

Flexible framing means the service will accept messages using<br />

any kind of framing and will use the same framing style when<br />

replying with an ACK message. Flexible framing is not available<br />

for business operations. MLLP is the default for operations.<br />

No framing. Each line that begins with the string MSH is the start<br />

of a new message<br />

An XML envelope wraps each <strong>HL7</strong> message. is<br />

added as a final wrapper tag if the message’s Envelope property<br />

contains none.<br />

Minimal Lower Level Protocol. Frame each <strong>HL7</strong> message with<br />

an ASCII 11 prefix and a suffix that consists ASCII 28 followed<br />

by ASCII 13.<br />

Minimal Lower Level Protocol using non-standard ASCII values.<br />

Frame each <strong>HL7</strong> message with a prefix that consists of the<br />

ASCII character value indicated by nn. Also provide a suffix that<br />

consists of the ASCII character value indicated by mm, followed<br />

by ASCII 13, the carriage return character.<br />

Frame messages with no MLLP, with ASCII 10, the line feed<br />

character, separating each message from the subsequent one.<br />

Frame messages with no MLLP, with an extra ASCII 13, the<br />

carriage return character, separating each message from the<br />

subsequent one.<br />

Frame messages with no MLLP, with a suffix separating each<br />

message from the subsequent one. This suffix consists of the<br />

ASCII character value indicated by nn.<br />

Frame messages with no MLLP, with a prefix character before<br />

each message.This suffix consists of the ASCII character value<br />

indicated by nn. Also provide a suffix that consists of the ASCII<br />

character value indicated by mm, but with no trailing ASCII 13.<br />

Lower Level Protocol. Frame each <strong>HL7</strong> message in a redundant<br />

checksum block.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 89


Settings for a Routing Production<br />

Framing Type<br />

<br />

<br />

MsgEnvelope<br />

MLLPXML<br />

MLLP<br />

MLLP<br />

MLLPMsgEnvelope<br />

Meaning<br />

Use this literal XML envelope to wrap each <strong>HL7</strong> message. The<br />

string if present in the block<br />

will be replaced with the message content. Otherwise the<br />

message will simply follow the envelope text and appropriate<br />

closing tags will be added, if the envelope contains open tags.<br />

An XML envelope wraps each <strong>HL7</strong> message. is<br />

added as a final wrapper tag if the message’s Envelope property<br />

contains none<br />

Use the message’s Envelope property verbatim if it is present.<br />

The string if present in the envelope will be<br />

replaced with the Message content. Otherwise the Message<br />

will simply follow the envelope text<br />

Same as XML, but with an MLLP prefix and suffix also around<br />

the message inside the envelope.<br />

Same as , but with an MLLP prefix and suffix<br />

also around the message inside the envelope.<br />

Same as , but with an MLLP prefix and suffix also<br />

around the message inside the envelope.<br />

Same as MsgEnvelope, but with an MLLP prefix and suffix also<br />

around the message inside the envelope.<br />

When the framing type is MLLP, <strong>Ensemble</strong> automatically detects extra carriage returns (ASCII 13)<br />

that occur in the message before the close framing. This indicates to <strong>Ensemble</strong> that a blank line is not<br />

being used to separate messages, so it assumes that any blank line is part of the message content and<br />

can be safely ignored.<br />

3.5 <strong>HL7</strong> Batch Messages<br />

<strong>Ensemble</strong> supports nested child documents in <strong>HL7</strong>. Each of the child documents is an <strong>Ensemble</strong> virtual<br />

document in its own right. <strong>Ensemble</strong> supports the following <strong>HL7</strong> batch formats:<br />

• BHS MSH ... MSH ... BTS<br />

<strong>Ensemble</strong> recognizes BHS as a batch header segment, and BTS as a batch trailer segment. Within<br />

this container, <strong>Ensemble</strong> recognizes each MSH message header segment as the beginning of a<br />

child document.<br />

90 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Batch Messages<br />

• FHS MSH ... MSH ... FTS<br />

<strong>Ensemble</strong> recognizes FHS as a batch header segment, and FTS as a batch trailer segment. Within<br />

this container, <strong>Ensemble</strong> recognizes each MSH message header segment as the beginning of a<br />

child document.<br />

• FHS BHS MSH ... MSH ... BTS BHS MSH ... MSH ... BTS FTS<br />

When FHS and BHS begin the message together, <strong>Ensemble</strong> recognizes FHS as the first-level<br />

parent document and each BHS as the beginning of a child document. BHS then becomes a secondlevel<br />

parent and the contents following each MSH segment become its child documents.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 91


Settings for a Routing Production<br />

Parent and Child Documents in <strong>HL7</strong> Batch Messages<br />

There are two production settings that control <strong>HL7</strong> batch processing. On the incoming side, <strong>HL7</strong><br />

business services have a Batch Handling configuration setting that determines how to process incoming<br />

batch documents. The options are:<br />

92 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


• Whole Batch — Do not process child documents individually; accumulate and send the whole<br />

batch as one composite document.<br />

• Single-Session Batch — Forward all child documents in the batch together in one session;<br />

the session includes objects representing the batch headers and trailers. Single-Session<br />

Batch is the default if no Batch Handling value is specified.<br />

• Multi-Session Batch — Forward each child document in the batch in its own session, with<br />

a unique session ID.<br />

• Individual — Forward each child document in the batch in its own session; do not forward<br />

objects representing the batch headers and trailers.<br />

In responding to received messages, the default behavior is to send an acknowledgement to the sender<br />

as a batch document that contains an ACK message for each child document. This works for most<br />

situations. However, <strong>HL7</strong> business services also have a property, not exposed as a configuration setting,<br />

called NoBatchReply. Its default value is 0 (false), which provides the default behavior. If you edit<br />

your business service’s OnInit method to include this statement:<br />

Set ..Adapter.NoBatchReply = 1<br />

<strong>HL7</strong> Batch Messages<br />

Then batch replies are inhibited; each individual message gets a separate un-wrapped ACK.<br />

On the outgoing side, <strong>HL7</strong> business operations have a AutoBatchParentSegs configuration setting.<br />

When AutoBatchParentSegs is False (the default) the business operation outputs child documents, but<br />

does not output the batch headers and trailers. When AutoBatchParentSegs is True, while outputting<br />

a message that has a batch parent, the business operation outputs the batch headers first, then the child<br />

documents, then follows up with the batch trailers when triggered by the final batch header message<br />

or by a file name change.<br />

The combination of Batch Handling and AutoBatchParentSegs enables the following modes of operation<br />

for <strong>HL7</strong> batch documents. The ABPS column indicates values of AutoBatchParentSegs. Any combination<br />

of values not shown in this table is invalid.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 93


Settings for a Routing Production<br />

<strong>HL7</strong> Batch Message Handling Options<br />

Batch Handling<br />

Whole Batch<br />

Single-Session<br />

or<br />

Multi-Session<br />

Single-Session<br />

or<br />

Multi-Session<br />

Individual<br />

ABPS<br />

(any)<br />

True<br />

False<br />

False<br />

Results<br />

Business service sends only the parent document; all<br />

child documents are referenced to it but not sent<br />

individually. Operation outputs entire batch at one time<br />

when it receives the parent document.<br />

Service sends each child document as it receives and<br />

parses it, followed by the parent document when all<br />

children have been sent.The business operation outputs<br />

parent headers when it receives the first child document,<br />

then finishes up with trailers when it receives the parent<br />

document object. Trailer segments automatically contain<br />

the correct child count values.<br />

This results in double output: the business operation<br />

sends out each child document individually, followed by<br />

the parent document containing each child document<br />

(again).<br />

Business service forwards each child document in the<br />

batch in its own session and does not forward objects<br />

representing the batch headers and trailers. On the<br />

outgoing side, the business operation does the same.<br />

If you wish to add custom code to your routing process to handle batch documents specially on the<br />

output side, you can do so. The following are two possibilities:<br />

• Your routing process code constructs new parent and child documents and links them, then sends<br />

each child to the business operation. The business operation must have AutoBatchParentSegs set<br />

to True. The business operation outputs parent headers when it receives the first child document,<br />

then finishes up with trailers when it receives the parent document object. Trailer segments automatically<br />

contain the correct child count values.<br />

• Your routing process code constructs new parent and child documents and links them, but sends<br />

only the parent object via the business operation.<br />

94 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


3.6 <strong>HL7</strong> Business Service Classes<br />

<strong>HL7</strong> Business Service Classes<br />

<strong>Ensemble</strong> provides external connectivity via built-in adapters for the major technologies used to<br />

exchange <strong>HL7</strong> messages: FTP, TCP, HTTP, and File. Documentation for the FTP, TCP, HTTP, and<br />

File inbound adapters advises you to write a business service that invokes the adapter. This is not<br />

necessary for <strong>HL7</strong> <strong>Version</strong> 2 message routing productions. <strong>HL7</strong> poses complex message parsing issues<br />

that go beyond simple connectivity. For this reason, <strong>Ensemble</strong> provides built-in <strong>HL7</strong> business services<br />

that parse <strong>HL7</strong> messages in a consistent manner. This way, you do not need to write your own business<br />

service code.<br />

The following diagram shows the inheritance tree for the built-in <strong>HL7</strong> business service classes. This<br />

tree indicates which configuration settings you should expect to be available in the [<strong>Ensemble</strong>] ><br />

[Productions] configuration diagram for each business service. The list of settings is cumulative, so<br />

for the EnsLib.<strong>HL7</strong>.Service.FTPService the settings are AlertOnError, ArchiveIO, AlertGracePeriod,<br />

TargetConfigNames, SearchTableClass, LocalFacilityApplication, Framing, AckMode, UseAckCommitCodes,<br />

IgnoreInboundAck, AddNackERR, BatchHandling, MessageSchemaCategory,<br />

DefCharEncoding, and AckTargetConfigNames.<br />

For detailed configuration instructions, see the “<strong>HL7</strong> Business Services” section in the chapter<br />

“Elements of a Routing Production.”<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 95


Settings for a Routing Production<br />

<strong>HL7</strong> Business Service Class Hierarchy, Showing Inheritance of Settings<br />

96 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


3.7 <strong>HL7</strong> Business Operation Classes<br />

<strong>HL7</strong> Business Operation Classes<br />

<strong>Ensemble</strong> provides external connectivity via built-in adapters for the major technologies used to<br />

exchange <strong>HL7</strong> messages: FTP, TCP, HTTP, and File. Documentation for the FTP, TCP, HTTP, and<br />

File outbound adapters advises you to write a business operation that invokes the adapter. This is not<br />

necessary for <strong>HL7</strong> <strong>Version</strong> 2 message routing productions. <strong>HL7</strong> poses complex message parsing issues<br />

that go beyond simple connectivity. For this reason, <strong>Ensemble</strong> provides built-in <strong>HL7</strong> business operations<br />

that construct <strong>HL7</strong> messages in a consistent manner. This way, you do not need to write your own<br />

business operation code.<br />

The following diagram shows the inheritance tree for the built-in <strong>HL7</strong> business operation classes. This<br />

tree indicates which configuration settings you should expect to be available in the [<strong>Ensemble</strong>] ><br />

[Productions] configuration diagram for each business operation. The list of settings is cumulative, so<br />

for the EnsLib.<strong>HL7</strong>.Operation.FTPOperation the settings are AlertOnError, ArchiveIO, AlertRetryGracePeriod,<br />

RetryInterval, FailureTimeout, Framing, Separators, SearchTableClass, DefCharEncoding,<br />

Filename, and AutoBatchParentSegs.<br />

For detailed configuration instructions, see the “<strong>HL7</strong> Business Operations” section in the chapter<br />

“Elements of a Routing Production.”<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 97


Settings for a Routing Production<br />

<strong>HL7</strong> Business Operation Class Hierarchy, Showing Inheritance of Settings<br />

98 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


4<br />

Syntax for a Routing Production<br />

This chapter describes the programming and syntax details that support <strong>HL7</strong> <strong>Version</strong> 2 routing productions.<br />

Topics include:<br />

• <strong>HL7</strong> Message Class<br />

• Virtual Property Syntax<br />

• Literal String Syntax<br />

• Schema Category Syntax<br />

4.1 <strong>HL7</strong> Message Class<br />

<strong>Ensemble</strong> provides a built-in class for <strong>HL7</strong> <strong>Version</strong> 2 virtual documents. The class is<br />

EnsLib.<strong>HL7</strong>.Message. You do not need to change anything to make this class work with a particular<br />

<strong>HL7</strong> <strong>Version</strong> 2 schema or even to make it work with custom <strong>HL7</strong> message types.<br />

The following figure illustrates how EnsLib.<strong>HL7</strong>.Message inherits its virtual document features from<br />

other classes. While the figure does not list all the properties and methods in the class, it highlights<br />

those you most need to understand in order to work with <strong>HL7</strong> messages. These are the properties and<br />

methods that allow you to efficiently handle <strong>HL7</strong> <strong>Version</strong> 2 data within an <strong>Ensemble</strong> production. These<br />

include the class properties DocType, TypeCategory, BuildMapStatus, and Name. To refer to these<br />

properties from statements in BPL, DTL, routing rules, Caché Basic, or ObjectScript, use ordinary dot<br />

syntax, as in:<br />

<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 99


Syntax for a Routing Production<br />

<strong>HL7</strong> Message Class Overview Showing Inheritance<br />

4.1.1 The DocType Property<br />

The DocType property is the document type, a string in two parts separated by a colon:<br />

category:structure<br />

Where:<br />

• category is the name of a schema category. This means that category must be the same as a<br />

name expressed in some schema category as follows:<br />

<br />

100 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


• structure is the name of a message structure within the referenced category. This means that<br />

structure must be the same as a name expressed somewhere inside the<br />

context as:<br />

<br />

<strong>HL7</strong> Message Class<br />

For example:<br />

2.3.1:ORM_O01<br />

2.4:ORD_O04<br />

myCustomCategory:MFN_M03<br />

When using <strong>HL7</strong> with <strong>Ensemble</strong>, you must supply document type values, using the syntax described<br />

in this topic, for the following items:<br />

• The DocType property of an <strong>HL7</strong> message<br />

• The sourceDocType attribute of a DTL element<br />

• The targetDocType attribute of a DTL element<br />

• Source Doc Type in the Studio data transformation wizard<br />

• Target Doc Type in the Studio data transformation wizard<br />

• Message Type or DocType in the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [EDI Document Viewer]<br />

page<br />

Tip:<br />

To browse examples of category:structure combinations, use “The Schema Structures Page”<br />

as described in the chapter “Viewing and Transforming Messages.”<br />

4.1.2 The TypeCategory Property<br />

The TypeCategory property contains an <strong>HL7</strong> category name. Typically, the <strong>HL7</strong> business service that<br />

receives <strong>HL7</strong> data from outside <strong>Ensemble</strong> instantiates an <strong>HL7</strong> message and assigns a TypeCategory<br />

value to it. <strong>Ensemble</strong> combines this TypeCategory with the message type declared in the MSH segment<br />

of the incoming message data; this combination identifies a within the <strong>HL7</strong> schema<br />

definition. This has an associated that <strong>Ensemble</strong> uses as the<br />

DocType for the <strong>HL7</strong> message, if no other DocType is assigned.<br />

4.1.3 The BuildMapStatus Property<br />

The BuildMapStatus property contains a %Status value that indicates the success or failure of the most<br />

recent effort to map the raw content of an <strong>HL7</strong> message to a particular DocType. You can test<br />

BuildMapStatus in code as follows:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 101


Syntax for a Routing Production<br />

• Use the macro $$$ISOK(my<strong>HL7</strong>Message.BuildMapStatus) in ObjectScript and the method<br />

$SYSTEM.Status.IsOK(my<strong>HL7</strong>Message.BuildMapStatus) in Basic. If the test returns<br />

a True value, BuildMapStatus contains a success value.<br />

• Use the macro $$$ISERR(my<strong>HL7</strong>Message.BuildMapStatus) in ObjectScript and the method<br />

$system.Status.IsError(my<strong>HL7</strong>Message.BuildMapStatus) in Basic. If the test returns<br />

a True value, BuildMapStatus contains a failure value.<br />

You can view details of any BuildMapStatus failure codes using “The Schema Structures Page” as<br />

described in the chapter “Viewing and Transforming Messages.”<br />

4.1.4 The Name Property<br />

The Name property is a read-only string that contains the <strong>HL7</strong> message structure name (such as<br />

ADT_A08 or ORM_O02) that the external data source has provided in the MSH segment. The Name<br />

can be useful in determining the <strong>HL7</strong> message structure that the clinical application thinks that it is<br />

sending, although this can differ from the actual message contents.<br />

4.1.5 The RawContent Property<br />

The RawContent property contains the 32 kilobytes of raw <strong>HL7</strong> message data that came to <strong>Ensemble</strong><br />

from an external source via an <strong>HL7</strong> business service. The RawContent property is not indexed in any<br />

way, and is constructed “on the fly,” so for example, if you were to use this property in an SQL search<br />

query it would not execute very efficiently. It is unlikely that you would work with the RawContent<br />

property in creating an <strong>Ensemble</strong> production, but it can be useful in analyzing and reporting badly<br />

formed messages. RawContent does not contain the complete <strong>HL7</strong> message data if it is larger than 32<br />

kilobytes in size. It contains the first 32KB of the message, which is usually the entire message because<br />

most are smaller than 32KB.<br />

4.1.6 The GetValueAt Method<br />

Any expression written in Caché Basic or ObjectScript can call the EnsLib.<strong>HL7</strong>.Message class method<br />

GetValueAt to get the value of a virtual property within an <strong>HL7</strong> message body. BPL and DTL can<br />

use GetValueAt anywhere that a Caché Basic or ObjectScript expression is appropriate, for example<br />

within a BPL element or within a DTL condition like the following:<br />

<br />

Arguments<br />

GetValueAt has one argument, a %String that contains a virtual property path. To compose this string,<br />

see the section “Virtual Property Path.”<br />

102 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Return Value<br />

GetValueAt returns the %String value of the virtual property named in the first argument.<br />

Shortcuts<br />

See “Curly Bracket {} Syntax”<br />

4.1.7 The SetValueAt Method<br />

Any expression written in Caché Basic and ObjectScript can call the EnsLib.<strong>HL7</strong>.Message class method<br />

SetValueAt to set the value of a virtual property within an <strong>HL7</strong> message body. BPL and DTL can use<br />

SetValueAt anywhere that a Caché Basic or ObjectScript expression is appropriate, for example within<br />

a BPL element.<br />

Arguments<br />

SetValueAt accepts two arguments:<br />

• A %String value to assign to the virtual property.<br />

• A %String that contains a virtual property path. To compose this string, see the section “Virtual<br />

Property Path.”<br />

Return Value<br />

SetValueAt returns a value of type %Status that indicates success or failure.<br />

Shortcuts<br />

See “Curly Bracket {} Syntax”<br />

Virtual Property Syntax<br />

4.2 Virtual Property Syntax<br />

This section explains the correct syntax to use when referring to virtual properties from statements in<br />

BPL, DTL, ObjectScript, Caché Basic, business rules (including routing rules), search filters, or search<br />

tables. These syntax conventions provide the equivalent of various method calls that are either not<br />

possible in certain contexts (business rules) or that are so frequently used that a shortcut is helpful.<br />

The shortcuts are as follows.<br />

• Curly brackets<br />

{segment:field}<br />

• Square brackets<br />

[segment:field]<br />

• Round brackets or parentheses<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 103


Syntax for a Routing Production<br />

(multi-valued-property-path)<br />

• Angle brackets<br />

<br />

4.2.1 Curly Bracket {} Syntax<br />

Business rules, search tables, search filters, and certain BPL and DTL elements support the curly<br />

bracket {} shortcut in place of GetValueAt to access the value of a virtual property. The syntax is as<br />

follows:<br />

my<strong>HL7</strong>Message.{myVirtualPropertyPath}<br />

This is equivalent to the following method call, which returns the value of the specified virtual property.<br />

The specific message structure or document type must be known.<br />

msg.GetValueAt("segment:field")<br />

Note:<br />

The BPL and DTL elements and elements do not support curly bracket syntax.<br />

The segment:field string must be a valid virtual property path. Here is a BPL example:<br />

<br />

Or consider this DTL example:<br />

<br />

<br />

<br />

Here is an excerpt from a search table:<br />

{1:10}<br />

Curly bracket {} syntax is simpler than a method call, so you will generally use {} instead of calling<br />

GetValueAt. However, curly brackets are not supported is within or statements in BPL<br />

or DTL. Here you must use the appropriate method call (GetValueAt or SetValueAt) to work with<br />

virtual properties.<br />

For curly bracket syntax to resolve, the message structure must be known. If the message structure is<br />

unknown in the current context, you may use square bracket [] syntax to match the segment and field<br />

regardless of message structure.<br />

104 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Virtual Property Syntax<br />

4.2.1.1 Virtual Property Path<br />

A virtual property path is a name in two parts, separated by a colon:<br />

segment:field<br />

Where:<br />

• segment identifies a message segment.<br />

• field identifies a field within that message segment.<br />

• A colon : separates segment and field.<br />

• A dot . separates hierarchical levels within segment or field.<br />

• Parentheses containing a number (n) provide an index into an array of repeating elements.<br />

For example:<br />

NK1(2):Address.streetaddress<br />

PR1grp(1).AUTgrp.CTD:ContactAddress.streetaddress<br />

Note:<br />

A virtual property path is relative to a specific message structure, and might not be valid in<br />

any other message structure. For help in finding the correct virtual property names and<br />

numbers, use “The Schema Structures Page” as described in the chapter “Viewing and<br />

Transforming Messages.”<br />

You can use numeric or symbolic names in the segment address or field address portion of the virtual<br />

property path. Following are two sample statements such as might appear within a DTL data<br />

transformation:<br />

<br />

<br />

The target has a DG1 segment with a field number 16.2 named DiagnosingClinician.familylastname.<br />

That means the two statements in the above example are equivalent.<br />

You cannot mix numbers and names on the same side of the colon. For example {DG1(1):Diagnosing-<br />

Clinician(1).familylastname} is allowed but {DG1(1):16(1).familylastname} is not allowed. On the<br />

left side of the colon (in the segment portion) numerics are of limited use because the numeric index<br />

of a particular segment is usually not known. MSH is an exception because it is always the first segment.<br />

All of the following DTL statements are equivalent, and equally valid, because MSH is segment 1 and<br />

ReceivingApplication is field 5 of MSH:<br />

<br />

<br />

<br />

<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 105


Syntax for a Routing Production<br />

4.2.1.2 Repeating Field () Syntax<br />

When you are using curly bracket {} notation in BPL or DTL, the shortcut () iterates through every<br />

instance of a repeating field within an <strong>HL7</strong> message structure. For example, the following single line<br />

of DTL:<br />

<br />

Is equivalent to the following three lines of equally valid DTL:<br />

<br />

<br />

<br />

The same () convention is also available in BPL.<br />

4.2.1.3 Wholesale Copy<br />

When you are using curly bracket {} notation in BPL or DTL, you can copy whole segments, groups<br />

of segments, or whole composite fields within a segment. Thus, the following DTL statements<br />

are all legal:<br />

<br />

<br />

<br />

Note:<br />

The last line of the above example uses the caret (^) as a component separator character. For<br />

details, see “<strong>HL7</strong> Separator Characters” in the section “Literal String Syntax.”<br />

To create a target object that is an exact copy of the source, do not use:<br />

<br />

Instead use the create='copy' attribute in the containing element, as in the following<br />

example:<br />

<br />

The create option may have one of the following values:<br />

• “new” — Create a new object of the target type, before executing the elements within the data<br />

transformation. This is the default.<br />

• “copy” — Create a copy of the source object to use as the target object, before executing the<br />

elements within the transform.<br />

• “existing” — Use an existing object, provided by the caller of the data transformation, as the<br />

target object.<br />

106 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Virtual Property Syntax<br />

4.2.2 Square Bracket [] Syntax<br />

Square bracket [] syntax is available for business rules, search tables, and search filters only. Square<br />

brackets:<br />

[segment:field]<br />

Equate to this method call:<br />

msg.FindSegmentValues("segment:field")<br />

This means to find values in named segments regardless of message structure. If there is more than<br />

one instance of the segment type in the message, this syntax returns a string that contains all matching<br />

values, each value enclosed in angle brackets. The segment:field combination inside the square<br />

brackets follows the same rules as the virtual property path for curly brackets {} except that the field<br />

must be in numeric format.<br />

When square brackets are used, <strong>Ensemble</strong> can resolve the numeric path without knowing the specific<br />

message structure or schema. This is different from curly brackets {} which require the message<br />

structure to be identified somehow. For example, a DTL data transformation identifies the message<br />

structure of the source and the target messages with attributes of the element<br />

(sourceDocType and targetDocType) so that curly bracket syntax can be used.<br />

Square bracket syntax supports the repeating field shortcut () only in the field portion of the property<br />

path (segment:field). There is no way to specify that a segment might repeat; in fact this is not necessary.<br />

If multiple segments of the same type exist in the message, square bracket syntax matches all segments<br />

of that type in the message. The string returned by square bracket syntax encloses each value in <br />

angle brackets.<br />

The following excerpt from a search table class shows two valid ways to match all the FT1 segments<br />

found in a message that contains several FT1 segments:<br />

<br />

[FT1:12.1]<br />

[FT1:6]<br />

<br />

In each case if the syntax returns multiple values a, b, and c they appear in a single string like this:<br />

<br />

4.2.3 Parenthesis () Syntax in Business Rules<br />

Parenthesis or “round bracket” syntax is available for business rules only. A pair of parentheses can<br />

be used as brackets in an <strong>HL7</strong> routing rule as follows:<br />

<strong>HL7</strong>.(multi-valued-property-path)<br />

This equates to:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 107


Syntax for a Routing Production<br />

msg.GetValues("multi-valued-property-path")<br />

A multi-valued property path is one that uses the repeating field shortcut () to iterate through every<br />

instance of a repeating field within an <strong>HL7</strong> message structure. You can use this in combination with<br />

round bracket syntax to return all values from all repetitions of a field. If the syntax returns multiple<br />

values a, b, and c they appear in a single string enclosed in angle brackets, like this:<br />

<br />

For example, in an <strong>HL7</strong> routing rule, the syntax <strong>HL7</strong>.(NK1():1) finds the values of the first field<br />

in all of the multiple NK1 segments in the <strong>HL7</strong> message object represented by the special variable<br />

<strong>HL7</strong>.<br />

4.2.4 Angle Bracket Syntax in Business Rules<br />

Angle bracket syntax is available for business rules only. An XPath expression in angle brackets<br />

such as the following<br />

<br />

Equates to:<br />

GetXPathValues(msg.stream,"context|expression")<br />

GetXPathValues is a convenience method in the rules engine. It operates on a message that contains<br />

a stream property whose contents are an XML document. The method applies an XPath expression to<br />

the XML document within the stream property, and returns all matching values. If the context| part<br />

of the XPath argument is missing, <strong>Ensemble</strong> searches the entire XML document. If the syntax returns<br />

multiple values a, b, and c they appear in a single string enclosed in angle brackets, like this:<br />

<br />

The following is an example of angle bracket syntax in an <strong>HL7</strong> routing rule: the syntax<br />

<strong>HL7</strong>. results in a match if the XML document in the message stream property contains<br />

the word “fracture.”<br />

4.3 Literal String Syntax<br />

Often a DTL data transformation copies existing <strong>HL7</strong> message data from fields within a source message<br />

to fields within a target message. The following DTL statement shows an example of this:<br />

<br />

In cases like this <strong>Ensemble</strong> preserves all of the special characters within the <strong>HL7</strong> message data, such<br />

as separator characters and escape sequences, and handles them automatically, even if the specific<br />

conventions regarding these characters are different on the source (incoming) and target (outgoing)<br />

108 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


sides. The business services and business operations that handle the incoming and outgoing sides of<br />

<strong>HL7</strong> message transmission handle all of these issues elegantly without needing any adjustments to<br />

occur within the data transformation.<br />

However, sometimes a DTL data transformation needs to assign a literal string value to a field, as in<br />

the following DTL statement:<br />

<br />

Literal String Syntax<br />

Important:<br />

In BPL and DTL, a literal string value must provide its own enclosing quotes, distinct<br />

from those that enclose the entire value, and of a different type. Thus, in the example<br />

above, value='"ULTRA"' inserts the string ULTRA into the ReceivingApplication<br />

field of the target message. value='ULTRA' or value="ULTRA" are not effective.<br />

When a DTL data transformation assigns a literal string value to a target message field, it is providing<br />

<strong>HL7</strong> message data directly, rather than copying it from the source message. In constructing a DTL<br />

statement like this, you need to be aware of the <strong>HL7</strong> separators and escape sequences that apply in the<br />

source (incoming) message, so that your literal string matches these conventions correctly.<br />

It does not matter which <strong>HL7</strong> separators and escape sequences apply on the target (outgoing) side;<br />

they may be different. What matters within the data transformation is that any literal strings you create<br />

must match the <strong>HL7</strong> separators and escape sequences of the source message. Then, after the data<br />

transformation constructs the target message object, the <strong>HL7</strong> business operation automatically adjusts<br />

the <strong>HL7</strong> separators and escape sequences to those expected by the target.<br />

You should also be aware that, because BPL and DTL are extensions of XML, whenever you construct<br />

a literal string for a BPL or DTL statement there are certain characters you can only represent using<br />

XML entities. A limited number of numeric character codes are also supported in constructing BPL<br />

or DTL strings. The next several topics explain the requirements for various types of special character.<br />

Finally, remember that the value attribute in a DTL statement can be a simple string, as in<br />

most of the examples in this book:<br />

value='"string"'<br />

Or the DTL value can be a complex string expression using the scripting language specified by the<br />

containing element. This language can be either Caché Basic or ObjectScript; if not<br />

specified it is ObjectScript. The same is true for a BPL statement, which uses the scripting<br />

language specified by the containing element; otherwise it uses ObjectScript.<br />

When constructing complex literal strings, keep in mind:<br />

• In ObjectScript, the concatenation operator is the _ (underscore) character, as in:<br />

value='"prefix"_source.{MSH:ReceivingApplication}_"suffix"'<br />

In Basic, the concatenation operator is & (ampersand).<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 109


Syntax for a Routing Production<br />

• To learn about useful ObjectScript string functions, such as $CHAR and $PIECE, see the Caché<br />

ObjectScript Reference. For Basic equivalents, see the Caché Basic Reference.<br />

• For a general introduction see Using Caché ObjectScript or Using Caché Basic.<br />

4.3.1 <strong>HL7</strong> Separator Characters<br />

An <strong>HL7</strong> message uses special characters to organize its raw contents. These characters may vary from<br />

one clinical application to another. For this reason, the <strong>HL7</strong> standard requires that each <strong>HL7</strong> message<br />

list the five specific characters that it is using as separators at the start of the MSH segment, in order<br />

from left to right:<br />

1. Field separator (FS)<br />

2. Component separator (CS)<br />

3. Repetition separator (RS)<br />

4. Escape character (ESC)<br />

5. Subcomponent separator (SS)<br />

A sixth character, the segment terminator character, is not specified in MSH and is generally assumed<br />

to be a carriage return (ASCII 13).<br />

4.3.1.1 Business Operations<br />

When configuring a routing production, you have the option of specifying a set of <strong>HL7</strong> separator<br />

characters, as well as a segment terminator, for outgoing <strong>HL7</strong> messages.<br />

The way to do this is to set the value of the Separators setting for the <strong>HL7</strong> business operation. For<br />

Separators, you must supply a string of characters which <strong>Ensemble</strong> assigns to <strong>HL7</strong> separators in left<br />

to right order: FS, CS, RS, ESC, SS as described in the previous list. If you do not specify a value for<br />

Separators, the business operation uses the following defaults for positions 1 through 5:<br />

|^~\&<br />

Beyond positions 1 through 5 of the Separators string, you can supply additional characters to override<br />

the default segment terminator character, the carriage return (ASCII 13). After position 5, use \r for<br />

the carriage return (ASCII 13) and \n for the line feed (ASCII 10).<br />

You can use \x in positions 1 through 5 if you need to specify segment terminators in positions 6 and<br />

higher but want your output messages to use fewer than 5 separators. Separators designated by \x in<br />

positions 1 through 5 are not used. The purpose of \x is simply to extend the length of the list of separators<br />

so that position 6 is interpreted correctly as the first segment terminator.<br />

110 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Literal String Syntax<br />

4.3.1.2 Data Transformations<br />

Within a DTL statement, any <strong>HL7</strong> separator character that you use appropriately in a literal string will<br />

act as a separator character within the resulting <strong>HL7</strong> message object. For example:<br />

<br />

This statement sets fields 2 and 3 of DG1(1):DiagnosingClinician by providing a literal string<br />

that contains the appropriate arrangement of subcomponent separator characters (^ in this case) to<br />

indicate field positions within the DG1(1):DiagnosingClinician component.<br />

Note:<br />

In order for this convention to work, ^ must actually be the subcomponent separator.<br />

4.3.2 <strong>HL7</strong> Escape Sequences<br />

When separator characters need to appear within the data contents of an <strong>HL7</strong> message, <strong>HL7</strong> provides<br />

escape sequences to replace the separator characters.<br />

The character most likely to require this feature is the & (ampersand) character. & is often used as an<br />

<strong>HL7</strong> separator. At the same time, & is likely to appear in <strong>HL7</strong> document data, either within the legal<br />

names of employers (Parker & Sons) or as shorthand in treatment orders (XR CHEST PA&LAT).<br />

Thus, within the <strong>HL7</strong> data stream you will often see & characters replaced by an escape sequence,<br />

such as the \T\ in the following samples:<br />

Parker \T\ Sons<br />

XR CHEST PA\T\LAT<br />

The following table lists the six standard <strong>HL7</strong> escape sequences and their meanings. <strong>HL7</strong> escape<br />

sequences begin and end with the escape character as defined in the MSH segment. <strong>HL7</strong> escape<br />

sequences are case-sensitive, and they use the specific characters F R S T E or .br as shown in the<br />

table. In the examples shown, the \ (backslash) is the escape character.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 111


Syntax for a Routing Production<br />

<strong>HL7</strong> Escape Sequences Using Backslash as Escape Character<br />

This character sequence...<br />

\.br\<br />

\F\<br />

\R\<br />

\S\<br />

\T\<br />

\E\<br />

If found within <strong>HL7</strong> data, indicates...<br />

Carriage return<br />

Field separator character<br />

Repetition separator character<br />

Component separator character<br />

Subcomponent separator character<br />

Escape character<br />

For example...<br />

|<br />

~<br />

^<br />

&<br />

\<br />

It is not necessary to provide any special processing in a DTL data transformation to handle the separator<br />

characters or escape sequences that already exist within the source message data. The business<br />

services and business operations that handle the incoming and outgoing sides of <strong>HL7</strong> message transmission<br />

know which separator characters to expect on each side. Prior to being sent, the whole text of<br />

the message is automatically “un-escaped” relative to the incoming set of separators, and then “reescaped”<br />

relative to the outgoing set of separators. All of these <strong>HL7</strong> issues are handled automatically<br />

when you use a DTL data transformation to simply fields in the source message to fields in<br />

the target message.<br />

On the other hand, if you a literal string to a target field using DTL, and that string needs to<br />

include <strong>HL7</strong> separator characters, either as separators or as literal characters, some special handling<br />

is required. The procedures are as follows.<br />

Suppose you have a source message in which ^ & and \ are separators as listed in the MSH segment:<br />

MSH|^~&\<br />

Now suppose that, for all ADT_A01 messages that arrive from a certain clinical source, your DTL<br />

data transformation needs to assign a literal value to the InsuranceCompanyName field. The correct<br />

value has been agreed upon by all concerned parties, including the insurance company, whose name<br />

is Pierre DuRhône & Cie. The value is to appear in the <strong>HL7</strong> data stream as follows:<br />

Pierre DuRho^ne & Cie<br />

In this case, you need <strong>HL7</strong> escape sequences to replace ^ and & within the data, as follows:<br />

<br />

The only other case in which you need to be concerned about separator characters is if you wish to<br />

migrate data into or out of an <strong>Ensemble</strong> <strong>HL7</strong> virtual document without using a data transformation at<br />

all. The EnsLib.<strong>HL7</strong>.Segment class provides explicit Escape and Unescape methods that you can<br />

112 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


invoke to accomplish manually what a DTL data transformation does automatically to “un-escape”<br />

and “re-escape” <strong>HL7</strong> messages. A replace method also exists.<br />

4.3.3 XML Entities<br />

When you a literal string value to a property using BPL or DTL, you must substitute XML<br />

entities for certain characters. This has nothing to do with <strong>HL7</strong>. The restriction exists because BPL<br />

and DTL are extensions of XML. Within all BPL or DTL statements (aside from the contents of <br />

or statements) certain characters must be represented by XML entities. The following table lists<br />

them.<br />

XML Entities for Use in BPL and DTL Strings<br />

Literal String Syntax<br />

Character<br />

><br />

<<br />

&<br />

'<br />

"<br />

XML Entity<br />

&gt;<br />

&lt;<br />

&amp;<br />

&apos;<br />

&quot;<br />

Description<br />

Right angle bracket or “greater than” symbol.<br />

Left angle bracket or “less than” symbol.<br />

Ampersand.<br />

Single quotation mark or apostrophe. A string enclosed in<br />

single quotes needs the &apos; entity to represent the '<br />

character.<br />

Double quotation mark. A string enclosed in double quotes<br />

needs the &quot; entity to represent the " character.<br />

To encode a literal string for the employer named Joe’s "Good Time" Bar & Grill, a BPL or DTL<br />

statement needs this syntax:<br />

<br />

As a general rule, you must use the appropriate XML entity in place of the characters >,


Syntax for a Routing Production<br />

• When & is an <strong>HL7</strong> separator character and the string needs to include that character as a separator<br />

use &amp;<br />

• When & is an <strong>HL7</strong> separator character and the string needs to include that character as a literal<br />

character use the appropriate <strong>HL7</strong> escape sequence for that separator.<br />

• In all other cases, whether or not & is an <strong>HL7</strong> separator, use &amp;<br />

Suppose & and " are in use as the <strong>HL7</strong> component and subcomponent separators. For an employer<br />

called Joe’s "Good Time" Bar & Grill, a DTL statement would need this syntax:<br />

<br />

4.3.4 Numeric Character Codes<br />

Decimal or hexadecimal representations of characters are permitted within literal strings in BPL and<br />

DTL.<br />

The string &#n; represents a Unicode character when n is a decimal Unicode character number. One<br />

example is &#233; for the Latin e character with acute accent mark (é).<br />

Alternatively, the string &#xh; represents a Unicode character when h is a hexadecimal Unicode<br />

character number. One example is &#x00BF; for the inverted question mark (¿).<br />

Important:<br />

Due to the limitations of single-byte encoding format for <strong>HL7</strong>, the numeric value in<br />

character codes in literal strings placed in <strong>HL7</strong> messages can be no higher than the<br />

decimal value 255 or hexadecimal x00FF.<br />

4.3.5 Null Mapping Codes<br />

There are <strong>HL7</strong> applications that use a null mapping convention. According to this convention, the<br />

source application can send a field that consists of two consecutive double-quote characters:<br />

""<br />

This value means “If you have data in this field, delete it from your application.”<br />

Many target applications do not expect these instructions and are not designed to respond to them. If<br />

this is the case, and the double quotes are saved in the target application as actual patient data, the<br />

application users will see double-quote characters on their screens. This can be annoying and misleading.<br />

When your source application uses a null mapping convention, your <strong>HL7</strong> data transformation can<br />

check for null mapping entries in <strong>HL7</strong> fields and replace them with empty strings, or otherwise fill in<br />

data for the benefit of the target application.<br />

114 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The following statement represents the simplest case. It checks for a null mapping in the source<br />

and replaces it with an empty string in the target. The condition tests for the null mapping code<br />

"" using a string of 2 quoted quotes. This results in a total of 6 double-quote characters, not including<br />

the single quotes that wrap the entire condition value. (Count carefully!)<br />

<br />

<br />

<br />

<br />

<br />

In the above example, the value indicates a empty string using 2 consecutive double-quote<br />

characters, with single quotes wrapping the entire value.<br />

The following syntax is equally valid:<br />

Schema Category Syntax<br />

<br />

<br />

<br />

<br />

<br />

You can achieve more sophisticated goals for handling null mappings. The following example takes<br />

alternative actions based on whether there is actually a value in {PV1:3}. If the field contains a null<br />

mapping code the element executes. Otherwise the element executes.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

4.4 Schema Category Syntax<br />

A schema category definition can be viewed in XML format by opening its *.<strong>HL7</strong> file in <strong>Ensemble</strong><br />

Studio. Each *.<strong>HL7</strong> file is an XML document whose top-level container is the element.<br />

Statements within the element define <strong>HL7</strong> message structures.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 115


Syntax for a Routing Production<br />

When viewed in <strong>Ensemble</strong> Studio, an *.<strong>HL7</strong> file resembles the following figure. The actual text is<br />

longer and wider than the example, which contains ellipses (...) for omitted items and is truncated at<br />

right. This example is the schema category definition for <strong>HL7</strong> <strong>Version</strong> 2.5.<br />

<strong>Ensemble</strong> Studio View of a Built-in <strong>HL7</strong> Category Definition<br />

Inside the element, the example begins with two sets of XML elements that you do not<br />

need to work with: and . These elements group <strong>HL7</strong> messages into<br />

functional categories. The example ends with two other XML elements that you do not need to work<br />

with: and . These elements define the range of possible values for certain<br />

fields in certain messages.<br />

When you create a custom schema category, you supplement an existing schema by defining custom<br />

segments (Z-segments) and then stating which message types and message structures may contain<br />

those segments. To accomplish this, you only need to work with the XML elements ,<br />

, and .<br />

116 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Schema Category Syntax<br />

Important:<br />

Never edit the built-in schema category definition files. When you need to use custom<br />

message types that contain Z-segments, create a custom schema category definition<br />

that uses a built-in schema category definition as its schema base.<br />

A custom schema category definition is simpler than a built-in definition and contains fewer statements.<br />

Everything in the base category is included in the custom schema category definition. There is no need<br />

to repeat the definitions of standard message types. You only need to define custom message types.<br />

The conventions for doing this are as follows:<br />

What to Define<br />

Custom schema category definition.<br />

Custom segments (Z-segments).<br />

Any message structures that include custom segments.<br />

Any message types that include message structures with custom<br />

segments. A message type identifies:<br />

How to Define It<br />

<br />

<br />

<br />

<br />

• The message structure to send<br />

• The message structure to expect in response<br />

When viewed in <strong>Ensemble</strong> Studio, a custom schema category definition resembles the following figure.<br />

The actual text is wider than the example, which is truncated at right. You can view the complete<br />

example by opening the schema definition file Demo.<strong>HL7</strong>.MsgRouter.Schema.<strong>HL7</strong> in the ENSDEMO<br />

namespace.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 117


Syntax for a Routing Production<br />

<strong>Ensemble</strong> Studio View of a Custom <strong>HL7</strong> Category Definition<br />

4.4.1 <br />

The element is the top-level container for the XML document that describes the custom<br />

schema category. The following is an example of syntax for a custom schema category<br />

definition:<br />

<br />

<br />

<br />

The following table describes the attributes.<br />

Attributes for the Element in Schema Category Definitions<br />

Attribute<br />

name<br />

std<br />

Description<br />

Name displayed in the Schema Structures<br />

page in the list of available schema<br />

categories.<br />

When 1 (true), this block<br />

describes a standard <strong>HL7</strong> schema<br />

category. The default is 0 (false).<br />

Value<br />

String. For convenience, use<br />

the name of the .<strong>HL7</strong> file.<br />

For standard schema<br />

category definitions only. Do<br />

not use std in a custom<br />

schema.<br />

118 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Schema Category Syntax<br />

Attribute<br />

base<br />

Description<br />

Identifies the schema category that is the<br />

base for this custom schema category.<br />

Every definition in the schema base is<br />

automatically included in the custom<br />

category; statements in the custom schema<br />

category simply add to the base.<br />

Value<br />

The name of a standard or<br />

custom schema category<br />

defined using a <br />

block in another .<strong>HL7</strong> file.<br />

4.4.2 <br />

A element may contain one or more elements. Each <br />

element defines the structure of a custom segment (Z-segment). The following is an example of<br />

element syntax:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

The following table describes the attributes.<br />

Attributes for the Element in Schema Category Definitions<br />

Attribute<br />

name<br />

description<br />

Description<br />

Name displayed in the Schema Structures<br />

page in the list of available segment<br />

structures.<br />

Text description of the segment contents,<br />

displayed in the Schema Structures page<br />

and in hover-text help for the Document<br />

Viewer page.<br />

Value<br />

3–character string. By<br />

convention, custom<br />

segment names begin with<br />

the letter Z.<br />

String<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 119


Syntax for a Routing Production<br />

4.4.3 <br />

A element may contain one or more elements. Each<br />

element describes one field of the custom segment, in sequential order from<br />

top to bottom. The following is an example of element syntax:<br />

<br />

The following table describes the attributes.<br />

Attributes for the Element in Schema Category Definitions<br />

Attribute<br />

piece<br />

codetable<br />

datastruct<br />

description<br />

Description<br />

Number displayed in the<br />

Schema Structures page when<br />

the user asks to view details of<br />

the segment that contains this<br />

field. This number can be used<br />

to identify the field in a virtual<br />

property path.<br />

Code table that enumerates a<br />

list of valid values for this field.<br />

This attribute is typically not<br />

used in a custom schema.<br />

Data structure that specifies<br />

how to interpret the values in<br />

this field. This attribute is<br />

typically not used in a custom<br />

schema.<br />

Text description of the field<br />

contents, displayed in the<br />

Schema Structures page and<br />

in hover-text help for the<br />

Document Viewer page.<br />

Value<br />

Integer. Each <br />

within a must use<br />

piece values in sequential order,<br />

beginning at 1 and incrementing by 1.<br />

The name of a code table defined<br />

using a block.<br />

The name of a data structure defined<br />

using a block.<br />

String<br />

120 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Schema Category Syntax<br />

Attribute<br />

symbol<br />

Description<br />

Symbol that indicates the<br />

requirements for presence,<br />

absence, or repetition of this<br />

field within the segment.<br />

This field is optional. It serves<br />

as an indicator on the Schema<br />

Structures page. It does not<br />

actually control the requirement<br />

or repetition of fields. See<br />

required and ifrepeating.<br />

Value<br />

A single character:<br />

• ! means 1 only. The field must<br />

appear, but only once.<br />

• means 0 or 1. The field may<br />

appear, but at most once.<br />

• + means 1 or more. The field may<br />

repeat one or more times.<br />

• * means 0 or more. The field may<br />

repeat zero or more times.<br />

• & means the field may be present,<br />

and may repeat, but only under<br />

certain conditions.<br />

length<br />

required<br />

Upper limit on the number of<br />

characters that can be present<br />

in this field.<br />

Whether or not this field must<br />

be present in the segment.<br />

Integer<br />

A single character:<br />

• C means conditional<br />

• O means optional<br />

• R means required<br />

ifrepeating<br />

Whether or not this field may<br />

repeat within the segment.<br />

Integer. 0 means no, 1 means yes.<br />

4.4.4 <br />

A element may contain one or more elements. Each <br />

element provides a specification for the number and arrangements of segments in a message<br />

structure. The following is an example of element syntax:<br />

<br />

The following table describes the attributes.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 121


Syntax for a Routing Production<br />

Attributes for the Element in Schema Category Definitions<br />

Attribute<br />

name<br />

definition<br />

description<br />

Description<br />

Name displayed in the Schema Structures<br />

page in the list of available message<br />

structures.<br />

Specification for the number and<br />

arrangements of segments in the message<br />

structure. May include a mix of standard<br />

and custom message segments. See syntax<br />

rules below.<br />

Text description of the field contents,<br />

displayed in the Schema Structures page<br />

and in hover-text help for the Document<br />

Viewer page.<br />

Value<br />

3–character string, plus an<br />

underscore (_), plus a<br />

3–character string.<br />

String that includes the<br />

3–character name values<br />

for standard or custom<br />

message segments defined<br />

using <br />

String<br />

Syntax for the definition string work as follows:<br />

• Keep the entire string all on one line<br />

• List each segment sequentially from left to right<br />

• When listing a segment, use its name value as defined by a <br />

• Separate a segment from the next segment by a ~ (tilde) character<br />

• If a segment or block of segments repeats, enclose the repeating part in {~ and ~}<br />

• If a segment or block of segments is optional, enclose the optional part in [~ and ~]<br />

Within a definition, a name may be simple, in which case <strong>Ensemble</strong> assumes the value refers to a<br />

custom block within the same .<strong>HL7</strong> file. Alternatively, a name may refer to a<br />

standard message structure from the schema base. This means it is defined in the .<strong>HL7</strong> file identified<br />

by the base attribute in the containing element. To indicate this, the name must use the<br />

prefix:<br />

base:<br />

So that <strong>Ensemble</strong> can find the appropriate in the other file. No other external<br />

.<strong>HL7</strong> file can be referenced; only the schema base.<br />

In the example at the beginning of this topic, only the ZSI segment is defined in<br />

the same .<strong>HL7</strong> file. The other segments (MSH, MFI, MFE, OM1, and Hxx) are all defined in the schema<br />

base.<br />

122 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Schema Category Syntax<br />

4.4.5 <br />

A element may contain one or more elements. entries<br />

define any message types that include message structures that have custom segments. A <br />

element is a simple list of two items:<br />

• A message structure to send<br />

• A message structure to expect in response<br />

The following is an example of element syntax:<br />

<br />

The following table describes the attributes.<br />

Attributes for the Element in Schema Category Definitions<br />

Attribute<br />

name<br />

structure<br />

returntype<br />

Description<br />

Name displayed in the Schema Structures<br />

page in the list of available message types.<br />

The message structure to send.<br />

The message structure to expect in<br />

response. This must be a valid ACK<br />

message structure. Make sure the<br />

returntype has a value from the schema<br />

base. For example:<br />

returntype="base:ACK"<br />

Value<br />

3–character string, plus an<br />

underscore (_), plus a<br />

3–character string.<br />

The name of a standard or<br />

custom message structure<br />

defined using<br />

<br />

The name of a standard or<br />

custom message structure<br />

defined using<br />

<br />

structure values can be simple name values from the current .<strong>HL7</strong> file. If a file contains syntax like<br />

the following, where the structure is MFN_M03:<br />

<br />

Then the same file must also contain syntax like the following, to define MFN_M03:<br />

<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 123


Syntax for a Routing Production<br />

Alternatively, structure or returntype values can refer to a standard message structures from the schema<br />

base. To indicate this, the values must use the prefix:<br />

base:<br />

So that <strong>Ensemble</strong> can find the appropriate entries, in the .<strong>HL7</strong> file identified by<br />

the base attribute in the containing element. No other external .<strong>HL7</strong> file can be referenced;<br />

only the schema base.<br />

The following example uses both styles of syntax. This example defines a custom message type<br />

MFN_M03 that sends a custom MFN_M03 and receives a standard MFK_M03 as a response.<br />

<br />

124 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


5<br />

Viewing and Transforming<br />

Messages<br />

This chapter describes the <strong>Ensemble</strong> Management Portal pages that allow you to view and transform<br />

<strong>HL7</strong> messages. From the [<strong>Ensemble</strong>] home page, you may choose options as follows:<br />

• From the main menu, choose EDI / <strong>HL7</strong> Manager. Click one of the following links:<br />

- <strong>HL7</strong> <strong>Version</strong> 2 — Displays the Web site for the American National Standards Institute (ANSI)<br />

standards developing organization Health Level Seven (<strong>HL7</strong>). The URI is<br />

http://www.hl7.org/<br />

- Schema Structures — Displays a list of the supported <strong>HL7</strong> <strong>Version</strong> 2.x schema specifications.<br />

You can click on any link in the display to drill down for details.<br />

- Message Viewer — Allows you to preview the results of applying various parsing schemes<br />

or data transformations to <strong>HL7</strong> message data.<br />

• From the main menu, choose Message Browser. The [<strong>Ensemble</strong>] > [Messages] page offers the<br />

following features for working with <strong>HL7</strong> message data:<br />

- Filter Messages — Find archived <strong>HL7</strong> messages that meet your filter criteria. You can specify<br />

detailed logical rules for the filter.<br />

- Compare Messages — Select two <strong>HL7</strong> messages from the list on the [<strong>Ensemble</strong>] > [Messages]<br />

page. Click Compare Messages to display their contents side by side.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 125


Viewing and Transforming Messages<br />

5.1 Starting the <strong>Ensemble</strong> Management Portal<br />

To start the <strong>Ensemble</strong> Management Portal from the System Management Portal:<br />

1.<br />

Click on the <strong>Ensemble</strong> cube icon in the Windows system tray. Choose System Management<br />

Portal from the menu. A browser window opens and the [Home] page displays.<br />

2. At the bottom of the System Administration column on the left-hand side, click the <strong>Ensemble</strong><br />

Management Portal option. The display changes to the <strong>Ensemble</strong> login page. Under the title bar<br />

is a display area that contains a dialog box and the prompt Please login.<br />

3. If you have more than one <strong>Ensemble</strong> namespace, the <strong>Ensemble</strong> login page includes a Namespace<br />

field. If you see the Namespace field, select a namespace from the drop-down list. If you have<br />

one <strong>Ensemble</strong> namespace, the <strong>Ensemble</strong> login page automatically selects that namespace and the<br />

Namespace field does not appear.<br />

4. In the Username and Password fields, enter the username and password for a user account defined<br />

in the namespace. The default login is _SYSTEM with the password SYS.<br />

5. Click Login. The [<strong>Ensemble</strong>] home page displays.<br />

To start the <strong>Ensemble</strong> Management Portal from Studio:<br />

1. Choose an <strong>Ensemble</strong> namespace:<br />

• Choose the File menu Change Namespace option. The Connection Manager displays.<br />

• Choose a Server Connection and Namespace (choose an <strong>Ensemble</strong> namespace).<br />

• If necessary, enter the Username and Password for that namespace and server.<br />

• Click OK to save your changes, Cancel to cancel them.<br />

2. Choose the Utilities menu <strong>Ensemble</strong> Management option. The <strong>Ensemble</strong> login page displays.<br />

3. Under the <strong>Ensemble</strong> login page title bar is a display area that contains a dialog box and a prompt<br />

to Please login. The dialog box provides Username and Password fields. Enter the username and<br />

password for a user account defined in the namespace you chose in Step 1. The default login is<br />

_SYSTEM with the password SYS.<br />

4. Click Login. The [<strong>Ensemble</strong>] home page displays.<br />

126 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The Schema Structures Page<br />

5.2 The Schema Structures Page<br />

When you start the <strong>Ensemble</strong> Management Portal and select EDI / <strong>HL7</strong> Manager, then Schema Structures,<br />

the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas] page displays. This page allows you to view<br />

detailed information about <strong>HL7</strong> <strong>Version</strong> 2 schema categories, including standard schemas and custom<br />

schemas.<br />

The Schema Structures page displays a table, with columns as follows:<br />

• Category — Identifies the schema category.<br />

The <strong>HL7</strong> schema definitions loaded into <strong>Ensemble</strong> were generated directly from the respective<br />

standards (<strong>HL7</strong> 2.1, 2.2, 2.3, 2.3.1, 2.4, and 2.5). They faithfully replicate any errors, omissions,<br />

or discrepancies that exist in these standards as published by the Health Level Seven organization.<br />

There is one exception to this rule: In the <strong>HL7</strong> 2.3.1 standard, the data structure XCN is the<br />

“extended composite ID number and name for persons.” The standard leaves XCN field 3 undefined<br />

by mistake. The <strong>Ensemble</strong> schema definition for <strong>HL7</strong> 2.3.1 corrects this so that XCN field 3 is<br />

correctly identified as “given name.”<br />

<strong>HL7</strong> <strong>Version</strong> 3 is not listed as an <strong>HL7</strong> schema category, because it uses entirely different data<br />

conventions from <strong>HL7</strong> <strong>Version</strong> 2. <strong>HL7</strong> <strong>Version</strong> 3 defines messages in XML format. <strong>Ensemble</strong><br />

does not use virtual documents to represent <strong>HL7</strong> <strong>Version</strong> 3 message structures. <strong>Ensemble</strong> handles<br />

the XML data directly, using XPATH and XSLT. For details, see the <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 3<br />

<strong>Development</strong> <strong>Guide</strong>.<br />

• Base — The standard category on which a custom category is based.<br />

• Links — Buttons you can click to drill down to various levels of each category:<br />

- Message Types identify two Message Structures as a request/response pair.<br />

- Message Structures/DocTypes identify the sequence and grouping of Segments within a<br />

Message Structure.<br />

- Segment Structures list the fields in each Segment of a Message Structure.<br />

- Data Structures list the contents of composite data fields.<br />

- Code Tables list the values that can be used within an enumerated field.<br />

At the bottom of the page, a dialog offers selections that allow you to:<br />

• Import or Export schema category definitions as XML files.<br />

• Choose a schema category from the drop-down list and Remove its definition from the <strong>Ensemble</strong><br />

database.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 127


Viewing and Transforming Messages<br />

WARNING!<br />

You cannot undo the Remove operation.<br />

5.2.1 Viewing a List of Document Types<br />

Suppose you are viewing the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas] page. If you click<br />

the Message Structures/DocTypes link in one of the rows, the display changes to list all the message<br />

structures in that category definition. This is the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas]<br />

> [<strong>HL7</strong> Schema Contents] page.<br />

This page is useful for supplying correct values for the DocType property of an <strong>HL7</strong> message object.<br />

Remember that this value is a name in two parts, separated by a colon:<br />

category:structure<br />

Where:<br />

• category is the name of a schema category, such as 2.3.1. This name appear at the top of the<br />

[<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas] > [<strong>HL7</strong> Schema Contents] page.<br />

• structure is the name of a message structure within that schema category. The page contains a<br />

complete list of valid message structures. If you view this page online, you can see that valid<br />

DocType values for category 2.3.1 include 2.3.1:ACK, 2.3.1:ADT_A17, 2.3.1:BAR_P01,<br />

2.3.1:PEX_P07, and so on.<br />

5.2.2 Viewing a Message Structure<br />

To view the internal organization of a message structure, click on its name in any [<strong>Ensemble</strong>] > [EDI<br />

and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas] > [<strong>HL7</strong> Schema Contents] page. <strong>Ensemble</strong> displays the segment<br />

structure of the message using the system of visual cues explained below. This is the [<strong>Ensemble</strong>] ><br />

[EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas] > [<strong>HL7</strong> Message Structure] page. The following example shows<br />

the 2.3.1:ORM_O01 message structure.<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.3.1:ORM_O01<br />

The visual conventions on this page are as follows:<br />

128 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


• The segments that comprise the message structure are listed in sequential order, from left to right.<br />

• The three-letter name of each message segment is displayed: MSH, NTE, PID, etc. This name<br />

indicates the type of segment that exists at this location in the <strong>HL7</strong> message structure.<br />

• White lines enclose a single segment. The look is similar to a table cell (see MSH and the first<br />

NTE segment, above).<br />

• If segments are organized into a group, the entire group appears within the same table cell (see<br />

PID and ORC above).<br />

• Green dotted lines enclose segments, groups, or fields that are optional.<br />

• Red solid lines enclose segments, groups, or fields that, if present, may repeat several times.<br />

• Orange dashed lines enclose a choice: this is a union of segments. Only one segment from the<br />

union can appear at this location within the message structure. It may be any of the segments<br />

listed.<br />

• A segment, group, or field may be both repeating and optional (see any NTE above).<br />

• You can navigate back to higher levels in the schema using the buttons Show All Categories and<br />

Show All Message Structures.<br />

• To see the message structure you are currently viewing in a raw text format, click Show Raw<br />

Definition text. You can click Show Definition diagram to return to the segment diagram.<br />

When you are viewing a segment diagram, if you hover the cursor over a three-letter segment name,<br />

a hover-text help window displays the syntax for referring to this segment in a virtual property path.<br />

In the above example, the cursor is hovering over an ODS segment whose segment address is:<br />

ORCgrp().OBRuniongrp.OBRunion.ODS<br />

In the following example, the cursor is hovering over a PR1 segment whose segment address is:<br />

PR1grp().PR1<br />

The Schema Structures Page<br />

This address is the segment portion of a virtual property path, which has the format segment:field. To<br />

discover valid values for the field portion of this path, click on the three-letter segment name in the<br />

diagram. The next several topics explore the results when you click on the PR1 segment in the message<br />

structure 2.3:ADT_A01.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 129


Viewing and Transforming Messages<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.3:ADT_A01<br />

5.2.3 Viewing a Segment Structure<br />

To view the structure of a message segment, click on its name in any page similar to the example<br />

shown in the previous section, “Viewing a Message Structure.” <strong>Ensemble</strong> displays a table that lists<br />

and describes all the fields in that segment. This is the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong><br />

Schemas] > [<strong>HL7</strong> Segment Structure] page.<br />

The following sample page appears when you click the PR1 segment in the 2.3:ADT_A01 message<br />

structure. The page states that the category 2.3 segment PR1 describes “Procedures” and may consist<br />

of fifteen fields. Of these, only SetIDProcedure, ProcedureCodingMethod, and ProcedureType are<br />

required (1, 2, and 6).<br />

<strong>Ensemble</strong> <strong>HL7</strong> Segment Structure Page<br />

The columns in the display have meaning as follows:<br />

• The Field column lists the numbers you can use to access fields within the segment (if you prefer<br />

numbers).<br />

130 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The Schema Structures Page<br />

• There may be a brief text Description of each field.<br />

• The Property Name column lists the names you can use to access fields within the segment (if you<br />

prefer names).<br />

• For more complex field values that use a data structure, you need further syntax details before<br />

you can complete the segment:field virtual property path. You can get this by clicking on a name<br />

in the Data Structure column<br />

• The Symbol column indicates the syntax rules for the field. The characters in this column indicate<br />

whether you can expect this field to be present, absent, or repeated within the message segment.<br />

Possible values are:<br />

Symbol<br />

!<br />

<br />

+<br />

*<br />

&<br />

n*<br />

Meaning<br />

(1 only) The field is required; it must occur only once.<br />

(0 or 1) The field is optional, but if it occurs, it may occur only once.<br />

(1 or more) The field may repeat one or more times.<br />

(0 or more) The field may repeat zero or more times.<br />

The field may be present, and may repeat, but only under certain<br />

conditions.<br />

(0 to n) The field repeats a maximum of n times.<br />

• The Repeat Count is the maximum number of times the field can repeat (if it repeats, and if there<br />

is a maximum).<br />

• The Length is the maximum number of characters in the field. Each repeat of the field may contain<br />

this number of characters.<br />

• Required displays R for required, O for optional.<br />

• Repeating displays 1 for true, 0 for false.<br />

• Click on an entry in the Code Table column (if any) to view the valid codes that may be entered<br />

in this field.<br />

• There may be an Alternate Description of the field.<br />

You can use this information, particularly the Property Name column, to build virtual property paths<br />

for <strong>Ensemble</strong> in the format segment:field. The following are examples of virtual property paths<br />

involving simple field values from the PR1 segment in the 2.3:ADT_A01 message structure. The ()<br />

shortcut syntax indicates all available instances of a repeating field, whereas (1) indicates the first<br />

instance:<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 131


Viewing and Transforming Messages<br />

PR1grp().PR1:ProcedureType<br />

PR1grp().PR1:ProcedureCode()<br />

PR1grp().PR1:ProcedureCode(1)<br />

PR1grp().PR1:ProcedureCode(x)<br />

PR1grp().PR1:ProcedurePriority<br />

5.2.4 Viewing a Data Structure<br />

When you click on a name in the Data Structure column, <strong>Ensemble</strong> displays a table that lists and<br />

describes all the fields in that data structure. This is the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong><br />

Schemas] > [<strong>HL7</strong> Data Structure] page. The following columns of the display are most useful:<br />

• The Component column lists the numbers you can use to access fields within the segments (if you<br />

prefer numbers).<br />

• The Property Name column lists the names you can use to access fields within the segments (if<br />

you prefer names).<br />

• Click on an entry in the Data Structure column (if any) to drill down for detail.<br />

• Click on an entry in the Code Table column (if any) to view the valid codes that may be entered<br />

in this field.<br />

The following sample page appears when you click the Data Structure item called 2.3:XCN in the<br />

segment structure page above. The page states that the category 2.3 data structure XCN describes an<br />

“Extended Composite ID number and name” and consists of fourteen fields. Of these, some are simple<br />

values, some are data structures, and some are codes.<br />

<strong>Ensemble</strong> <strong>HL7</strong> Data Structure Page<br />

Given this information, you can construct virtual property paths for the complex PR1grp().PR1:Surgeon<br />

field in the message structure 2.3:ADT_A01 as follows:<br />

132 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The Schema Structures Page<br />

PR1grp().PR1:Surgeon.familyname<br />

PR1grp().PR1:Surgeon.degree<br />

5.2.5 Viewing a Code Table<br />

When you click on a name in the Code Table column, it lists and explains the valid codes for that field.<br />

This is the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [<strong>HL7</strong> Schemas] > [<strong>HL7</strong> Code Table] page. The following<br />

sample page appears when you click the Code Table item called 2.3:200 in the data structure page<br />

shown in the previous section, “Viewing a Data Structure.”<br />

<strong>Ensemble</strong> <strong>HL7</strong> Code Table Page<br />

The example above shows that the category 2.3 code table 200 describes a “Name type” that can have<br />

the value L, O, M, A, C, or D. You can arrive at this page by clicking on:<br />

1. The message structure 2.3:ADT_A01<br />

2. The message segment PR1, which has a segment address of PR1grp().PR1<br />

3. The data structure DS:2.3:XCN in the optional Anesthesiologist field<br />

4. The code table CT:2.3:200 in the nametype field<br />

This means that if you have an <strong>HL7</strong> message with a DocType of 2.3:ADT_A01, it has an optional<br />

virtual property with the path PR1grp().PR1:Anesthesiologist.nametype that can contain one of the<br />

following values: L, O, M, A, C, or D.<br />

Note:<br />

For details, see “Virtual Property Path” in the chapter “Syntax for a Routing Production.”<br />

5.2.6 Choosing a Different Category<br />

It is a feature of the <strong>HL7</strong> standard that a message structure can differ by <strong>HL7</strong> version, even when the<br />

structure has the same name and number. For example, both <strong>HL7</strong> 2.4 and <strong>HL7</strong> 2.5 define a message<br />

structure called ORD_O04, but these definitions contain different segments. <strong>Ensemble</strong> provides the<br />

message structure definitions 2.4:ORD_O04 and 2.5:ORD_O04. The [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager]<br />

> [<strong>HL7</strong> Schemas] > [<strong>HL7</strong> Message Structure] page makes it easy to see the differences between<br />

the two definitions, as the following two figures show.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 133


Viewing and Transforming Messages<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.4:ORD_O04<br />

<strong>Ensemble</strong> <strong>HL7</strong> Message Structure Page, DocType 2.5:ORD_O04<br />

5.3 The Document Viewer Page<br />

When you start the <strong>Ensemble</strong> Management Portal and select EDI / <strong>HL7</strong> Manager, the [<strong>Ensemble</strong>] > [EDI<br />

and <strong>HL7</strong> Manager] page displays. From here you can display the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager]<br />

> [EDI Document Viewer] page as follows:<br />

• In the ASC X12 row, click Document Viewer. The page displays with “X12 Document” selected<br />

in the View box. For details, see “The Document Viewer Page” in the “Viewing and Transforming<br />

Messages” chapter of the <strong>Ensemble</strong> X12 <strong>Development</strong> <strong>Guide</strong>.<br />

• In the ASTM row, click Document Viewer. The page displays with “ASTM Document” selected<br />

in the View box. For details, see “The Document Viewer Page” in the “Viewing and Transforming<br />

Messages” chapter of the <strong>Ensemble</strong> ASTM <strong>Development</strong> <strong>Guide</strong>.<br />

• In the <strong>HL7</strong> <strong>Version</strong> 2 row, click Message Viewer. The page displays with “<strong>HL7</strong> Message” selected<br />

in the View box. This chapter describes the <strong>HL7</strong> <strong>Version</strong> 2 features of the Document Viewer page.<br />

When “<strong>HL7</strong> Message” is selected, the Document Viewer page allows you to retrieve <strong>HL7</strong> message<br />

data from external files or the <strong>Ensemble</strong> message archives. You can:<br />

• Preview the results of applying various parsing schemes or data transformations to message data.<br />

134 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


• View an <strong>HL7</strong> message as if it belonged to a particular category of <strong>HL7</strong>.<br />

• Preview the results of an <strong>Ensemble</strong> data transformation by looking at the before-and-after contents<br />

of an <strong>HL7</strong> message.<br />

• Verify that you are using the correct category:structure syntax for the DocType of an <strong>HL7</strong> message.<br />

• Verify that you are using the correct segment:field syntax to use to access a specific data item<br />

within an <strong>HL7</strong> message.<br />

• Determine the DocType assignment that a particular business service would make for a particular<br />

message.<br />

• View the content of messages from the <strong>Ensemble</strong> persistent store.<br />

• View the content of messages from a file on disk.<br />

The Document Viewer Page<br />

The Document Viewer page allows you to try interpreting messages from a particular data source as<br />

version 2.1, or 2.2, etc., to determine which DocType is the right one to use when handling messages<br />

from that source. There are a variety of reasons why you might need to do this. For example, you might<br />

find when you update an external application that it has changed the actual version of the <strong>HL7</strong> messages<br />

it sends, but has neglected to update the <strong>HL7</strong> version declaration that it sends in these <strong>HL7</strong> messages.<br />

It is also useful in determining which of the built-in categories to use as a schema base, when a message<br />

contains Z-segments.<br />

In the following example, the chosen Source is Filename and the chosen DocType/Schema is Category.<br />

The message being viewed is message number 33 within an archive file called XYZ120. No data<br />

transformation is being applied to the message at the moment. This example highlights some useful<br />

features of the Viewer:<br />

• The MSH segment declares that the message is of type 2.2:ADT_O01, but the user has chosen<br />

Schema Category / <strong>Version</strong> with the category 2.3.1. The reason for this (not shown) is that when<br />

the user tried the message with Schema Category / <strong>Version</strong> 2.2 none of the message fields parsed<br />

correctly. The user moved on to try categories 2.3 and 2.3.1 before finding that 2.3.1 fit the message<br />

best.<br />

• After the user clicks View <strong>HL7</strong> Message, the bottom half of the page displays the results of parsing<br />

this message as a category 2.3.1 message. Links, such as for message segments 1 through 18,<br />

indicate that the message segments have parsed correctly using the selected Schema Category /<br />

<strong>Version</strong>. Clicking any of these links displays more specific information about the field.<br />

• Non-links, such as appear for segments 19 through 24 in the illustration, indicate that the parser<br />

is not able to understand these segments of the message using the selected Schema Category /<br />

<strong>Version</strong>. This is to be expected for Z-segments if you have chosen a standard schema like 2.3.1<br />

as the Schema Category / <strong>Version</strong>.<br />

• Just above the bottom half of the page, the parser reports that it has used a DocType of<br />

2.3.1:ADT_O01 to parse the messsage, and that there are Z-segments at the end of the message<br />

(ZPI and following) that do not conform to this DocType. If you find a Schema Category / <strong>Version</strong><br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 135


Viewing and Transforming Messages<br />

choice that allows the parser to understand all but the Z-segments in the message, then you know<br />

this standard schema is a good choice to be the basis of the custom schema that you create to parse<br />

the complete message including Z-segments.<br />

• After you create a custom schema, it becomes available as a choice from the Schema Category /<br />

<strong>Version</strong> list.<br />

Document Viewer Page<br />

5.3.1 Viewing a Message<br />

To view a message using the Document Viewer page:<br />

1. Ensure that the View choice is <strong>HL7</strong> Message.<br />

136 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The Document Viewer Page<br />

2. Click a radio button to choose a Source and enter the required details.<br />

3. Click a radio button to choose a DocType and enter the required details.<br />

4. Optionally, select the Apply Data Transform check box and enter the required details.<br />

5. Click View <strong>HL7</strong> Message.<br />

6. View the display.<br />

The following discussion describes these steps in detail.<br />

Source for Message Data<br />

Click a radio button to choose a Source for Message Data. The choices are:<br />

• Filename — Click the Browse button to find a file that contains <strong>HL7</strong> message data. Enter a number<br />

in the Message # inside file field.<br />

• Message Header Id — Enter the object identifier of an <strong>Ensemble</strong> message.<br />

• <strong>HL7</strong> Message Id — Enter the object identifier of an <strong>HL7</strong> message body object.<br />

DocType or Schema for Message Data<br />

Click a radio button to choose a Source for <strong>HL7</strong> Message DocType. The choices are:<br />

• ProductionName || ConfigName | CommentOrClassname — Choose from the drop-down list of<br />

production items.<br />

• Schema Category / <strong>Version</strong> — Choose an <strong>HL7</strong> category from the drop-down list.<br />

• <strong>HL7</strong> Message Type (<strong>Version</strong>:Name) — Enter the name of an <strong>HL7</strong> message type ()<br />

in the format category:type. The parser uses the message structure associated with the given<br />

message type.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 137


Viewing and Transforming Messages<br />

• Use this DocType — Enter the name of an <strong>HL7</strong> message structure () in the<br />

format category:structure. The parser uses this message structure.<br />

• MSH declared <strong>Version</strong>:Name — The parser uses the message structure associated with the message<br />

type declared in the MSH segment of the message.<br />

• Object’s saved DocType — The parser uses the DocType as declared in the <strong>HL7</strong> message body<br />

object. (This option does not apply to stored messages loaded from a file.)<br />

• None — The parser does not use any DocType to parse the message. It displays the raw segments<br />

without transforming any of them into links.<br />

Applying a Data Transformation<br />

If you want to apply a data transformation to the <strong>HL7</strong> message data, select the Apply Data Transform<br />

check box and enter the full package and class name of an <strong>Ensemble</strong> data transformation. From here<br />

you have two options:<br />

• View the transformation on the [<strong>Ensemble</strong>] > [EDI and <strong>HL7</strong> Manager] > [EDI Document Viewer]<br />

page. To do this:<br />

- Click one of the following radio buttons to determine the display format for the resulting <strong>HL7</strong><br />

message data:<br />

• Show Output Only — The transformed message appears in place of the original message<br />

on the page.<br />

• Show Input and Output side-by-side — The format is the same, but you must use horizontal<br />

scroll bars to see all the data.<br />

- Click the View <strong>HL7</strong> Message button.<br />

• Save the transformed message to a file. To do this, enter a pathname in the field beside the Save<br />

To File button and click the button.<br />

5.3.2 Parsing the Message<br />

After you enter your choices and click View <strong>HL7</strong> Message, the Document Viewer page page displays<br />

a summary report, followed by the message data in the bottom half of the screen. The report looks like<br />

the following example. It echoes the Source, DocType, and Data Transform choices and reports the<br />

BuildMapStatus that resulted from the attempt to parse the message. In the following example, the<br />

BuildMapStatus reveals that an unrecognized Z-segment was found in the message.<br />

138 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


The Document Viewer Page<br />

Document Viewer Parsing Summary<br />

Following this report, the Document Viewer page displays the message data. This is the same view<br />

available on the [<strong>Ensemble</strong>] > [Messages] page when the Contents link is selected and the message<br />

contains <strong>HL7</strong> data. There is one row in the display for each segment in the message structure. From<br />

left to right, the entries in each line reads as follows:<br />

• The segment number on a white background: 1, 2, 3, etc.<br />

• The segment name on a shaded background: MSH, PID, etc.<br />

• Field contents and separator characters, exactly as provided in the message.<br />

5.3.3 Displaying the Segment Address<br />

If you hover the cursor over a segment name in the shaded column, a hover-text help window displays<br />

the following information:<br />

• The segment address to use in a virtual property path.<br />

• The descriptive name of this segment.<br />

See the following close-up from a Document Viewer display of message contents. The cursor is hovering<br />

over the segment name NK1 which is segment number 5. The segment address is NK1(1) and<br />

the meaning of the segment is “next of kin / associated parties.”<br />

Document Viewer Showing Hover-Text Help for Segment Address<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 139


Viewing and Transforming Messages<br />

5.3.4 Displaying the Field Address<br />

If you hover the cursor over a field anywhere within the message structure, a hover-text help window<br />

displays the following information:<br />

• The field address to use in a virtual property path (as a number)<br />

• The field address to use in a virtual property path (as a name)<br />

• Characters that indicate the syntax rules for this field. The characters can begin with:<br />

Symbol<br />

!<br />

<br />

+<br />

*<br />

&<br />

n*<br />

(m)<br />

Meaning<br />

(1 only) The field is required; it must occur only once.<br />

(0 or 1) The field is optional, but if it occurs, it may occur only once.<br />

(1 or more) The field may repeat one or more times.<br />

(0 or more) The field may repeat zero or more times.<br />

The field may be present, and may repeat, but only under certain<br />

conditions.<br />

(0 to n) The field repeats a maximum of n times.<br />

m is the maximum number of characters in the field. Each repeat of the<br />

field may contain this number of characters.<br />

See the following close-up from a Document Viewer display of message contents. The cursor is hovering<br />

over the second data item in the NK1 segment, which contains the string “Taylor”. The field<br />

address is 2.1 or Name.familylastname. The field may repeat zero or more times. Each repeat of the<br />

field has a maximum length of 48 characters.<br />

140 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Document Viewer Showing Hover-Text Help for Field Address<br />

The Document Viewer Page<br />

5.3.5 Viewing Batch Messages<br />

Suppose you enter choices and click View <strong>HL7</strong> Message as described in the section “Viewing a Message.”<br />

Now suppose the message you have chosen to view is not a single <strong>HL7</strong> message but a group<br />

of <strong>HL7</strong> messages in batch format. Rather than open each batch message directly, the Message Viewer<br />

allows you to walk through the batch message structure one level at a time.<br />

The following display is the result of asking to view a batch message that begins with an FHS segment.<br />

<strong>Ensemble</strong> parses the batch message and finds that it has 3 segments: FHS, FTS, and a block of child<br />

documents in between. The block contains two child documents; each beginning with BHS and ending<br />

with BTS. The message is a two-level batch message.<br />

The Message Viewer assigns the child documents the identifiers and . It displays the toplevel<br />

parent document, using links ( and ) to represent the two child documents. The display<br />

is as follows:<br />

<strong>HL7</strong> Batch Message with FHS and BHS,Top-Level Parent Document<br />

When you click on a child document link in an <strong>HL7</strong> batch message display, a new browser window<br />

opens to display the child document. The Message Viewer window, with the top-level parent, remains<br />

open in the original browser window.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 141


Viewing and Transforming Messages<br />

The next display is the result of clicking the child document link in the previous display. This<br />

example is a two-level batch message, so the child document has children of its own: child documents<br />

through .<br />

This example highlights a useful navigation feature of the Message Viewer. If there are more than 10<br />

child documents in a batch message, the Message Viewer displays links to the first five and last five<br />

child documents. Between the lists is a text field, into which you can enter any identifier number<br />

between the first and last numbers. After you enter a number, click Other. A new browser window<br />

opens to display the child document.<br />

<strong>HL7</strong> Batch Message with FHS and BHS, Mid-Level Parent Document<br />

The next display is the result of clicking the child document link in the previous display. Since<br />

this is the lowest level of the batch message hierarchy, message is a normal <strong>HL7</strong> <strong>Version</strong> 2 message<br />

that begins with an MSH segment.<br />

142 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


<strong>HL7</strong> Batch Message with FHS and BHS, Child Document<br />

The Document Viewer Page<br />

When you are done viewing messages in the batch message hierarchy, you can close all the pop-up<br />

browser windows until the top-level parent document remains in the original Message Viewer window.<br />

From here, you may return to other <strong>Ensemble</strong> Management Portal activities.<br />

5.3.6 Saving the Output to a File<br />

While viewing the Document Viewer summary and message data that result from clicking View <strong>HL7</strong><br />

Message, you might want to save the message data to a text file. If so, enter a value in the Save to File<br />

field to the right of the data transformation selections, and click Save to File.<br />

• If you enter a full path and filename, the file is saved to that location. The path must already exist<br />

on the system.<br />

• If you enter only a filename, the file is saved in the management directory for the active namespace.<br />

For example, if you installed <strong>Ensemble</strong> into the directory C:\MyCache and your current namespace<br />

is ENSEMBLE, the file is saved as follows:<br />

C:\MyCache\Mgr\ENSEMBLE\filename<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 143


Viewing and Transforming Messages<br />

5.4 Filtering <strong>HL7</strong> Messages<br />

The <strong>Ensemble</strong> Management Portal [<strong>Ensemble</strong>] > [Messages] page allows you to filter the <strong>Ensemble</strong><br />

message archive based on fields in the message data. Even virtual properties can be searched, as long<br />

as you follow specific rules. You can:<br />

• Apply basic filter criteria, such as the time of day when the message was sent.<br />

• Apply detailed filter criteria, such as the presence of a specific field or value in the data.<br />

• Archive a specific set of filter criteria and retrieve it for later use.<br />

• Display a list of messages that match your filter criteria.<br />

• View, compare, or resend the messages in the list.<br />

For detailed instructions, see the section “Message Filter” in the “Message Browser” chapter of<br />

Managing <strong>Ensemble</strong> Productions.<br />

5.5 Comparing <strong>HL7</strong> Messages<br />

The <strong>Ensemble</strong> Management Portal [<strong>Ensemble</strong>] > [Messages] page allows you to compare the contents<br />

of two messages. Select the check box beside each of two messages in the list, then click the Compare<br />

Messages link at the top of the page. The two messages display side by side. To return to the<br />

[<strong>Ensemble</strong>] > [Messages] page, click the browser’s Back button.<br />

For detailed instructions, see the section “Message Contents” in the “Message Browser” chapter of<br />

Managing <strong>Ensemble</strong> Productions.<br />

144 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


6<br />

Converting Interfaces to <strong>Ensemble</strong><br />

The following diagram shows some of the information technology required to run a typical hospital.<br />

The diagram reflects the complex challenges faced by hospital IT staff. In the diagram, the various<br />

end-user applications exchange <strong>HL7</strong> messages with the lab information system and hospital information<br />

system (HIS). An interface engine routes <strong>HL7</strong> messages between the systems. Not all hospital applications<br />

are shown; the focus is on the <strong>HL7</strong> messages that enter and leave the interface engine.<br />

This chapter assumes that for each clinical application, you might need to define both inbound and<br />

outbound interfaces. The figure illustrates this by providing a circle at the source of each type of<br />

message and an arrow at each destination. Various combinations of inbound and outbound interfaces<br />

are shown. Within this chapter, an interface is inbound or outbound relative to the clinical application.<br />

An inbound interface receives messages from the HIS or lab system via the interface engine. An outbound<br />

interface sends messages to the HIS or lab system via the interface engine. Other interfaces<br />

within the hospital IT configuration are outside the scope of this chapter, even if they appear in the<br />

diagram.<br />

In the diagram, solid arrows represent real-time information exchange; dotted arrows represent batch<br />

transmissions. Variations in arrow color highlight the different categories of data: green for admitting,<br />

yellow for pharmacy, gold for patients, orange for scheduling, pink for master file notifications, purple<br />

for transactions, aqua for requisitions, blue for laboratory, gray for physicians, and black for vendors.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 145


Converting Interfaces to <strong>Ensemble</strong><br />

Hospital IT Configuration Featuring an Interface Engine<br />

146 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Often when you bring <strong>Ensemble</strong> into such a configuration, it is for the purpose of replacing an existing<br />

interface engine with <strong>Ensemble</strong>. In order to do this you must:<br />

1. Use an <strong>Ensemble</strong> production as a routing engine, as described in previous chapters.<br />

2. Convert each of the existing interfaces to use the <strong>Ensemble</strong> routing engine instead of the previous<br />

interface engine.<br />

3. Once all of the interfaces are converted, remove the previous interface engine from the configuration.<br />

The conversion approach in this chapter leaves the existing interface engine in place and converts the<br />

interfaces one by one to use <strong>Ensemble</strong>. Unconverted interfaces continue to use the previous engine<br />

while you test and confirm that the new interface works properly using <strong>Ensemble</strong>. As soon as the<br />

converted interface works correctly, you begin work on the next unconverted interface. This incremental<br />

change policy ensures the best chance of uninterrupted, error-free service during the conversion.<br />

You could take an approach that converts groups of related interfaces at the same time. That is, you<br />

could decide to convert all of the interfaces that convey messages to and from the Blood Bank application,<br />

then move on to Fetal Monitoring. Still, you may find that the work boils down to converting<br />

one interface at a time.<br />

This chapter explains how to convert one existing <strong>HL7</strong> interface to use <strong>Ensemble</strong>. The general steps<br />

are as follows. Each section of this chapter describes one of these steps in detail:<br />

1. Back up the production<br />

2. Describe the interface<br />

3. Choose schema categories<br />

4. Create data transformations<br />

5. Define routing rules<br />

6. Add business operations<br />

7. Create or edit a routing process<br />

8. Add business services<br />

9. Test the interface<br />

10. Deploy the interface<br />

The procedure in this chapter reverses the order in which you would usually describe an <strong>Ensemble</strong><br />

production. (“An <strong>HL7</strong> business service receives an incoming message...”) However, experience with<br />

interface conversion shows that if you develop the elements top-down, beginning with the business<br />

service and working down to the custom schema, you must often backtrack to previous steps to fill in<br />

or correct the names of the lower-level items, in the various forms where you have configured higherlevel<br />

items.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 147


Converting Interfaces to <strong>Ensemble</strong><br />

The procedure in this chapter takes a bottom-up approach, reducing backtracking to a minimum by<br />

creating the lower-level items first, so that their names are known when it is time to configure the<br />

higher-level items. Bottom-up order works as shown in this chapter: Steps 1 and 2; Steps 3, 4, 5, 6, 7,<br />

8; Steps 9 and 10.<br />

You might have success performing this procedure in top-down order, especially if you have wellestablished<br />

naming conventions, which reduce simple errors. Top-down order works as follows: Steps<br />

1 and 2; Steps 8, 7, 6, 5, 4, 3; Steps 9 and 10.<br />

6.1 Backing Up the Production<br />

The following steps outline a general-purpose backup procedure for <strong>Ensemble</strong> productions that use<br />

<strong>HL7</strong>. The exact steps will vary depending on your packaging and naming conventions for <strong>Ensemble</strong><br />

classes, custom classes, routing rules, and custom <strong>HL7</strong> category definitions.<br />

Note:<br />

Regarding XML backup files: If you use a UNIX system, never FTP a backup XML file in<br />

binary mode. Regular FTP will convert this file from DOS to UNIX properly, but binary<br />

FTP might not.<br />

6.1.1 Backup from Studio<br />

To perform a full backup from Studio:<br />

1. Start Studio and change to the <strong>Ensemble</strong>-enabled namespace that you are backing up.<br />

2. Export your own package(s) of classes from Studio. This should export all of your business service,<br />

business process, business operation, data transformation, and utility classes. To back up a package:<br />

• Select the package name in the Workspace window<br />

• Right-click and select Export from the context menu.<br />

• Select the Export in XML format check box, choose an appropriate file name, and click OK.<br />

If necessary, rather than choosing a package you can select individual classes for export from<br />

Studio:<br />

• Select Tools and Export, then click Add.<br />

• Choose Files of type All Files, enter File name *.cls, then click Open.<br />

• Select your classes from the list and click Open to add them to the Export list.<br />

• Select the Export in XML format check box, choose an appropriate file name, and click OK.<br />

148 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Backing Up the Production<br />

3. Export your own business rules (File name *.rul).<br />

4. Export your own Custom Schemas (File name *.hl7).<br />

5. The resulting XML file(s) can be imported into any <strong>Ensemble</strong>-enabled namespace.<br />

6.1.2 Backup from ObjectScript<br />

The steps in the above procedure can be cumbersome if you need to repeat them often from <strong>Ensemble</strong><br />

Studio. You should code them into an ObjectScript method as soon as is convenient. The exact code<br />

will vary, depending on your packaging and naming conventions for <strong>Ensemble</strong> classes, custom classes<br />

(including data transformations), business rules, and custom category definitions. The general idea is<br />

that an ObjectScript version of this procedure would create a single master list of all items to be<br />

exported, and then export everything on the list to a single XML file, appropriately dated. In detail:<br />

1. Use the $system.OBJ.GetPackageList method with the ObjectScript $ORDER or $O function to<br />

assemble a list of all classes (*.cls) in each of the packages of interest. The code for each<br />

package will look something like the following example for a custom package named Mutro:<br />

do $system.OBJ.GetPackageList(.tList,"Mutro","ars")<br />

set class="" for {<br />

set class=$o(tList(class)) quit:class=""<br />

set tFullList(class_".cls")=""<br />

}<br />

For more information about ObjectScript functions like $ORDER and $EXTRACT, see the<br />

“Caché ObjectScript Functions” chapter in the Caché ObjectScript Reference.<br />

2. Use the ^Ens.Rule.RuleDefinitionD global and the $ORDER function to assemble a list<br />

of all business rules (*.rul) within the <strong>Ensemble</strong>-enabled namespace, something like the following:<br />

set p="" for {<br />

set p=$o(^Ens.Rule.RuleDefinitionD(p)) q:p=""<br />

set r="" for {<br />

set r=$o(^Ens.Rule.RuleDefinitionD(p,r)) q:r=""<br />

set tFullList(p_"."_r_".rul")=""<br />

}<br />

}<br />

3. Use the ^Ens<strong>HL7</strong>.Schema global and the ObjectScript functions $ORDER and $EXTRACT to<br />

assemble a list of all custom schemas (*.hl7) within the <strong>Ensemble</strong>-enabled namespace. In the<br />

following example, the list is easily created because the customer used a naming convention for<br />

custom schemas; all names start with the prefix Mutro_:<br />

set cat="" for {<br />

set cat=$o(^Ens<strong>HL7</strong>.Schema(cat)) quit:cat=""<br />

if $e(cat,1,6)="Mutro_" set tFullList(cat_".hl7")=""<br />

}<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 149


Converting Interfaces to <strong>Ensemble</strong><br />

4. Set the output directory, construct the XML filename using a time stamp, and export the files.<br />

Something like:<br />

; Normalize the directory name and figure the file name<br />

if pDir'="" set pDir=$tr(pDir,"\","/")<br />

if $e(pDir,$l(pDir))'="/" set pDir=pDir_"/"<br />

for count=1:1 {<br />

set filename=pDir_"backup_"_$zdate($h,8)_"_"_count_".xml"<br />

quit:##class(%File).Exists(filename)=0<br />

}<br />

;<br />

; Export all the items on the list<br />

Set tSC=$system.OBJ.Export(.tFullList,pDir_"backup_"_$zdate($h,8)_".xml")<br />

Do:('tSC) $system.Status.DisplayError(tSC)<br />

;<br />

Set tSC=$system.OBJ.Export(.tFullList,filename)<br />

Do:('tSC) $system.Status.DisplayError(tSC)<br />

;<br />

write !,"Backup to file "_filename_" done.",!<br />

The above example expects a parameter pDir to be passed to the method, but pDir can quite easily<br />

be set to a specific directory by the backup method. The example uses the ObjectScript functions<br />

$TRANSLATE, $EXTRACT, $ZDATE, and $HOROLOG as well as the %File.Exists and<br />

$system.OBJ.Export methods.<br />

6.2 Describing the Interface<br />

Each clinical application in use at the enterprise provides its own <strong>HL7</strong> application specification document.<br />

The specification document explains which types of <strong>HL7</strong> event the application can send (or<br />

receive), and which message segments and pieces of each segment the application sends (or expects)<br />

for these events. For example, for an MSH segment the <strong>HL7</strong> application specification document shows<br />

exactly what the segment will look like, what will be hard-coded, what format will be used for strings,<br />

etc. The information is extremely detailed. The administrator of each clinical application can show<br />

you this document for his or her application.<br />

The source and target applications each have an <strong>HL7</strong> application specification document. However,<br />

any single interface between these applications, such as the interface that you are converting, uses a<br />

small subset of the possibilities listed in the specification document. Your best source for a description<br />

of an interface is actually the interface definition that you are replacing.<br />

Open the existing interface definition (for example, in eGate, the collaboration rule). With this definition<br />

in view, open a text file and type into it a brief description of what the interface does. Do not try to<br />

reproduce the coding conventions of the existing definition (LOOP, CASE, etc.) in detail. Simply<br />

identify:<br />

• The message segments that you expect to arrive from the source<br />

• How the interface changes them before sending them to the target<br />

150 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


In preparing a description of an interface that you are converting to <strong>Ensemble</strong>, it can be helpful to<br />

compare terminology between the technology you are replacing and <strong>Ensemble</strong>. As an example, the<br />

following table lists analogies between SeeBeyond and <strong>Ensemble</strong> terminology.<br />

Sample Comparison of Interface Terms: SeeBeyond and <strong>Ensemble</strong><br />

Describing the Interface<br />

SeeBeyond<br />

Collaboration rule<br />

COPY or DUPLICATE<br />

DISPLAY<br />

LOOP<br />

IF<br />

CASE<br />

FUNCTION<br />

CHANGE-PATTERN<br />

<strong>Ensemble</strong><br />

Interface definition<br />

statement in a DTL data transformation<br />

statement in a DTL data transformation<br />

or the shorthand notation () in DTL<br />

statement in a DTL data transformation<br />

Routing rule<br />

Code in business services or business operations; also <br />

Text replacement using functions like $CHAR and $PIECE<br />

6.2.1 The Inbound Interface<br />

Suppose you have a source application from which a variety of <strong>HL7</strong> messages arrive. However, only<br />

ancillary orders are of interest, and then only for certain types of patients, certain types of orders, and<br />

when the message is genuine and not a test of the system. In describing which messages are of interest<br />

from this source, you might type something like:<br />

Send only:<br />

Message Type "ORM_O01 "<br />

PV1:18 Patient Type = "ER" or "ECM" or "ERQ"<br />

ORC:1 Order Control = "NW" or "CA" or "OC"<br />

PID:5 Last Name not "TEST"<br />

6.2.2 The Outbound Interface<br />

How the interface changes these message segments, before sending them, depends on what the target<br />

application needs to receive. Based on your knowledge of the interface and the sources of information<br />

listed above, you might type something like:<br />

Copy source MSH to target.<br />

Set target MSH:11 Processing ID = "P".<br />

Copy source MSH:10 Control ID to target MSH:13 Sequence Number.<br />

Copy source PID to target.<br />

Set target PID:1 Set ID = "1".<br />

Copy source PID:2 Patient External ID<br />

to the 2nd repetition of target PID:3 Patient Internal ID and<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 151


Converting Interfaces to <strong>Ensemble</strong><br />

set its Identifier Type = "PI".<br />

Null out target PID:2.<br />

Copy source ORC to target.<br />

If source ORC:1 Order Control = "CA" or "OC",<br />

then set target ORC:5 Order Status to "CA".<br />

If source ORC:2.1 Placer Order Number is empty, then<br />

copy source ORC:3.1 Filler Order Number<br />

to target ORC:2.1 Placer Order Number and<br />

set target ORC:2.2 Placer Application = "ULTRA".<br />

Set target ORC:3.2 Filler Application = "ULTRA".<br />

Copy source OBR to target.<br />

If source OBR:2.1 Placer Order Number is empty, then<br />

copy source OBR:3.1 Filler Order Number<br />

to target OBR:2.1 Placer Order Number and<br />

set target OBR:2.2 Placer Application = "ULTRA".<br />

Set target OBR:3.2 Filler Application = "ULTRA".<br />

Set target OBR:4.3 Coding Scheme (SIM Department) = "LAB".<br />

6.3 Choosing Schema Categories<br />

In this step, you must determine which <strong>HL7</strong> schema will be used for the inbound and outbound sides<br />

of the interface. This begins with an approximate choice, which you refine by testing messages against<br />

that schema in the <strong>Ensemble</strong> Management Portal.<br />

Each clinical application has an <strong>HL7</strong> application specification document that identifies the <strong>HL7</strong> schema<br />

version that it uses when sending messages, and that it expects when receiving messages. You can<br />

confirm this version against the message data sent by the application. Its outgoing message MSH<br />

segment states an <strong>HL7</strong> version number that (in theory) announces what <strong>HL7</strong> version the application<br />

is using.<br />

You may discover that neither source of information is strictly accurate. Clinical applications can<br />

update their <strong>HL7</strong> versions at different times so that one application uses a new <strong>HL7</strong> version and another<br />

does not. Applications can upgrade <strong>HL7</strong> versions or add or change Z segments or without changing<br />

the contents of the MSH segment or documenting the change.<br />

6.3.1 Choosing an Incoming Schema Category<br />

Choose a schema category for the inbound side of the interface (as the message enters <strong>Ensemble</strong> via<br />

an <strong>HL7</strong> business service) as follows:<br />

1. Capture some sample messages from the source application in text files. You can use archived<br />

file copies of these messages, if you have them.<br />

2. Start the <strong>Ensemble</strong> Management Portal.<br />

3. Choose the EDI / <strong>HL7</strong> Manager menu, Schema Structures option, browse, and choose an <strong>HL7</strong><br />

standard schema that seems to match the structure of the message segments you are interested in.<br />

152 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Creating Data Transformations<br />

4. Choose the EDI / <strong>HL7</strong> Manager menu, Message Viewer option, and test your text file messages<br />

against your chosen schema. Try different choices of schema until you find the standard schema<br />

that most closely matches your message structure.<br />

Tip:<br />

Do not be concerned with the specific <strong>HL7</strong> separator characters expected on each side of<br />

the interface. The <strong>HL7</strong> business operation handles these appropriately.<br />

5. The messages from the source application might contain extra segments that are not in the schema.<br />

If so, when you parse the messages using the Message Viewer option, the messages may either<br />

accept the message, or generate a bad message error, as follows:<br />

• If the message contains extra Z segments, and the schema defines those Z segments, the<br />

message is okay.<br />

• If the message contains extra Z segments, but the schema does not define any Z segments,<br />

the message is okay.<br />

• If the message contains extra Z segments, and the schema defines Z segments, but the Z<br />

segments found in the message do not match the Z segments in the schema, it is a bad message.<br />

• If the message contains extra non-Z segments, then regardless of Z segments, it is a bad<br />

message.<br />

6. If the messages trigger one of the bad message error conditions, try choosing a different standard<br />

schema, and if that does not work, you must create a custom <strong>HL7</strong> category definition to accommodate<br />

the non-standard message structure.<br />

6.3.2 Choosing an Outgoing Schema Category<br />

Repeat a similar procedure to choose a schema for the outbound interface.<br />

6.4 Creating Data Transformations<br />

Create DTL data transformations. For details, see the “DTL Data Transformations for <strong>HL7</strong>” section<br />

in the chapter “Elements of a Routing Production.”<br />

6.5 Defining Routing Rule Sets<br />

Create routing rule sets. For details, see the “Routing Rule Sets for <strong>HL7</strong>” section in the chapter<br />

“Elements of a Routing Production.”<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 153


Converting Interfaces to <strong>Ensemble</strong><br />

6.6 Adding Business Operations<br />

The business operation for an <strong>HL7</strong> interface controls the outgoing message transmission to the target<br />

application. For testing purposes, it is useful to configure a production with two <strong>HL7</strong> business operations<br />

that have the same configuration name:<br />

• One is an FTP or TCP business operation that controls the FTP or TCP transmission of <strong>HL7</strong><br />

messages across the interface when the production is running normally.<br />

• The other is a File business operation that sends <strong>HL7</strong> messages to a file during testing or troubleshooting<br />

of the interface.<br />

By <strong>Ensemble</strong> convention (the items have the same configured name) only one of these configuration<br />

items can be enabled at a time. Enable one or the other depending on whether you want a “test” environment<br />

(the File operation) or a “live” environment (the TCP or FTP operation).<br />

The steps to create a “live” business operation and its “test” counterpart are as follows:<br />

1. Examine the target application to see which separators it expects <strong>HL7</strong> messages to contain.<br />

2. Create the “live” (FTP or TCP) <strong>HL7</strong> business operation as described in previous chapters.<br />

3. Use similar steps to create a “test” (File) <strong>HL7</strong> business operation.<br />

Give the “test” (File) operation the same configuration Name as the “live” one.<br />

4. Use the Enabled field to enable and disable the “live” (FTP or TCP) or “test” (File) versions of<br />

the business operation. Only one business service of the same name can be active at one time.<br />

6.7 Creating or Editing a Routing Process<br />

To enable your new interface to work with the <strong>Ensemble</strong> routing engine, you must add a routing process<br />

to the production that:<br />

1. Tells how to interpret data from the source (identifies a routing rule)<br />

2. Tells where to send the interpreted data (identifies a business operation)<br />

You can create a new <strong>HL7</strong> routing process as described in previous chapters.<br />

154 <strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong>


Adding Business Services<br />

6.8 Adding Business Services<br />

The business service for an <strong>HL7</strong> interface receives the incoming messages from the source application.<br />

For testing purposes, it is useful to configure a production with two <strong>HL7</strong> business services that have<br />

the same configuration name:<br />

• One is an FTP or TCP business service that receives <strong>HL7</strong> messages from the source application<br />

via FTP or TCP when the production is running normally.<br />

• The other is a File business service that receives <strong>HL7</strong> messages from a file during testing or<br />

troubleshooting of the interface.<br />

By <strong>Ensemble</strong> convention (the items have the same configured name) only one of these configuration<br />

items can be enabled at a time. Enable one or the other depending on whether you want a “test” environment<br />

(the File service) or a “live” environment (the TCP or FTP service).<br />

The steps to create a “live” business service and its “test” counterpart are as follows:<br />

1. Create the “live” (FTP or TCP) <strong>HL7</strong> business service as described in previous chapters.<br />

2. Use similar steps to create a “test” (File) <strong>HL7</strong> business service.<br />

Give the “test” (File) service the same configuration Name as the “live” one.<br />

3. Use the Enabled field to enable and disable the “live” (FTP or TCP) or “test” (File) versions of<br />

the business service. Only one business service of the same name can be active at one time.<br />

6.9 Testing the Interface<br />

Generally you need to maintain a separate “test” production that is an exact copy of the production<br />

that runs “live” at your health facility. Develop the new <strong>Ensemble</strong> interface within the “test” production.<br />

When that is done, you can migrate a copy of the new interface to the “live” production.<br />

To test a new interface:<br />

1. Capture some sample messages from the source application in files.<br />

2. In the “test” production, enable the File business service and the File business operation and send<br />

the messages as files.<br />

3. Examine the resulting <strong>HL7</strong> message data in the output files to see if it meets the requirements for<br />

the target application.<br />

4. If necessary, adjust the interface elements and retest.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 155


Converting Interfaces to <strong>Ensemble</strong><br />

5. Selectively disable the “test” (File) versions and re-enable the “live” (FTP or TCP) versions of<br />

the business service and business operation, still within the “test” production.<br />

6.10 Deploying the Interface<br />

Once you have completed testing the <strong>Ensemble</strong> interface in the test production, it is time to add the<br />

new <strong>Ensemble</strong> interface elements to the production that you are running live. To do this:<br />

1. Back up the complete live production as described in the first step of this procedure.<br />

2. Export the new elements of the test production, created in the previous steps:<br />

• Export the new classes for the interface: business process, data transformation(s), business<br />

operations, business services, and any utility classes.<br />

• Export the business rule(s) *.rul<br />

• Export the custom schema(s) *.hl7<br />

3. Copy the new XML elements that the new interface added to the XDATA section of the<br />

production class. For example:<br />

Configuration Item<br />

Business service (Test)<br />

Business service (Live)<br />

Business process (if new)<br />

Business operation (Test)<br />

Business operation (Live)<br />

Sample Start of Element<br />


Deploying the Interface<br />

5. Optionally, configure alerts for the new production elements:<br />

• <strong>HL7</strong> business service and business operations have a configuration setting called Alert On<br />

Error. When Alert On Error is set to True, as soon as the item encounters any type of error<br />

condition it automatically triggers an alert. An alert writes a message to the <strong>Ensemble</strong> event<br />

log and can also send notification to a user via email or pager. Setting Alert On Error to False<br />

disables the option.<br />

• Alert Grace Period (for business services) and Alert Retry Grace Period (for business operations)<br />

offer useful constraints on the frequency of alerts when they are enabled.<br />

Note:<br />

This procedure describes how to add interfaces to the “live” production one by one.<br />

Alerts are easy to configure as described in this step, once they have been set up. To set<br />

them up for the “test” or “live” production, see the “Pager and Email Alerts” section<br />

in the chapter “Elements of a Routing Production.”<br />

6. Ensure that the new interface is processing all new messages.<br />

7. Disable or clean up the previous interface technology:<br />

• Ensure that all previously pending requests are satisfied and all queues are empty.<br />

• Disable the old interface. For eGate elements, disable the “start automatically” option.<br />

<strong>Ensemble</strong> <strong>HL7</strong> <strong>Version</strong> 2 <strong>Development</strong> <strong>Guide</strong> 157

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

Saved successfully!

Ooh no, something went wrong!