Ensemble HL7 Version 2 Development Guide: 25 April 2011
Ensemble HL7 Version 2 Development Guide: 25 April 2011
Ensemble HL7 Version 2 Development Guide: 25 April 2011
Ensemble HL7 Version 2 Development Guide Ensemble Version 2010.2 25 April 2011 Copyright 2011 InterSystems Corporation All rights reserved. This book was assembled and formatted in Adobe Page Description Format (PDF) using tools and information from the following sources: Sun Microsystems, RenderX, Inc., Adobe Systems, and the World Wide Web Consortium at www.w3c.org.The primary document development tools were special-purpose XML-processing applications built by InterSystems using Cach and Java.
and Cach WEBLINK, Distributed Cache Protocol, M/SQL, M/NET, and M/PACT are registered trademarks of InterSystems Corporation.
and
InterSystems Jalapeo Technology, Enterprise Cache Protocol, ECP, and InterSystems Zen are trademarks of InterSystems Corporation. All other brand or product names used herein are trademarks or registered trademarks of their respective companies or organizations. This document contains trade secret and confidential information which is the property of InterSystems Corporation, One Memorial Drive, Cambridge, MA 02142, or its affiliates, and is furnished for the sole purpose of the operation and maintenance of the products of InterSystems Corporation. No part of this publication is to be used for any other purpose, and this publication is not to be reproduced, copied, disclosed, transmitted, stored in a retrieval system or translated into any human or computer language, in any form, by any means, in whole or in part, without the express prior written consent of InterSystems Corporation. The copying, use and disposition of this document and the software programs described herein is prohibited except to the limited extent set forth in the standard software license agreement(s) of InterSystems Corporation covering such programs and related documentation. InterSystems Corporation makes no representations and warranties concerning such software programs other than those set forth in such standard software license agreement(s). In addition, the liability of InterSystems Corporation for any losses or damages relating to or arising out of the use of such software programs is limited in the manner set forth in such standard software license agreement(s). THE FOREGOING IS A GENERAL SUMMARY OF THE RESTRICTIONS AND LIMITATIONS IMPOSED BY INTERSYSTEMS CORPORATION ON THE USE OF, AND LIABILITY ARISING FROM, ITS COMPUTER SOFTWARE. FOR COMPLETE INFORMATION REFERENCE SHOULD BE MADE TO THE STANDARD SOFTWARE LICENSE AGREEMENT(S) OF INTERSYSTEMS CORPORATION, COPIES OF WHICH WILL BE MADE AVAILABLE UPON REQUEST. InterSystems Corporation disclaims responsibility for errors which may appear in this document, and it reserves the right, in its sole discretion and without notice, to make substitutions and modifications in the products and practices described in this document. For Support questions about any InterSystems products, contact: InterSystems Worldwide Customer Support Tel: +1 617 621-0700 Fax: +1 617 374-9391 Email: [email protected]
Table of Contents
About This Book .................................................................................................................................... 1 1 Ensemble HL7 Version 2 Support ..................................................................................................... 3 2 Elements of a Routing Production .................................................................................................... 5 2.1 Building the Production ............................................................................................................. 5 2.2 HL7 Business Services ............................................................................................................... 6 2.2.1 Creating an HL7 Business Service ................................................................................... 6 2.2.2 Configuring an HL7 Business Service ............................................................................. 7 2.2.3 Integrating an HL7 Business Service ............................................................................. 11 2.3 HL7 Custom Schema Categories ............................................................................................. 12 2.4 HL7 Routing Processes ............................................................................................................ 14 2.4.1 Creating an HL7 Routing Process .................................................................................. 14 2.4.2 Configuring an HL7 Routing Process ............................................................................ 14 2.4.3 Integrating an HL7 Routing Process .............................................................................. 16 2.5 HL7 Sequence Manager ........................................................................................................... 16 2.5.1 Creating an HL7 Sequence Manager ............................................................................. 17 2.5.2 Configuring an HL7 Sequence Manager ....................................................................... 17 2.5.3 Integrating an HL7 Sequence Manager .......................................................................... 20 2.5.4 Accessing HL7 Sequence Data Programmatically ......................................................... 21 2.6 Routing Rule Sets for HL7 ....................................................................................................... 22 2.7 DTL Data Transformations for HL7 ........................................................................................ 28 2.7.1 Utility Functions ............................................................................................................ 31 2.7.2 Utility Class Methods ..................................................................................................... 32 2.8 HL7 Business Operations ......................................................................................................... 32 2.8.1 Creating an HL7 Business Operation ............................................................................. 32 2.8.2 Configuring an HL7 Business Operation ....................................................................... 33 2.8.3 Integrating an HL7 Business Operation ......................................................................... 36 2.9 Pager and Email Alerts ............................................................................................................. 36 2.10 HL7 Search Tables ................................................................................................................. 37 3 Settings for a Routing Production ................................................................................................... 43 3.1 HL7 Message Validation and Bad Messages ............................................................................ 43 3.1.1 The d Validation Flag ..................................................................................................... 44 3.1.2 The m Validation Flag .................................................................................................... 44 3.1.3 The z Validation Flag ..................................................................................................... 45 3.1.4 Bad Message Handlers ................................................................................................... 45 3.1.5 Overriding the Validation Sequence ............................................................................... 45 3.2 HL7 Acknowledgment (ACK) Mode ....................................................................................... 46 3.2.1 HL7 ACK Configuration Settings for a Business Service ............................................. 47 3.2.2 HL7 ACK Configuration Settings for a Business Operation ......................................... 49 3.3 HL7 Dual Acknowledgment Sequences ................................................................................... 50 3.3.1 Dual ACK Sequence for Incoming Messages ................................................................ 51 3.3.2 Dual ACK Sequence for Outgoing Messages ................................................................ 52 3.3.3 Configuring a Dual ACK Sequence ............................................................................... 52 3.4 HL7 Message Framing Types ................................................................................................... 53 3.5 HL7 Batch Messages ................................................................................................................ 54 3.6 HL7 Business Service Classes ................................................................................................. 57 3.7 HL7 Business Operation Classes ............................................................................................. 58
4 Syntax for a Routing Production .................................................................................................... 59 4.1 HL7 Separator Characters ........................................................................................................ 59 4.1.1 Business Operations ....................................................................................................... 60 4.1.2 Data Transformations ..................................................................................................... 60 4.2 HL7 Escape Sequences ............................................................................................................ 60 4.3 Null Mapping Codes ................................................................................................................ 61 4.4 HL7 Message Class .................................................................................................................. 62 4.4.1 The DocType Property ................................................................................................... 63 4.4.2 The TypeCategory Property ........................................................................................... 64 4.4.3 The BuildMapStatus Property ........................................................................................ 64 4.4.4 The Name Property ........................................................................................................ 64 4.4.5 The RawContent Property .............................................................................................. 64 4.4.6 The GetValueAt Method ................................................................................................ 65 4.4.7 The SetValueAt Method ................................................................................................. 65 5 Viewing and Transforming Messages .............................................................................................. 67 5.1 Starting the Ensemble Management Portal .............................................................................. 67 5.2 The Schema Structures Page .................................................................................................... 68 5.2.1 Viewing a List of Document Types ................................................................................ 69 5.2.2 Viewing a Message Structure ......................................................................................... 69 5.2.3 Viewing a Segment Structure ......................................................................................... 70 5.2.4 Viewing a Data Structure ............................................................................................... 72 5.2.5 Viewing a Code Table ..................................................................................................... 72 5.2.6 Choosing a Different Category ...................................................................................... 73 5.3 The Document Viewer Page ..................................................................................................... 74 5.3.1 Viewing a Message ......................................................................................................... 75 5.3.2 Parsing the Message ....................................................................................................... 77 5.3.3 Displaying the Segment Address ................................................................................... 77 5.3.4 Displaying the Field Address ......................................................................................... 78 5.3.5 Viewing Batch Messages ................................................................................................ 79 5.3.6 Saving the Output to a File ............................................................................................. 80 5.4 Filtering HL7 Messages ........................................................................................................... 81 5.5 Comparing HL7 Messages ....................................................................................................... 81
List of Figures
Figure 11: HL7 Routing Engine in Ensemble Terms ............................................................................ 3 Figure 21: Ensemble DTL Visual Editor ............................................................................................. 29 Figure 31: HL7 Message Acknowledgment (ACK) Types .................................................................. 46 Figure 32: Paired Business Service and Business Operation for Incoming Dual ACK ...................... 51 Figure 33: Paired Business Service and Business Operation for Outgoing Dual ACK ....................... 52 Figure 34: Parent and Child Documents in HL7 Batch Messages ...................................................... 55 Figure 35: HL7 Business Service Class Hierarchy, Showing Inheritance of Settings ........................ 57 Figure 36: HL7 Business Operation Class Hierarchy, Showing Inheritance of Settings .................... 58 Figure 41: HL7 Message Class Overview Showing Inheritance ......................................................... 63 Figure 51: Ensemble HL7 Message Structure Page, DocType 2.3.1:ORM_O01 ............................... 69 Figure 52: Ensemble HL7 Message Structure Page, DocType 2.3:ADT_A01 ................................... 70 Figure 53: Ensemble HL7 Segment Structure Page ............................................................................ 71 Figure 54: Ensemble HL7 Data Structure Page ................................................................................... 72 Figure 55: Ensemble HL7 Code Table Page ........................................................................................ 73 Figure 56: Ensemble HL7 Message Structure Page, DocType 2.4:ORD_O04 ................................... 73 Figure 57: Ensemble HL7 Message Structure Page, DocType 2.5:ORD_O04 ................................... 73 Figure 58: Document Viewer Page ...................................................................................................... 75 Figure 59: Source for Message Data ................................................................................................... 76 Figure 510: DocType or Schema for Message Data ............................................................................ 76 Figure 511: Applying a Data Transformation ...................................................................................... 76 Figure 512: Document Viewer Parsing Summary ............................................................................... 77 Figure 513: Document Viewer Showing a Tooltip for the Segment Address ...................................... 78 Figure 514: Document Viewer Showing a Tooltip for the Field Address ............................................ 79 Figure 515: HL7 Batch Message with FHS and BHS, Top-Level Parent Document .......................... 79 Figure 516: HL7 Batch Message with FHS and BHS, Mid-Level Parent Document ......................... 80 Figure 517: HL7 Batch Message with FHS and BHS, Child Document ............................................ 80
List of Tables
Table 21: Built-in Search Table Entries for HL7 ................................................................................. 38 Table 22: Attributes for the <Item> Element in Search Tables ............................................................ 41 Table 31: Values for the Validation Setting .......................................................................................... 43 Table 32: Acknowledgment (ACK) Modes for HL7 Business Services ............................................. 47 Table 33: Enhanced-Mode ACK Commit Codes for HL7 2.3 and Higher .......................................... 48 Table 34: NACK Error Codes for HL7 Business Services .................................................................. 49 Table 35: Code Values for Reply Code Actions .................................................................................. 49 Table 36: Action Values for Reply Code Actions ................................................................................ 50 Table 37: Framing Types for HL7 Business Operations and Business Services ................................. 53 Table 38: HL7 Batch Message Handling Options ............................................................................... 56 Table 41: HL7 Escape Sequences Using Backslash as Escape Character ........................................... 61
There is also a detailed Table of Contents. The following books provide related information: Ensemble Best Practices describes best practices for organizing and developing Ensemble productions. Ensemble Virtual Documents explains how the concept of virtual documents allows Ensemble to provide efficient support for EDI document exchange. Ensemble HL7 Version 3 Development Guide explains how to add HL7 Version 3 interfaces to a routing production.
1
Ensemble HL7 Version 2 Support
The following figure illustrates the flow of an HL7 Version 2 message through an Ensemble production that works as an HL7 interface routing engine. This figure expands the simple view of a single interface shown in the Configuration Items section of the Design Model for a Routing Production chapter in Ensemble Best Practices. This figure adds elements of a routing production that are referenced by configuration items, but that are not themselves configuration items. These elements include routing rule sets, data transformations, virtual documents, and schema definitions. You create these items when you follow the instructions in this book.
An HL7 Version 2 message flows through the elements of an Ensemble HL7 routing production as follows:
1. 2.
An HL7 business service receives an incoming message from the specific source application whose messages it is configured to accept. The business service passes the message to a specific HL7 routing process. This is an Ensemble business process that prepares incoming messages from a HL7 business service for delivery outside Ensemble via a specific HL7 business operation. The routing process may validate the message against an expected HL7 schema definition. This may be a standard HL7 schema or a custom schema. (Not shown) If validation fails, the HL7 routing process passes the message to its configured bad message handler. This is an HL7 business operation that disposes of any incoming HL7 messages that fail validation, usually by saving the messages to a file. It may also enter an error in the Event Log or alert an operator.
3.
4.
The HL7 routing process applies a routing rule set to the message. The routing rule set chooses one or more target business operations and applies any data transformations that may be needed to prepare the message for the target application. In the typical case, some data transformation is required to prepare the message for the target. The routing rule set may invoke transformations that are custom coded, but commonly transformations are constructed using the Ensemble Data Transformation Language (DTL). DTL can call out to utility functions or utility class methods for more complex calculations. When the outgoing message is ready, the routing process passes it to an HL7 business operation. The business operation provides the address and framing information required to send HL7 messages to the target application. (Not shown) By default, all HL7 messages that pass through the production are retained in the Ensemble message warehouse for as long as wanted. While in the message warehouse, the contents of HL7 messages are available for tracking and viewing using Ensemble Management Portal features such as the EDI / HL7 Manager, Message Browser, and Visual Trace, or by issuing an SQL query. You can configure the production to purge old messages automatically or at an administrators discretion.
5.
6.
As further background information, the book Ensemble Best Practices describes best practices for organizing and developing Ensemble productions. It provides information that applies to all productions, including those that route HL7 Version 2 messages and other EDI format documents. A useful sequel to Ensemble Best Practices, Developing Ensemble Productions describes specific Ensemble development practices in detail; the following chapters help you to understand the relationships between the elements of a routing production: Production Concepts Ensemble Messages Business Services Business Processes Business Operations Message Routing Data Transformations
2
Elements of a Routing Production
This chapter explains how to build each element of an HL7 message routing production based on the starter production that you can create from the Ensemble Management Portal [Ensemble] > [Productions] page. Topics include: Building the Production HL7 Business Services HL7 Custom Schema Categories HL7 Routing Processes HL7 Sequence Manager Routing Rule Sets for HL7 DTL Data Transformations for HL7 HL7 Business Operations Pager and Email Alerts HL7 Search Tables
HL7FileService MsgRouter
An HL7 routing process with an empty routing rule set A disabled HL7 file operation with default settings
HL7FileOperation
In building an HL7 routing production, you create and configure many such interfaces. You can start by enabling these starter elements, copying them, renaming them, and modifying them to suit your needs. As you build an interface, it frequently happens that while configuring one item you must enter the name of another item that you have not yet created. A clear naming convention is essential to avoid confusion. For suggestions, see the Naming Conventions section in the Design Model for a Routing Production chapter of Ensemble Best Practices. Note: You can only use alphanumeric characters, periods (.) and underscores (_) in configuration names. Do not use underscores in the names of data transformations.
In addition to interface elements, the starter production provides several elements that do not route HL7 messages, but that provide supporting functionality for the production:
Bad Message Handler
Ens.Alert A routing process with a routing rule set that you can configure to route alert messages to different email
business operations depending on the source of the alert (that is, which element is in trouble) and various conditions (such as the time of day) to suit your corporate schedules and procedures.
PagerAlert and EmailAlert Email business operations that can be configured to send a text message (such as an alert)
to a pager or email address. The next several topics explain how to build a complete HL7 message routing production beginning from this foundation.
1.
On the [Ensemble] > [Productions] > [Configuration] page, start the Business Service Wizard in one of the following ways: Click the diagram background and then click Add Service. Right-click the diagram to reveal the context menu. Point to Add and then click Business Service.
2. 3.
Click HL7 Input for the kind of business service option. Click one of the following from the Input type list to determine the host class:
TCP File FTP HTTP SOAP
A business service class corresponding to each input type already exists and requires no programming. 4. 5. Give the item a configuration Name; the default is the class name. Enter information in the following fields: 6. Use the Target Name field to identify the routing process or business operation to which this business service sends the HL7 messages that it receives. You can configure the optional Category field later.
The Copy command works only within the same production. You cannot copy a business service from one production to another.
as a production item. The most important of these for HL7 are as follows.
The default Pool Size value of 1 makes it possible to support FIFO (First In, First Out) processing. In many cases, multiple patient demographic updates must be received in order. For example, many applications require receipt of an ADT Registration message before they can process an Order message, an Order message must be received before a Result message, and so on.
Pool Size
This text label permits configuration items to be sorted in the configuration diagram. For example, you can assign the same Category name to all items in the same interface. You may enter multiple category names separated by commas. Space characters count (do not use them around the commas).
Category
For descriptions of the other General Settings, see the Business Service Settings section in the Configuration chapter of Managing Ensemble Productions. This column of settings appears at right. The column is organized into settings that configure the HL7 business service (at top) and settings that configure its associated adapter (at bottom). The specific settings will be different depending on which HL7 business service you are configuring, and which adapter that business service is using. The following list describes how to configure the most important of these settings. For details about which class provides which settings, see the HL7 Business Service Classes section in the Settings for a Routing Production chapter.
Specific Settings
The setting names that appear in the lower portion of the page are, in many cases, localized descriptions of the class property names. You can hover the cursor over any setting name to display its help text as it appears in the Class Reference or click the setting name to display the help text in a separate pop-up window. The Specific Settings for an HL7 business service are as follows: Adapter Class Identifies the TCP, File, FTP, or HTTP inbound adapter for HL7. Ack Target Config Names (File and FTP only) Unlike TCP business services, File and FTP business services have no persistent connection on which to send HL7 acknowledgment messages (ACK or NACK). For this reason, the default Ack Mode for File and FTP business services is Never, which is usually appropriate. However, when you do want to send ACKs from a File or FTP business service, use the Ack Target Config Names setting to identify an Ensemble routing process or business operation to receive the ACK messages. See Ack Mode for more information. Ack Mode Helps to establish the format and conventions for issuing HL7 acknowledgment messages in response to HL7 messages received. For a list of codes to enter in this field, see the HL7 Acknowledgment (ACK) Mode section in the Settings for a Routing Production chapter. Add NACK ERR If True, when generating NACK messages, append an ERR segment that containing the Ensemble error codes and error text; otherwise do not embed internal error state information in NACK messages. For related settings, see the HL7 Acknowledgment (ACK) Mode section in the Settings for a Routing Production chapter. Alert Grace Period Business services can be configured with an Alert Grace Period during which errors relating to external connections do not trigger alerts, even if Alert On Error is True. The Alert Grace Period is allowed to elapse, giving the business service and the external source time to reestablish their connection. If the error condition still exists after the Alert Grace Period, the business service triggers an alert; otherwise no alert is triggered.
Setting Alert Grace Period to 0 disables this feature for the business service. Alert On Error If True, the HL7 business service automatically triggers an alert upon encountering an error. See the Pager and Email Alerts section in this chapter. Archive IO If True, the adapter associated with this business service will log in the Ensemble I/O archive each input and output communication it shares with the external system. This is not related to the Archive Path. See the Working with the I/O Archive section in the What to Manage chapter of Managing Ensemble Productions. Batch Handling How to treat received message batches. The options are:
Whole Batch Do not process message documents individually; accumulate and send the whole batch as
objects representing the batch header and trailer segments. This is the default.
Multi-Session Batch Forward each message in the batch in its own session; each session includes
senting the batch header and trailer segments. For more about batch handling, see the HL7 Batch Messages section in the Settings for a Routing Production chapter. Default Char Encoding The default character encoding to use when reading or writing HL7 messages. If any incoming HL7 message has an empty MSH:18 (Character Set) field, Ensemble uses this value in its place. Supported encoding values are UTF-8, Latin1, and any other NLS definitions installed on the Ensemble server. The value Native means to use the native default encoding installed on the Ensemble server. The default value for Default CharEncoding is Latin1. Placing a ! (exclamation point) character at the beginning of this field forces Ensemble to use the Default Char Encoding value and ignore any value found in MSH:18. For example: !UTF-8 Placing a @ (at sign) character at the beginning of this field means that the field identifies an internal NLS Translation Table instead of a logical character encoding. Framing Controls how the HL7 business service interprets the incoming HL7 message packet. For a list of framing options, see the HL7 Message Framing Types section in the Settings for a Routing Production chapter. If you are unsure what value to use, accept the default of flexible framing for HL7 business services. Ignore Inbound ACK If True, the business service ignores any inbound ACK messages to avoid creating an ACK feedback loop. For details and related settings, see the HL7 Acknowledgment (ACK) Mode section in the Settings for a Routing Production chapter.
Local Facility Application Colon-separated LocalFacility:LocalApplication code that represents the facility and application that receive HL7 messages via this business service. If this business service constructs its own ACK, Local Facility Application provides the SendingFacility:SendingApplication codes for the ACK message; otherwise, this setting is ignored. Message Schema Category Category to apply to incoming message types to produce a complete DocType specification. Combines with the document type Name (MSH:9) to produce a MessageType specification which Ensemble then uses to look up a MessageStructure / DocType in the MessageTypes section of the given HL7 schema category. This setting may also contain multiple comma-separated type Names followed by = and then a DocTypeCategory or full DocType value to apply to HL7 messages containing that type Name. A trailing asterisk (*) at the end of a given partial type Name matches any types beginning with the entry. DocType property of an HL7 message object For example: MessageSchemaCategory='2.3.1, ADT_*=2.5, BAR_P10=2.4, ORM_O01_6=2.4:RDE_O01' Note that a DocType assignment may be needed for Validation or SearchTableClass indexing. The name of one of the following items: A standard HL7 schema: 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, or 2.6. A custom HL7 schema
If you have not yet prepared a custom schema definition for the HL7 business service, you may leave this field blank for now. However, do not leave it blank permanently unless you also disable validation for the routing process, or validation errors will automatically occur. See the Message Validation and Bad Messages section in the Settings for a Routing Production chapter. Search Table Class The package and class name of a search table class that you have defined in this Ensemble namespace. A search table class is a specialized tool that you can create to work with virtual documents, such as HL7 messages. A virtual document is efficient because it contains a large amount of raw data but no instantiated properties. Creating a search table enables Ensemble to efficiently index a few of the fields in a virtual document so that these fields are available to be searched as if they were properties in a standard message body. To create a search table class, see the HL7 Search Tables section in this chapter. For conceptual information, see the Search Tables chapter in the book Ensemble Virtual Documents. Target Config Names The configured name of one or more of the following items: An HL7 routing process (for a routing interface) An HL7 business operation (if your design bypasses a routing process for this interface and simply relays messages from the incoming business service to the outgoing business operation)
Use ACK Commit Codes True or False. If True, when constructing an ACK message for HL7 messages version 2.3 or higher, the business service places one of the enhanced-mode ACK commit codes in the MSA segment AcknowledgmentCode field. See the description of Use ACK Commit Codes in the HL7 Acknowledgment (ACK) Mode section of the Settings for a Routing Production chapter for more details. The remaining entries in the Specific Settings column are determined by the type of adapter: TCP, File, FTP, HTTP, or SOAP. The following adapter settings are especially important for HL7 business services: Append Timestamp (File only) If True, the HL7 business service automatically appends a time stamp to filenames in the Archive Path. The format for this time stamp is %f_%Q where:
%f is the name of the data source, in this case the input filename _ is the literal underscore character, which appears in the output filename %Q indicates ODBC format date and time
In substituting a value for the format code %f, Ensemble strips out any of the characters | ? \ / : [ ] < > & , ; NUL BEL TAB CR LF, replacing spaces with underscores (_) and slashes (/) with hyphens (-). When the output file is being saved on an OpenVMS system, Ensemble replaces colons (:) with hyphens (-); otherwise, colons (:) become dots (.). Archive Path (File and FTP only) If this field is not empty, Ensemble creates a copy of each HL7 message received via this business service and saves it as a file in the specified Archive Path. The archived filename is the same as the input filename. Call Interval The number of seconds to wait before looking for more input. The default is 5 seconds. The minimum is 0.1 seconds. For further information about any setting, hover the cursor over the setting name, or consult these references: Adapter Settings in the FTP Inbound Adapter chapter of Using FTP Adapters with Ensemble Adapter Settings in the File Inbound Adapter chapter of Using File Adapters with Ensemble Adapter Settings in the TCP Inbound Adapter chapter of Using TCP Adapters with Ensemble, which describes the settings for the general-purpose TCP inbound adapter. The difference for the special-purpose adapter called EnsLib.HL7.Adapter.TCPInboundAdapter is that it has JobPerConnection set to False, which is usually appropriate for HL7. The Using the HTTP Inbound Adapter chapter in Using HTTP Adapters with Ensemble
An HL7 routing process (for a routing interface) An HL7 business operation (if your design bypasses a routing process for this interface and simply relays messages from the incoming business service to the outgoing business operation) A custom HL7 schema definition, to parse the incoming HL7 messages
The next several topics provide instructions for creating these items. 2. Return to the diagram on the [Ensemble] > [Productions] > [Configuration] page. Select the new HL7 business service. If the Target Config Names and Message Schema Category fields were previously blank, configure them now, and Apply your changes.
Ensemble provides a built-in schema category definition for each published version of the HL7 standard. These HL7 category definitions can be viewed and edited in XML format by opening the corresponding .HL7 file in Ensemble Studio. Each .HL7 file consists of a set of XML statements which define the HL7 messages. To create your own custom schema category, simply create a new .HL7 file and add XML statements to it. You can do this by creating a new file or copying an existing file, as follows: 1. Start Ensemble Studio and change to an Ensemble-enabled user namespace. Important: InterSystems recommends that you do not place custom code or data in the system-provided namespaces ENSLIB or ENSDEMO where it will be deleted the next time you upgrade Ensemble. The ENSEMBLE namespace and any new namespace that you create to hold your work is preserved across Ensemble upgrades.
2. 3. 4. 5. 6. 7.
From the File menu, choose New. The New dialog displays. Select the Custom tab. Select the HL7 Schema icon and click OK. Enter a New Schema Name. This is the <Category> name of the new schema. When you save the schema definition, it becomes the name of the new *.HL7 file. Enter a Base Schema Name. Specify the <Category> name of the schema base. Use one of the built-in categories: 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, or 2.6. Click OK.
If you have already created a custom schema category that matches your requirements closely, you might prefer to copy and edit this custom schema instead of creating a new custom schema. Use the following steps: 1. Open any existing custom schema category file as follows: Start Studio. Select File Open. For the Look in field choose an Ensemble-enabled user namespace. In the Files of type field select All files. In the File name field enter the extension *.hl7 or *.HL7. The names of several schema category files appear. Select an existing custom schema category file as the model for your new file. Do not select any of the built-in schema category files (2.1.HL7, 2.2.HL7, 2.3.HL7, 2.3.1.HL7, 2.4.HL7, 2.5.HL7, 2.5.1.HL7, or 2.6.HL7). If there are no custom schema category files to choose from, create a new file as described in the previous procedure. Click Open.
2.
From the File menu, choose Save As. Enter a new filename with the *.HL7 extension. For example:
myCustomCategory.HL7
3.
Edit the name and base attributes for <Category>: For name specify the new *.HL7 filename. For base specify the <Category> name of the schema base. Use one of the built-in categories: 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, or 2.6.
For example:
<Category name="myCustomCategory" base="2.4" ... >
You are now ready to edit your new file to add and remove XML statements from the <Category> block. You may open and study existing .HL7 schema files using Ensemble Studio. The editing steps for the new .HL7 schema file are as follows. For a formal syntax guide to the XML used in schema category definitions, see the Schema Category Syntax chapter in the book Ensemble Virtual Documents: 1. 2. 3. 4. 5. 6. 7. Define Z-segments using <SegmentStructure> elements. Define custom <MessageStructure> elements that contain the Z-segments. Define custom <MessageType> elements that contain the custom message structures. Remove any unneeded XML statements that remain from examples you have copied. From the File menu, choose Save. This action both saves and compiles the new category definition. Try viewing the new category definition from the Ensemble Management Portal. Select EDI / HL7 Manager and then Schema Structures. You should see your new custom category listed along with the standard categories. You can use the new custom schema definition in an HL7 routing production as follows: When creating a DTL data transformation, identify the custom schema category as the sourceDocType or targetDocType When configuring an HL7 business service, identify the custom schema category as the Message Schema Category
Click HL7 Message Router for the business process option; the router class defaults to EnsLib.HL7.MsgRouter.RoutingEngine. Enter information in the following fields: Give the routing process a configuration HL7 Router Name. Use a simple name that does not contain any dot (.) separators or space characters. The Routing Rule Name field identifies the routing rule set that the routing process executes to decide where to send the messages that it receives.
4.
Note:
Ack Type Determines the ACK type (that is, AA or CA) if constructing an ACK or NACK reply message locally. A is the default code. For further details, see the HL7 Acknowledgment (ACK) Mode section in the Settings for a Routing Production chapter. Add NACK ERR If True, when generating NACK messages, append an ERR segment that containing the Ensemble error codes and error text; otherwise do not embed internal error state information in NACK messages. Alert On Bad Message If True, any message that fails validation automatically triggers an alert. Bad Message Handler Identifies the HL7 business operation that disposes of any incoming HL7 messages that fail validation. Business Rule Name The full name of the routing rule set for this routing process. If you generated the routing process using the Business Process Wizard, use the default value provided by the wizard. Force Sync Send If True, make synchronous calls for all send actions from this routing process. If False, allow these calls to be made asynchronously. The Force Sync Send setting is intended to support FIFO ordering in the following case: This routing process and its target business operations all have Pool Size set to 1, and ancillary business operations might be called asynchronously from within a data transformation or business operation called from this routing process. If Force Sync Send is True, this can cause deadlock if another business process is called by a target that is called synchronously from this routing process. Note that if there are multiple send targets, Force Sync Send means these targets will be called one after another in serial fashion, with the next being called after the previous call completes. Also note that synchronous calls are not subject to the Response Timeout setting. Local Facility Application Colon-separated LocalFacility:LocalApplication code that represents the facility and application that receive HL7 messages via this routing process. If this routing process constructs its own ACK or NACK messages, Local Facility Application provides the SendingFacility:SendingApplication codes for the messages; otherwise, this setting is ignored. NACK Code Determines the NACK code type (that is, AE or AR) if constructing a NACK reply message locally to report an error. E is the default code. For further details, see the HL7 Acknowledgment (ACK) Mode section in the Settings for a Routing Production chapter. Response From A comma-separated list of configured items within the production. This list identifies the targets from which a response may be forwarded back to the original caller, if the caller requested a response.
If a Response From string is specified, the response returned to the caller is the first response that arrives back from any target in the list, and if there are no responses, an empty OK response header is returned. If the Response From value is empty, nothing is returned. The Response From string allows special characters as follows: The * character by itself matches any target in the production, so the first response from any target is returned. If there are no responses, an empty OK response header is returned. If the list of targets begins with a + character, the responses from all targets return together, as a list of message header IDs in the response header. If none of the targets responds, an empty OK response header is returned. If the list of targets begins with a - character, only error responses will be returned, as a list of message header IDs in the response header. If none of the targets responds with an error, an empty OK response header is returned.
Response Target Config Names A comma-separated list of configured items within the production. If specified, this list identifies the destinations, in addition to the caller, to which responses will be forwarded. If empty, responses are only returned to the caller. This setting takes effect only if the Response From field has a value. Response Timeout Maximum length of time to wait for asynchronous responses before returning a timed-out error response header. A value of -1 means to wait forever. Note that a value of 0 is not useful, because every response would time out. This setting takes effect only if the Response From field has a value. Validation If blank, the routing process skips validation and simply routes messages. For details about validation conventions when this field contains a value, see the Message Validation and Bad Messages section in the Settings for a Routing Production chapter. An HL7 routing process has other configurable settings that apply to all business hosts. Documentation for these common settings is available in the Business Process Settings section in the Configuration chapter of Managing Ensemble Productions.
The sequence manager has the ability to detect duplicate messages and timing gaps between messages. It also determines when the timing gaps between sequential messages are sufficiently large to indicate a problem. Its level of sensitivity can be adjusted using its configuration settings. To build an HL7 sequence manager for use in an HL7 message routing production, you must create it, configure it, and integrate it into the production. This topic explains each step. Important: The Ensemble HL7 Sequence Manager is a HL7-compatible store-and-forward application and does not support the HL7 Sequence Number Protocol as defined in Chapter 2, section 2.10.1 of the HL7 Standard.
Click All Processes for the business process option. Click EnsLib.HL7.SequenceManager in the ProcessClass list. Enter information in the following fields: Give the item a configuration Name. For suggestions, see the Naming Conventions section in the Design Model for a Routing Production chapter of Ensemble Best Practices. You can configure the optional Category and Comment fields later.
5.
A sequence manager can check for duplicate messages and messages out of sequence, duplicate messages or messages out of sequence, or neither. This makes Enable Duplicated Message Check entirely independent of Perform Sequence Number Check On in that either, one, or both of these settings may be True.
Perform Sequence Number Check On Fields for the sequence manager to check to see if any of the incoming messages are out of sequence. If so, the sequence manager resequences the messages and sends them to its configured targets. Possible values for Perform Sequence Number Check On are:
Sender This is the default. The sequence manager checks:
None The sequence manager does not check for messages out of sequence.
A sequence manager can check for duplicate messages and messages out of sequence, duplicate messages or messages out of sequence, or neither. This makes Enable Duplicated Message Check entirely independent of Perform Sequence Number Check On in that, either one, or both of these settings may be True. Perform Output Transformation On Fields for the sequence manager to transform before sending out a message. The output transformation provides new facility, application, and sequence number fields as described in the following list, then sends the message to its configured targets. Possible values for Perform Output Transformation On are:
Sender This is the default. The sequence manager copies Facility and Application from the Output
setting and assigns a new sequence number. The result is that the following fields are changed in the outgoing message:
Facility Application
MSH:3 SendingApplication
Receiver The sequence manager copies Facility and Application from the Output Facility Application
setting and assigns a new sequence number. The result is that the following fields are changed in the outgoing message: MSH:5 ReceivingApplication MSH:6 ReceivingFacility MSH:13 SequenceNumber
None The sequence manager does not perform any transformation before sending the message.
Output Target Config Names A comma-separated list of configured items within the production. If specified, this list identifies the destinations to which the sequence manager will send any message that passes its tests. Message Wait Timeout For definitions of large gaps, small gaps, and late messages, see the Large Gap Size setting. For any small gap, the sequence manager waits for Message Wait Timeout seconds to see if messages will arrive to fill the gap between the preceding message and the late message. If they do not arrive and the Message Wait Timeout expires, the sequence manager stops waiting and sends whatever it has for messages in the current sequence. The default Message Wait Timeout is 60. Passthrough Message Types A comma-separated list of message types that are exempt from duplicate checks, sequence checks, or output transformations. The sequence manager always passes these messages through unchanged. The default list is:
QBP_Q21,QBP_Q22,RSP_K21,RSP_K22,ACK
Out Of Sequence Message Target The configured Name of an item within the production, usually a business operation. If specified, this is where the sequence manager sends any out-of-sequence message notices. Duplicated Message Target The configured Name of an item within the production, usually a business operation. If specified, this is where the sequence manager sends any duplicate messages that it receives. Output Facility Application Specifies the facility and application to be used in the message transformation when Perform Output Transformation On is set to Sender or Receiver. The format for the Output Facility Application value is: Facility:Application
Message Resendable Time Window Time window during which the sequence manager considers a duplicate message to be a duplicate. The reason for the Message Resendable Time Window is that sometimes a duplicate message is not a mistake. Sometimes it is the result of deliberately resending a message sequence. Suppose a message arrives and the sequence manager detects that it is a duplicate of a previously received message. In this case: If it has been more than Message Resendable Time Window seconds since the sequence manager first saw this message, it interprets the new arrival as a deliberately resent copy. The sequence manager begins tracking the messages in this resent sequence independently from its tracking of the main sequence of messages. Suppose the sequence manager is processing a sequence that includes numbers such as 1001, 1002, 1003, and 1004, but at the same time it begins receiving messages with the sequence numbers 1, 2, and 3. If the older messages with smaller sequence numbers were first received more than Message Resendable Time Window seconds ago, the sequence manager interprets them as messages in a resent sequence, rather than as messages out of sequence. It begins tracking the main sequence and the resent sequence simultaneously. While doing so, it keeps the two sequences separate, appropriately ignoring gaps between unrelated sequence numbers such as 2 and 1001. If it has been less than Message Resendable Time Window seconds since the sequence manager first saw this message, the new arrival is understood to be a true duplicate, and the sequence manager handles it appropriately. See Enable Duplicated Message Check.
The default Message Resendable Time Window is 300 seconds (5 minutes). Large Gap Size A number that indicates a significant gap in the sequence of messages; the default is 100. A late message is a message that arrives with a sequence number larger than the previously received message in the sequence, but not exactly sequential. For example, when message 102 arrives after message 101, 102 is not late; it is the next message in sequence. However, when message 110 arrives after message 101, 110 is a late message. When there is a late message, and the sequence numbering gap between the preceding and subsequent messages is less than the configured Large Gap Size, this is a small gap. A gap larger than this is a large gap. For any small gap, the sequence manager waits for Message Wait Timeout seconds to see if messages arrive to fill the gap. If the messages arrives within the waiting period, the sequence manager aligns them in their proper sequence. If they do not arrive and the Message Wait Timeout expires, the sequence manager stops waiting and sends whatever it has for messages in the current sequence. When there is a large gap, the sequence manager does not wait for any period of time. It immediately sends an alert, then sends whatever it has for messages in the current sequence.
An HL7 sequence manager has other configurable settings that apply to all business hosts. Documentation for these common settings is available in the Business Process Settings section in the Configuration chapter of Managing Ensemble Productions.
2. 3.
Return to configuring the HL7 sequence manager. Provide it with a list of Output Target Config Names for successful messages. If you want the sequence manager to check for duplicate messages, set Enable Duplicated Message Check to True. If you want to save the duplicate messages for troubleshooting purposes, create a HL7 business operation to receive them. In the Duplicated Message Target field enter the name of the new HL7 business operation.
4.
If you want the sequence manager to check for out-of-sequence messages, set Perform Sequence Number Check On to Sender or Receiver and configure the details of sequence checking by setting values for Large Gap Size and Message Wait Timeout. Otherwise, set Perform Sequence Number Check On to None. If you want to save the out-of-sequence messages for troubleshooting purposes, create a HL7 business operation to receive them. In the Out Of Sequence Message Target field enter the name of the new HL7 business operation.
5.
If you want the sequence manager to transform messages before sending them outside Ensemble, set Perform Output Transformation On to Sender or Receiver and set a value for the Output Facility Application. Otherwise, set Perform Output Transformation On to None. Identify any Passthrough Message Types that the sequence manager should simply send to the Output Target Config Names without checking or transforming them.
6.
NextSequenceNumber Identifies the next number in the sequence. A sample SQL query on EnsLib.HL7.SM.RuntimeData might be as follows:
SELECT NextSequenceNumber FROM EnsLib.HL7.SM.RuntimeData WHERE Facility = 'mine'
For background information about how Cach classes provide programmatic access via objects or SQL, see:
The Object Persistence chapter in Using Cach Objects The Defining Tables chapter in Using Cach SQL The Querying the Database chapter in Using Cach SQL
This topic explains how to use the features of the Message Routing Rule Editor that are different from those of the Business Rule Editor. For background information about the Business Rule Editor, see the chapters Managing Business Rules and Creating Rule Sets in Using Business Rules with Ensemble. To build a routing rule set for use with an HL7 routing process: 1. 2. Start the Ensemble Management Portal. Display the Message Routing Rule Editor in one of the following ways: While viewing a diagram on the [Ensemble] > [Productions] > [Configuration] page, click on a routing process in the Business Processes column. Click View Rules. The [Ensemble] > [Business Rules] > [Message Routing Rule Editor] page displays. Click Edit. From the main menu, choose Business Rules. The [Ensemble] > [Business Rules] page displays a list of rule sets. Find a routing rule set and click Edit next to its name. From the main menu, choose Business Rules. The [Ensemble] > [Business Rules] page displays a list of rule sets. Click Create New Message Routing Rule.
3.
When you create a new HL7 routing process using the Business Process Wizard, Ensemble creates a new, empty routing rule set to accompany the new routing process. Its information table contain the following values acquired from the Business Process Wizard: The package that contains the production class. For example, if you used the wizard to add a routing process to a production called TestRule.MyTest, the associated routing rule has a Package Name of:
Package Name
TestRule
Rule Name
The simple Routing Rule Name that you chose in the wizard, such as:
MyRule
The combination of the Package Name and Rule Name identify the rule uniquely within the Ensemble namespace. The full name for any rule definition is the Package Name and Rule Name connected by a dot (.) as in:
TestRule.MyRule
This full name, rather than the Rule Name, is the correct value to use in the BusinessRuleName field when configuring an HL7 routing process. The Business Process Wizard sets this up automatically.
Routing Engine Class
The default Router Class from the wizard; do not change it:
EnsLib.HL7.MsgRouter.RoutingEngine
If you did not use the wizard to create your routing rule set, then in the top half of the Message Routing Rule Editor screen you must enter basic information for the rule as follows: Similar in principle to the package name you use to organize host classes in Studio, this name may contain dot (.) separators, as in:
Package Name
MyClassPackage.Organization.Levels
Rule Name
MyRule
Effective Begin DateTime The time from which the rule becomes active. The exact time is included in the active
interval. The format is YYYY-MM-DDTHH:MM:SS. The time portion is optional and defaults to 00:00:00. The time when the rule stops being active. The exact time is excluded from the active interval. The format is YYYY-MM-DDTHH:MM:SS. The time portion is optional and defaults to 24:00:00
Effective End DateTime
The combination of the Package Name and Rule Name along with the Effective Begin DateTime and Effective End DateTime identify the rule uniquely within the Ensemble namespace. The full name for any rule definition is the Package Name and Rule Name connected by a dot (.) followed by the formatted begin and end effective dates, as in:
MyClassPackage.Organization.Levels.MyRule$2009-07-01T00:00:00$2010-06-30T24:00:00
This full name, rather than the Rule Name, is the correct value to use in the BusinessRuleName field when configuring an HL7 routing process.
Routing Engine Class This field tells the Message Routing Rule Editor which object properties to offer as drop-
down choices in the Value Editor window while a user is editing a rule. For an HL7 routing rule set, use:
EnsLib.HL7.MsgRouter.RoutingEngine
4.
Type a Description of the rule definition and its purpose. For example, you might list the types of message segments that travel over this interface. You may also enter additional fields for your own rule reporting purposes:
Report Group Report Name
Value to be used to group rules for reporting Display value for the rule report group Optional short description of this Rule Definition.
Short Description
5.
Do All Rules If the Do All Rules check box is selected, Ensemble will begin at Rule 1 and evaluate all of the rules in
sequence. In this case Ensemble executes every rule that evaluates to True. If the Do All Rules check box is clear, Ensemble stops evaluating rules immediately after executing the first rule in the sequence that evaluates to True. 6. The bottom half of the Message Routing Rule Editor page contains fields that describe the logic of the routing rule using Rules, Conditions, and Actions. The following close-up views show details of this part of the user interface.
On the right are the columns that define Conditions and their resulting Actions:
7.
If you expect many of your rules to share fields in common, for example a Message Class of EnsLib.HL7.Message, you can streamline the editing process by providing a Base rule for the set. A rule called Base always appears at the top of a list of routing rules. Base serves as a convenient template for creating new rules for the set. It is not a default value of any kind, but a starting point for editing rules. You can use it or leave it blank. Any part of the Base rule that you define appears automatically in every other rule in the set. Wherever text is italicized in the Message Routing Rule Editor display, this indicates that the value is inherited from the Base rule. As an example, see the Source and Message Class columns in the figures above. Any rule in the set may override the values it inherits from the Base rule.
8.
To add a rule to the set, in the Rules column, click . The Routing Rule Wizard displays. Use this dialog to configure the rule Source, Message Class, Document Name, Schema Category, and Schema Doc Type, as described in the following steps.
Source
9.
An HL7 business service (for a routing interface) An HL7 routing process (if another rule chains to this routing rule set)
Click the More (...) icon next to the Source field to see a popup list of possible Source items in the namespace, organized by production name. For example:
Select an item and click OK to save your changes to the Source field. If you have not yet prepared the item you need as a Source, you may leave this field blank and return to it when the item is ready. If you leave the Source field permanently blank, Ensemble considers input from all sources to be a match for that rule. You can configure this case deliberately for any rule that needs it. 10. Message Class identifies the Ensemble message object that is being routed by this rule. Click the More (...) icon next to the Message Class field to view a popup list of possible Message Class choices. To route HL7 Version 2 messages, choose EnsLib.HL7.Message. Important: The next three fields in the Routing Rule Wizard, and the next three steps in this procedure, apply only when the Message Class is EnsLib.HL7.Message or any other virtual document class, such as for X12 or ASTM. For other types of message, skip to Step 14.
The distinctions between these properties are as follows: is the HL7 message structure that the source application identifies in the MSH:9 field, such as ADT_A08 or ORM_O01. To allow easy retrieval, this MSH:9 value resides in the EnsLib.HL7.Message property called Name.
Document Name
There is a problem with relying on the message header segment, MSH, for message validation. What the application says it is sending, and what the application actually sends, can be different. In theory, the values in MSH always correctly identify the contents of the message, but in practice, this is not always the case. For example, the message header MSH:12 field may state that the message is version 2.2, but the message contents may actually conform to the 2.3.1 standard or to some custom schema category. Thus, in addition to Document Name the Routing Rule Wizard also offers Schema Category and Schema Doc Type as values that the Ensemble validation sequence can attempt to match. These values should have been correctly assigned by the business service that accepted the message into Ensemble. If the values in the message DocType do not match those in the rule, then the rule does not execute. and Schema Doc Type represent the actual HL7 message structure. These values reside in the EnsLib.HL7.Message property called DocType. DocType is a two-part string separated by a colon, such as 2.4:ADT_A08.
Schema Category
At left is the Schema Category. This is the name of a built-in schema category such as 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, 2.6, or the name of a custom schema definition. At right is the Schema Doc Type. This is an HL7 message structure within the identified schema, such as ADT_A08 or ORM_O01.
If validation is enabled for the routing process, and if values are provided for Schema Category or Schema Doc Type, Ensemble parses the message to determine if its structure matches the schema specified. The Schema Doc Type does not need to be the same as the Document Name for the message to be accepted as valid. Steps 11, 12, and 13 explain how to fill in these fields in the Routing Rule Wizard. 11. For the Document Name, you can: Leave the field blank, to match any Document Name. Enter a value, to cause the rule to match only messages with the specified Document Name. Enter more than one value in the Document Name text entry field, pressing Enter between values to place one value on each line of text. This causes the rule to match any of the specified Document Name values, and no others.
When viewing the rule after you have edited it, the value you entered in the Document Name field appears as the Message Type for the rule. 12. For the Schema Category, you can: Leave the field blank, to match any Schema Category. Enter or choose a single value using the More (...) icon, to cause the rule to match only messages with the specified Schema Category.
When viewing the rule after you have edited it, the value you entered in the Schema Category field appears as the Category for the rule. 13. For the Schema Doc Type, you can: Leave the field blank, to match any Schema Doc Type. Enter a value, to cause the rule to match only messages with the specified Schema Doc Type. Enter more than one value in the Schema Doc Type text entry field, pressing Enter between values to place one value on each line of text. This causes the rule to match any of the specified Schema Doc Type values, and no others. Enter either a simple Schema Doc Type (ORM_O01) or a full value separated by a colon (2.3.1:ORM_O01). A full value in the Schema Doc Type field temporarily overrides whatever is in the Schema Category field.
When viewing the rule after you have edited it, the value you entered in the Schema Doc Type field appears as the Schema Doc Type for the rule. Important: If you are uncertain how to use the Document Name (Step 11), Schema Category (Step 12), or Schema Doc Type (Step 13), return to Step 10 for an overview of these fields.
14. Click OK to save changes in the Routing Rule Wizard. Click Cancel to discard them. 15. Once you have created a new rule, you may add Conditions and Actions to it. For details, see the Creating Rule Sets chapter in Using Business Rules with Ensemble. As you add Conditions to each rule, remember these tips:
Conditions
Conditions can refer to properties of the HL7 message object. Within Conditions, the special variable Document
represents the HL7 message object, as in the following examples. For HL7 batch documents, you can use the special variable Document.Parent to represent the parent message object.
Document.Name Document.Parent.DocType Document.{PIDgrp.PV1grp.PV1:18} Document.{PIDgrp.PID:PatientName.familylastname} Document.{ORCgrp(1).OBRuniongrp.OBRunion.OBR:4.3}
Note:
For compatibility with past releases, the special variables HL7 and HL7.Parent are supported as alternatives to Document and Document.Parent.
A dot separates the Document variable from the property name. This name may be: Any of the class properties: DocType, TypeCategory, BuildMapStatus, or Name. A virtual property, referenced using any of the following conventions: Curly brackets
{segmentPath:field}
Square brackets
[segmentName:field]
Angle brackets
<context|expression>
Details are available in the Virtual Property Syntax section of the book Ensemble Virtual Documents. However, you do not need to enter properties by typing; you can browse for properties as described in the Creating Rule Sets chapter in Using Business Rules with Ensemble. 16. To specify an Action for a rule, click Add or Send in the Action column. The Routing Rule Wizard displays a dialog in which you can configure Action details as follows:
Type
Choose an option, one of the following: Meaning Send the message to the target. This is appropriate for most cases. Discard the message. If the Do All Rules check box is selected, Ensemble evaluates every rule in the set, and all rules that are True have their actions executed. On the other hand, if any rule that is True provides a final action of stop, this overrides the Do All Rules setting and causes Ensemble to stop evaluating rules immediately. All subsequent rules in the set are skipped. If the Do All Rules check box is clear, Ensemble stops evaluating rules after executing the actions provided by the first rule that evaluates to True. However, if one of the actions in the rule is continue, this overrides the Do All Rules setting and causes Ensemble to continue evaluating more rules, in sequence, until it finds the next rule that evaluates to True, and then stop.
Type
send delete stop
continue
Target
For send you may enter the configured name of one or more of the following items.
An HL7 business operation, to route the message to an external application An HL7 routing process, to chain to another routing rule set
Click the More (...) icon next to the Target field to see a list of possible Target items in the namespace, organized by production name. You may select items from this list, one at a time. If you need to enter multiple items in the Target field, separate each name with a comma. This happens automatically when you select multiple items from the list.
Transform To transform the HL7 message before sending it to the Target, enter the full package and class name
of one or more DTL data transformations. Click the More (...) icon next to the Transform field to see a list of data transformation classes in the namespace. You may select items from this list, one at a time. If you need to enter multiple items in the Transform field, separate each name with a comma. This happens automatically when you select multiple items from the list. Click OK to save your changes, Cancel to discard them.
If you have not yet created the configuration items that you want to specify in the Target or Transform fields, you may leave the Action field blank and return to it when these items are ready. Note that the Target and Transform fields each support multiple values. Multiple data transformations are chained in the order in which they appear, from left to right. Any transformations listed after the first one should be defined with create="existing" so as not to discard the results of the previous transformation in the chain. If you leave the Action, Transform, and Target fields permanently blank, Ensemble takes no action when this rule is true. You can configure this case deliberately for any rule that needs it. 17. To save changes to the routing rule set, click Save. If you wish to discard changes and return to the previously saved version of the rule set, click Revert. 18. Complete the instructions in the next several topics for creating any Source, Target, or Transform items that your routing rule set needs. The items might be: An HL7 business service, to route messages to the rule A DTL data transformation, to transform the message before sending it An HL7 business operation, to route the message to an external application An HL7 routing process may be either a Source or a Target
As you create items, return to the Message Routing Rule Editor to add them to the appropriate fields of the rule definition. 19. Repeat from step 5 as needed to refine the logic of the routing rule set. 20. Return to the diagram on the [Ensemble] > [Productions] > [Configuration] page. Select the corresponding HL7 routing process. In the BusinessRuleName field enter the full name of the new routing rule set.
To build a DTL data transformation for use in an HL7 message routing production: 1. Start Studio and change to an Ensemble-enabled user namespace. Important: InterSystems recommends that you do not place custom code or data in the system-provided namespaces ENSLIB or ENSDEMO where it will be deleted the next time you upgrade Ensemble. The ENSEMBLE namespace and any new namespace that you create to hold your work is preserved across Ensemble upgrades.
2.
Find an existing Ensemble data transformation that seems similar to the one you are converting. After converting several interfaces, you might discover a specific data transformation that tends to be useful as a starting point when nothing else is similar. Use this class, or use the data transformation class Demo.HL7.Router.SampleTransformation from the ENSDEMO namespace of sample classes. This class is illustrated above. Choose Tools, then Copy Class. A dialog pops up. Edit it using the following sequence of steps: In the Copy Class Definition From field, browse to the data transformation class that you chose as a starting point. In the To field, enter the full package and class name for the new data transformation. Important: InterSystems recommends that you do not use the package names Demo, Ens, EnsLib, EnsPortal, or CSPX. This causes your work to be deleted the next time you upgrade Ensemble.
3.
4. 5.
Select the Add New Class to Project check box. Click OK.
Have the Ensemble Data Transformation Language Reference handy. This book lists and explains the available DTL elements. Be clear about the value you want for the create attribute of the <transform> element. create may have one of the following values:
new Create a new object of the target type, before executing the elements within the data transformation. Any source segments that you do not explicitly assign to the target object are ignored. This is the default. copy Create a copy of the source object to use as the target object, before executing the elements within the transform. existing Use an existing object, provided by the caller of the data transformation, as the target object.
To create a target object that is an exact copy of the source, do not use:
<assign property='target' value='source' />
Instead use the create='copy' attribute in the containing <transform> element. 6. Ensure that the DTL <transform> element identifies the correct schema category for: The sourceDocType attribute The targetDocType attribute
The schema category may be the same or different for the source and target objects. 7. Ensure that the DTL <transform> element sets the scripting language that you want to use for all of the conditional expressions and <code> elements within that data transformation. ObjectScript is the default language. If you want Cach Basic, you can specify it as follows:
<transform language="basic"
8.
Use <assign> elements to assign HL7 segments from the source message to the target message. You can use the DTL Visual Editor for this. For full instructions, see the section Using the DTL Visual Editor in the Production Data chapter of Developing Ensemble Productions. If you want to type <assign> elements into the DTL code directly, you may do so. Your changes in the DTL code view become visible each time you click on the DTL diagram view in the DTL Visual Editor. Possibly, you will want to use a combination of techniques. You can first generate a line of code by dragging, then fine-tune the code by editing the text.
9.
The data transformation can refer to properties of the HL7 message object, including: The class properties DocType, TypeCategory, BuildMapStatus, and Name. Virtual document properties as described in Curly Bracket {} Syntax in the Virtual Property Syntax section of the book Ensemble Virtual Documents.
Within the data transformation class code, the special variables source and target represent the respective HL7 message objects, as in the following examples:
source.Name target.DocType source.{PIDgrp.PV1grp.PV1:18} target.{PIDgrp.PID:PatientName.familylastname} source.{ORCgrp(1).OBRuniongrp.OBRunion.OBR:4.3}
10. Assign any literal string values, or make conditional assignments, as described in the Literal String Syntax section of the book Ensemble Virtual Documents. Highlights include: The syntax required to assign a literal string in DTL is as follows:
value='"string"'
Do not insert a literal HL7 separator string for MSH 2 in the target. HL7 separators are handled in the HL7 business operation. Do not manually change HL7 escape sequences such as \F\ or \S\ in the data transformation. The HL7 business operation handles these appropriately. Be aware of XML entities and other special characters. If you run into trouble with quotes you can use the entities " and ' A value can be a simple literal string, as in:
value='"string"'
A value can be a complex string expression in the language being used for the data transformation. The language for this expression depends on the value of the language attribute for the DTL <transform> element. If not specified, the default language is ObjectScript. The ObjectScript concatenation operator is the underscore character, as in:
value='"string1"_"string2"'
In Cach Basic, the concatenation operator is & (ampersand). To learn about useful ObjectScript string functions, such as $CHAR and $PIECE, see the Cach ObjectScript Reference. For Basic equivalents, see the Cach Basic Reference. The HL7 null mapping code "" requires special handling. The following example tests for the null mapping code in the source message and replaces it with a blank string in the target message:
<if condition='source.{PV1:7().4}=""""""'> <true> <assign property='target.{PV1:7().4}' value='""' /> </true> </if>
For details, see Null Mapping Codes in the Literal String Syntax section in the chapter Syntax for a Routing Production. 11. For simple calculations, the DTL data transformation can: Invoke Ensemble utility functions Use ObjectScript or Cach Basic expressions in the DTL <code> element Invoke the DTL <sql> element
For more complex calculations, you can write utility class methods and invoke them from the DTL <code> element, or from the value string in another DTL element. 12. You can comment your DTL code. For your comments to be permanently visible in both class code and DTL Visual Editor views, you must provide comments within a <annotation> block. For details and examples, see the Documentation and Comments section in the Creating a New Production chapter of Developing Ensemble Productions. 13. Compiling the data transformation also saves it. 14. To use the DTL data transformation in the production, simply enter its full package and class name in the Transform field of a routing rule set.
For example, the following DTL <assign> statement uses the built-in function ToUpper to convert a string to all uppercase characters. This <assign> statement references ToUpper using double-dot syntax, as if it were a method in the DTL data transformation class:
<assign property='target.BankName' value='..ToUpper(source.BankName)' action='set'/>
For syntax details and a list of functions, see the Utility Functions section in the Creating a New Production chapter of Developing Ensemble Productions. The topic also explains how to extend the list of built-in utility functions by adding custom code.
2. 3.
Click HL7 Output. Click one of the following from the Output type list to determine the host class:
TCP File FTP HTTP SOAP
A business operation class corresponding to each output type already exists and requires no programming. 4. Enter information in the following fields: 5. Give the item a configuration Name; the default is the class name. You can configure the optional Category field later.
Note:
as a production item. The most important of these for HL7 are as follows. For descriptions of the other General Settings, see the Business Operation Settings section in the Configuration chapter of Managing Ensemble Productions. The default Pool Size value of 1 makes it possible to support FIFO (First In, First Out) processing. FIFO processing is important to ensure correct data in the receiving applications. Multiple patient demographic updates must be received in order; otherwise, obsolete, incorrect data may appear in the receiving application. Also, many applications require receipt of an ADT Registration message before they can process an Order message, an Order message must be received before a Result message, and so on.
Pool Size
The number of seconds during which to continue retry attempts. After this number of seconds has elapsed, the business operation gives up and returns an error code. HL7 business operations automatically set this value to -1 for never time out to ensure that no HL7 message is skipped.
Failure Timeout
This text label permits configuration items to be sorted in the configuration diagram. For example, you can assign the same Category name to all items in the same interface. You may enter multiple category names separated by commas. Space characters count (do not use them around the commas).
Category
This column of settings appears at right. The column is organized into settings that configure the HL7 business operation (at top) and settings that configure its associated adapter (at bottom). The specific settings will be different depending on which HL7 business operation you are configuring, and which adapter that business operation is using. The following list describes how to configure the most important of these settings. For details about which class provides which settings, see the HL7 Business Operation Classes section in the Settings for a Routing Production chapter.
Specific Settings
The Specific Settings for an HL7 business operation are as follows: Adapter Class Identifies the TCP, File, FTP, or HTTP outbound adapter for HL7. Alert On Error If True, the HL7 business operation automatically triggers an alert upon encountering errors connecting with its external target. See the Pager and Email Alerts section in this chapter. Alert Retry Grace Period Business operations can be configured with an Alert Retry Grace Period during which errors relating to external connections do not trigger alerts, even if Alert On Error is True. This grace period accommodates a business operation that attempts an external connection with a configured Retry Interval and Failure Timeout. During its retry sequence, the business operation may encounter connection failures that become unimportant after one of its retry attempts succeeds. Thus, if a business operation first encounters an error, but later achieves success within the time allotted by the Alert Retry Grace Period, no alert is triggered even though an error occurred. Setting Alert Retry Grace Period to 0 disables this feature for the business operation. Archive IO If True, the adapter associated with this business operation will log in the Ensemble I/O archive each input and output communication it shares with the external system. See the Working with the I/O Archive section in the What to Manage chapter of Managing Ensemble Productions. Auto Batch Parent Segs (File and FTP only) If True, when writing a message that has a batch parent, output the batch headers first, then child documents, then follow up with the batch trailers when triggered by the final batch header message or by a file name change. If False, omit headers and trailers and output child documents only. The default is False. For more about batch handling, see the HL7 Batch Messages section in the chapter Settings for a Routing Production. Default Char Encoding The default character encoding to use when reading or writing HL7 messages. If any incoming HL7 message has an empty MSH:18 (Character Set) field, Ensemble uses the Default Char Encoding value in its place. Supported values are UTF-8 or any member of the Latinn family. The value Native means to use the native default
encoding installed on the Ensemble server. The default value for Default Char Encoding is Latin1. Placing a ! (exclamation point) character at the beginning of the encoding name forces Ensemble to use the Default Char Encoding value and ignore any value found in MSH:18. For example: !UTF-8 File Name (File and FTP only) The target file name. The File Path adapter setting determines the path for this file; File Name determines the name. File Name can include Ensemble time stamp specifiers. If you leave File Name blank, the default uses the time stamp specifier %f_%Q where:
%f is the name of the data source, in this case the input filename _ is the literal underscore character, which will appear in the output filename %Q indicates ODBC format date and time
For full details about time stamp conventions, including a variety of codes you can use instead of the default %f_%Q, see the Time Stamps in Filenames section in the Creating a New Production chapter of Developing Ensemble Productions. Framing Controls how the HL7 business operation constructs the outgoing HL7 message packet. For a list of framing options, see the HL7 Message Framing Types section in the chapter Settings for a Routing Production. If you are unsure what value to use, accept the default of MLLP framing for HL7 business operations. No Fail While Disconnected (TCP only) If True, suspend counting seconds toward the Failure Timeout while disconnected from the TCP server. The No Fail While Disconnected setting does not apply if Failure Timeout is 1 or if Stay Connected is 0. Reply Code Actions Allows you to supply a comma-separated list of code-action pairs, specifying which action the business operation takes on receipt of various types of ACK response messages. The format of the list is: code=action,code=action, ... code=action For possible code and action values, see the HL7 Acknowledgment (ACK) Mode section in the Settings for a Routing Production chapter. Retry Interval Number of seconds to wait between attempts to connect with a destination outside Ensemble. Search Table Class The package and class name of a search table class that you have defined in this Ensemble namespace. A search table class is a specialized tool that you can create to work with virtual documents, such as HL7 messages. A virtual document is efficient because it contains a large amount of raw data but no instantiated properties. Creating a search table enables Ensemble to efficiently index a few of the fields in a virtual document so that these fields are available to be searched as if they were properties in a standard message body. To create a search table class, see the HL7 Search Tables section in this chapter. For further background information, see the Search Tables chapter in the book Ensemble Virtual Documents. Separators HL7 separator characters to use in the outgoing message. If you leave this field blank, the default is:
For further details, see HL7 Separator Characters in the Literal String Syntax section in the chapter Syntax for a Routing Production. The remaining entries in the Specific Settings column are determined by the type of adapter: TCP, File, FTP, or HTTP. The following adapter settings are especially important for HL7 business operations: Reconnect Retry (TCP only) Number of retries at which to drop the connection and try reconnecting again. A value of 0 (zero) means never disconnect. The default is 5. Stay Connected If StayConnected is a positive value, the adapter stays connected to the remote system for this number of seconds after completing an operation. A zero value means to disconnect immediately after every operation. The default of -1 means to stay permanently connected, even during idle times. Adapters are assumed idle at startup and therefore only auto-connect if they are configured with a StayConnected value of -1. For further information about any setting, hover the cursor over the setting name, or consult these references: Adapter Settings in the FTP Outbound Adapter chapter of Using FTP Adapters with Ensemble Adapter Settings in the File Outbound Adapter chapter of Using File Adapters with Ensemble Adapter Settings in the TCP Outbound Adapter chapter of Using TCP Adapters with Ensemble, which describes the settings for the general-purpose TCP outbound adapter. The difference for the special-purpose adapter called EnsLib.HL7.Adapter.TCPOutboundAdapter is that it has the following settings configured appropriately for HL7:
Get Reply
is set to True. This means the adapter will wait to read a reply message back from the socket before has its usual default of 5 seconds, but has a maximum limit of 30,000 seconds. has a default of 30 instead of its usual 15, and has a maximum limit of 30,000 seconds.
returning.
Connect Timeout
Response Timeout
The Using the HTTP Outbound Adapter chapter in Using HTTP Adapters with Ensemble
The SendAlert method from Cach Basic or ObjectScript code The <alert> element from a BPL business process The Alert On Error setting to enable automatic alerts from business hosts
All alert messages are automatically written to the Ensemble event log as entries of type Alert. However, the real purpose of an alert is to contact an external entity, such as a human user (via email or page) or a management tool (via WMI or SNMP). A production does this by directing all alert messages to a configuration item called Ens.Alert, which has been set up with all the information necessary to contact user devices outside Ensemble. For details, see the Alerts section in the Production Concepts chapter of Developing Ensemble Productions. The starter HL7 routing production provides the following elements to support alerts: Ens.Alert The starter HL7 routing production provides a built-in Ens.Alert element. This Ens.Alert is a routing process with an associated routing rule set called AlertRule. You can configure AlertRule to route alert messages to different business operations depending on the source of the alert message (that is, which element is in trouble) and various conditions (such as time of day). Tip: To view time-of-day function examples, start Studio and change to the ENSDEMO namespace. Look at the sample functions in the class Demo.HL7.MsgRouter.Functions.
To configure AlertRule, follow a similar procedure to the one for HL7 routing rule sets, except: For the Message Class, choose Ens.AlertRequest In the Target field, choose or type the configured name of an email business operation.
PagerAlert and EmailAlert These are ordinary email operations that can be configured to send a text message (such as the body of an alert) to a pager or email address. PagerAlert and EmailAlert are initially identical, other than their names. Both are provided to emphasize the fact that alerts have different priorities. Generally the higher-priority alerts go to a pager, lower-priority to email. You can configure any number of destinations that copy these starter operations. At runtime, your AlertRule routing rule set determines which destination is appropriate to use.
If you need more than this minimal list of virtual properties, you may subclass EnsLib.HL7.SearchTable to create new search table classes. Any subclass of EnsLib.HL7.SearchTable inherits the entries described in the previous table, plus the infrastructure that makes search tables work. To create a new search table class for your message routing production: 1. Start Studio and choose an Ensemble-enabled user namespace. Important: InterSystems recommends that you do not place custom code or data in the system-provided namespaces ENSLIB or ENSDEMO where it will be deleted the next time you upgrade Ensemble. The ENSEMBLE namespace and any new namespace that you create to hold your work is preserved across Ensemble upgrades.
2.
Choose File, then New. A dialog pops up. Edit it as follows: Click on the General tab. Select the Cach Class Definition icon and click OK. Enter a package and class name and click Next. Important: InterSystems recommends that you do not use the package names Demo, Ens, EnsLib, EnsPortal, or CSPX. This causes your work to be deleted the next time you upgrade Ensemble.
For Class type, choose Extends. Beside the Name of super class field, click the Browse button. Choose the EnsLib package and under HL7, choose SearchTable. Click OK. Click Finish.
3.
Position the cursor in the line between the curly brackets and select Class, then Add, then New XData. A dialog pops up. When prompted to enter a name, type:
SearchSpec
4.
5.
Now you may add <Item> entries inside the <Items> container.
The XData SearchSpec block lists the virtual properties whose values you want users to be able to search. The following code excerpt shows the XData SearchSpec block that defines the entries in EnsLib.HL7.SearchTable. These are the entries described in the previous table, Built-in Search Table Entries for HL7. You do not need to repeat any of these entries in your search table subclass, because it inherits them from EnsLib.HL7.SearchTable:
XData SearchSpec { <Items> <Item DocType="" PropName="MSHTypeName" >{1:9.1}_"_"_{1:9.2}</Item> <Item DocType="" PropName="MSHControlID" PropType="String:CaseSensitive" >{1:10}</Item> <Item DocType="" PropName="PatientID" >[PID:2.1]</Item> <Item DocType="" PropName="PatientID" >[PID:3().1]</Item> <Item DocType="" PropName="PatientID" >[PID:4().1]</Item> <Item DocType="" PropName="PatientName" >[PID:5]</Item> <Item DocType="" PropName="PatientAcct" >[PID:18.1]</Item> </Items> }
As you can see from the above example, an XData SearchSpec block contains one <Items> block, which may contain one or more <Item> elements. Each <Item> element contains a string expression, such as {1:10} in the above example. This string expression may include the following components in any combination: Literal characters within double quotes. Virtual property syntax within {} or []. This resolves to the value of the specified field in the HL7 message. Square brackets differ from curly brackets in that square brackets enclose a segment:field combination that does not require you to identify its containing message structure. ObjectScript string operators, such as the underscore (_) for concatenation. ObjectScript string functions, such as $PIECE or $EXTRACT.
The following example consists of one virtual property path that uses {} syntax. This <Item> element refers to the value at Segment 1, Field 10 of the HL7 message:
<Item DocType="" PropName="MSHControlID" PropType="String:CaseSensitive" StoreNulls="true" > {1:10} </Item>
The following more complex <Item> element uses the ObjectScript _ operator to concatenate three strings. From left to right, these are: The value within Segment 1, Field 4 A literal | character The value within Segment 1, Field 3
The following <Item> example uses most of the possible syntax options: concatenation, virtual properties, a literal hyphen character (-), and the ObjectScript string function $PIECE:
PropName
Any string that you expect to be unique and meaningful, when viewed with others in the list.
The following sample search table class provides several examples of valid <Item> entries. This class inherits from EnsLib.HL7.SearchTable, as is required for HL7 search tables. Comments above each group of <Item> entries describe the purpose of that set of entries. For details about {} or [] syntax, see the Virtual Property Syntax section of the book Ensemble Virtual Documents.
Class Demo.HL7.MsgRouter.SearchTable Extends EnsLib.HL7.SearchTable [ ClassType = persistent, ProcedureBlock ] { XData SearchSpec { <Items> <!-- Items that do not depend on DocType, indexing any HL7 message --> <Item DocType="" PropName="SendingFacilApp" >{1:4}_"|"_{1:3}</Item> <Item DocType="" PropName="RecvingFacilApp" >{1:6}_"|"_{1:5}</Item> <Item DocType="" PropName="MSHDateTime" PropType="DateTime:HL7" >{1:7}</Item> <!-- Get fields from named segments found in any HL7 message --> <Item DocType="" PropName="PatientName" >[PID:5]</Item> <Item DocType="" PropName="InsuranceCo" >[IN1:4]</Item> <!-- Get patient name from any HL7 message declared type ADT_A05 --> <Item DocType=":ADT_A05" PropName="PatientName" >{3:5}</Item> <!-- Get specific field from specific segment when the --> <!-- HL7 message is assigned a specific DocType. Only in this --> <!-- case can you use names for segments, instead of numbers. --> <Item DocType="Demo.HL7.MsgRouter.Schema:ORM_O01 " PropName="ServiceId" > {ORCgrp().OBRuniongrp.OBRunion.OBR:UniversalServiceID.text} </Item> <Item DocType="2.3.1:ORU_R01 " PropName="ServiceId" > {PIDgrpgrp().ORCgrp(1).OBR:UniversalServiceID.text} </Item> </Items> } }
3
Settings for a Routing Production
This chapter explains the details of important configuration settings within an HL7 message routing production. Topics include: HL7 Message Validation and Bad Messages HL7 Acknowledgment (ACK) Mode HL7 Dual Acknowledgment Sequences HL7 Message Framing Types HL7 Batch Messages HL7 Business Service Classes HL7 Business Operation Classes
An HL7 routing process has a configuration setting called Validation that controls the validation sequence. The following table lists the possible values for the Validation string:
Meaning Enables or disables various steps in the validation cascade. The flags may appear in any combination, except that z and z are mutually exclusive, and m includes z, so m is the same as mz.
The message validation sequence is as follows. If a flag is not present in the string, its associated step is disabled: 1. 2. 3. Test for issues controlled by d (if present). Test for issues controlled by m (if present). Exclude issues controlled by z (if z is present). Test for issues controlled by z (if z is present without m).
If at any time during this cascade the message fails validation, the HL7 routing process passes the message to its bad message handler (if present). If there is no bad message handler, the routing process simply stops the validation sequence without routing the message. On the other hand, any message that does not explicitly fail validation is allowed through. You can use the various options to control how many tests you want each HL7 routing process to apply.
3.
Whenever you override the OnValidate method, you must also override the Validation property definition in the same subclass. Pay careful attention to the following details: Its InitialExpression value. This sets the default for the Validation configuration setting. The comments that precede the Validation property definition. Use the /// convention and leave no white space lines between the last comment line and the property definition. This allows Ensemble Management Portal users to view your comments as a tooltip for the Validation setting. As an example, the following excerpt shows some of the comments that appear with the Validation property definition in the EnsLib.HL7.MsgRouter.RoutingEngine class:
Commit ACK The Ensemble business service returns an ACK to the source application as soon as it commits the transaction that saves the data received from that source. It sends a NACK if this proves impossible for some reason. The Ensemble business operation may be set up to interpret an ACK or NACK from the target application, but it does not return those messages to the source. Application ACK The Ensemble business service does not send an ACK or NACK to the source application until one returns from the target application by way of the Ensemble business operation. The business service returns the ACK or NACK that it receives from the business operation.
* Commit and Application ACK The third option only occurs in the rare condition where you set the Ack Mode to be MSH-determined and the MSH segment contains a value in both field 15 and 16 that requires an ACK. InterSystems recommends you avoid this condition. You use these acknowledgment conventions to send one of the three main types of ACK message content: Accept The message arrived, and was accepted. Reject The message arrived, but has been rejected. Error The message did not arrive successfully; try again.
The following sections describe the configuration settings you use to control ACK processing in Ensemble: HL7 ACK Configuration Settings for a Business Service HL7 ACK Configuration Settings for a Business Operation
Meaning Return ACK reply messages as requested in the MSH header fields 15 and 16. Either field may contain one of the following four control codes: AL Always NE Never ER Error or reject conditions only SU Successful completion only
MSH 15 (AcceptAcknowledgmentType) controls Commit ACK and MSH 16 (ApplicationAcknowledgmentType) controls Application ACK. Depending on how they are set in the incoming message MSH segment, one, both or neither may occur. Byte* Send back a single ACK-code byte instead of an ACK message, immediately upon receipt of the inbound message. ASCII 6 means OK; ASCII 21 means Error. This option is not available for any of the built-in HL7 business services (TCP, File, HTTP, and so on) but it is available if you write a custom business service that subclasses EnsLib.HL7.Service.Standard without overriding the Ack Mode setting.
* Ensemble business operations automatically treat a single byte ASCII 6 as an HL7 ACK with an AA commit code and ASCII 21 as an HL7 ACK with an AE commit code. Use ACK Commit Codes HL7 business services have a Use ACK Commit Codes setting that applies if the Message Schema Category is 2.3 or higher. It can be True or False. If True, when constructing an ACK message for HL7 messages version 2.3 or higher, the business service places one of the enhanced-mode ACK commit codes in the MSA segment AcknowledgmentCode field. This code may be one of the following two-letter sequences:
Table 33: Enhanced-Mode ACK Commit Codes for HL7 2.3 and Higher
Code AA AE AR CA CE CR Meaning in Original Mode Application Accept Application Error Application Reject Meaning in Enhanced Mode Application acknowledgment: Accept Application acknowledgment: Error Application acknowledgment: Reject Accept acknowledgment: Commit Accept Accept acknowledgment: Commit Error Accept acknowledgment: Commit Reject
Ignore Inbound ACK Setting Ignore Inbound Ack to True causes a business service to ignore any inbound ACK messages to avoid creating an ACK feedback loop. Add NACK ERR If the Add NACK ERR setting is True, when generating NACK messages, append an ERR segment that contains the Ensemble error codes and error text; otherwise do not embed internal error state information in NACK messages.
NACK Error Code Controls the error code in MSA:1 of the NACK message this service generates when there is an error processing the incoming message. The default is ContentE, which is to return code E for errors with the message content, and code R for system errors Ensemble encounters while attempting to process the message. This distinction is important because Ensemble expects system errors to be solved so that if the remote client tries again at a later time they may not occur, while message content and validation errors are expected to require correction at the source and not to be worth retrying in the same form. Some client systems may expect or require a different error behavior; therefore, Ensemble provides three additional behaviors. The following table describes the four options.
Meaning Matches AA or CA values (Accept) Matches AE or CE values (Error) Matches AR or CR values (Reject) Matches replies with an empty MSA:1 field. An empty or whitespace code value is the same as _ (underscore) Matches any MSA:1 value not matched otherwise (default=F) Matches replies that do not contain an MSA segment Matches where the reply MSA:2 ControlId does not match the ControlId of the original message
:* :~ :I?
Code
:T?
Meaning Matches where the reply MSH:9 Type name does not match the schemas declared reply type for the original message
You can also use the standard codes described in the Reply Code Actions Setting section in the Configuration chapter of Managing Ensemble Productions. The following values for action may be used alone or combined to form strings. F is the default action if no other is given, except for :?A whose default action is C:
Meaning Treat the message as Completed OK. Log a warning but treat the message as Completed OK. Retry the message according to the configured RetryInterval and FailureTimeout; finally Fail unless a different action is also specified Suspend the message, log an error, and move on to try the next message Disable the Operation, log an error and restore the outbound message to the front of the Operations queue Fail with an error and move on to try the next message
S D
This default indicates that Ensemble retries messages with acknowledgment codes AR or CR; for those with codes AE or CE, it suspends the current message, logs an error, and moves on to the next message. The default also treats any message with codes AA or CA as Completed OK and suspends messages that have a value in field MSA:1 that is not matched by any other listed reply code. For batch ACK messages, the business operation determines the correct Reply Code Actions based on the first child ACK found within the batch. Get Reply (TCP business operations only) If True, the business operation waits to read an ACK or other reply message back from the socket before returning. It also applies any defined Reply Code Actions.
is a specialized HL7 TCP business operation that sends out ACKs on behalf of a paired HL7 TCP business service. It also
depends on this partner to collect ACKs on its behalf. Each of these configuration items plays its usual role in addition to the work it does for its partner item. An EnsLib.HL7.Service.HTTPAckInService and EnsLib.HL7.Operation.HTTPAckOutOperation are also available.
Figure 32: Paired Business Service and Business Operation for Incoming Dual ACK
1. 2. 3. 4. 5. 6. 7. 8. 9.
The client application sends a message into Ensemble. The inbound ACK business service sends an immediate 1-byte ACK to the client application. The inbound ACK business service sends the message to its routing process. The routing process routes the message to its target via a business operation. The target application returns an ACK message to the business operation. Ensemble relays the ACK to the inbound ACK business service. The business service relays the ACK to its paired business operation. The business operation relays the ACK to the client application. The client application acknowledges the ACK message by returning a 1-byte ACK.
Figure 33: Paired Business Service and Business Operation for Outgoing Dual ACK
1. 2. 3. 4. 5. 6. 7. 8. 9.
A business service sends a message to its routing process. The routing process routes the message to the outbound ACK business operation. The outbound ACK business operation relays the message to the target application. The target application acknowledges the message by returning a 1byte ACK. The target application returns an ACK message to the inbound ACK business service. The business service sends an immediate 1byte ACK to the target application. The business service relays the ACK to its paired business operation. The business operation relays the ACK message back to the business service. The business service receives the ACK to its original message.
Choose EnsLib.HL7.Service.TCPAckInService or EnsLib.HL7.Service.HTTPAckInService as the business service class. It is not one of the standard HL7 Input options available from the Business Service Wizard, but you can choose it by selecting the Other option and identifying the class. 2. Add a business operation to the production. Choose EnsLib.HL7.Operation.TCPAckOutOperation or EnsLib.HL7.Service.HTTPAckOutOperation as the business operation class. It is not one of the standard HL7 Output options available from the Business Operation Wizard, but you can choose it by selecting the Other option and identifying the class. 3. Configure the following settings for the business service: Set Immediate Byte ACK to True. Then, in addition to forwarding a full ACK message according to the Ack Mode setting, the business service also returns an immediate 1-byte ACK on its TCP or HTTP connection. For a Partner Operation, choose the business operation that you added in Step 2. Whenever you specify a Partner Operation value, the business service ignores any inbound ACK messages that it receives directly, to avoid creating an ACK feedback loop. The business operation must exist and have the underlying class EnsLib.HL7.Operation.TCPAckOutOperation or EnsLib.HL7.Operation.HTTPAckOutOperation, respectively. 4. Configure the following setting for the business operation: Set the Partner ACK Timeout to the number of seconds for the business operation to wait for its partner business service to supply an ACK that corresponds to the normal outbound message that the business operation sent. The default is 600 seconds (10 minutes).
Table 37: Framing Types for HL7 Business Operations and Business Services
Framing Type Flexible None MLLP Inbound / Outbound Inbound Both Both Meaning Determine framing style from the content of received data. No framing; each line that begins with the string MSH is the start of a new message. Minimal Lower Level Protocol Frame each HL7 message with an ASCII 11 prefix and a suffix that consists of ASCII 28 followed by ASCII 13.
Meaning MLLP using non-standard ASCII values. Frame each HL7 message with a prefix that consists of the ASCII character value indicated by nn. Also provide a suffix that consists of the ASCII character value indicated by mm, followed by ASCII 13, the carriage return character. Frame messages with ASCII 10, the line feed character, separating each message from the subsequent one. Frame messages with an extra ASCII 13, the carriage return character, separating each message from the subsequent one. Frame messages with a suffix separating each message from the subsequent one. This suffix consists of the ASCII character value indicated by nn. Frame messages with a prefix character before each message. This prefix consists of the ASCII character value indicated by nn. Also provide a suffix that consists of the ASCII character value indicated by mm, but with no trailing ASCII 13. (Obsolete) Lower Level Protocol Frame each HL7 message in a redundant checksum block. Use the message Envelope property verbatim if it is present. If the string <!--HL72MSG--> is present in the envelope, Ensemble replaces it with the Message content; otherwise the Message follows the envelope text. Same as MsgEnvelope, but with the MLLP prefix and suffix also around the message inside the envelope.
Ascii[nn]/[mm]
Both
LLP MsgEnvelope
Both Outbound
MLLPMsgEnvelope
Outbound
When the framing type is MLLP, Ensemble automatically detects extra carriage returns (ASCII 13) that occur in the message before the close framing. This indicates to Ensemble that a blank line is not being used to separate messages, so it assumes that any blank line is part of the message content and can be safely ignored. You can specify multiple characters. For example, if you require nonstandard framing such as $Char(2) for message start and $Char(3,4) for message end for your HL7 messages, you can use the Ascii[nn]/[mm] framing option as follows:
Ascii2/3,4
Note:
ASCII values must be given as numeric values when you enter them in Framing fields. For example, enter lowercase x as Ascii120, not as Ascii'x'.
Ensemble recognizes FHS as a batch header segment, and FTS as a batch trailer segment. Within this container, Ensemble recognizes each MSH message header segment as the beginning of a child document. FHS BHS MSH ... MSH ... BTS BHS MSH ... MSH ... BTS FTS When FHS and BHS begin the message together, Ensemble recognizes FHS as the first-level parent document and each BHS as the beginning of a child document. BHS then becomes a second-level parent and the contents following each MSH segment become its child documents.
There are two production settings that control HL7 batch processing. On the incoming side, HL7 business services have a Batch Handling configuration setting that determines how to process incoming batch documents. The options are:
Whole Batch Do not process child documents individually; accumulate and send the whole batch as one composite
document.
Single-Session Batch Forward all child documents in the batch together in one session; the session includes objects representing the batch headers and trailers. Single-Session Batch is the default if no Batch Handling
value is specified.
Multi-Session Batch Forward each child document in the batch in its own session, with a unique session ID. Individual Forward each child document in the batch in its own session; do not forward objects representing
In responding to received messages, the default behavior is to send an acknowledgment to the sender as a batch document that contains an ACK message for each child document. This works for most situations. However, HL7 business services also have a property, not exposed as a configuration setting, called NoBatchReply. Its default value is 0 (false), which provides the default behavior. If you edit your business services OnInit method to include this statement:
Set ..Adapter.NoBatchReply = 1
Then batch replies are inhibited; each individual message gets a separate un-wrapped ACK. On the outgoing side, HL7 business operations have a AutoBatchParentSegs configuration setting. When AutoBatchParentSegs is False (the default) the business operation outputs child documents, but does not output the batch headers and trailers. When AutoBatchParentSegs is True, while outputting a message that has a batch parent, the business operation outputs the batch headers first, then the child documents, then follows up with the batch trailers when triggered by the final batch header message or by a file name change. The combination of Batch Handling and AutoBatchParentSegs enables the following modes of operation for HL7 batch documents. The ABPS column indicates values of AutoBatchParentSegs. Any combination of values not shown in this table is invalid.
ABPS (any)
Results Business service sends only the parent document; all child documents are referenced to it but not sent individually. Operation outputs entire batch at one time when it receives the parent document. Service sends each child document as it receives and parses it, followed by the parent document when all children have been sent. The business operation outputs parent headers when it receives the first child document, then finishes up with trailers when it receives the parent document object. Trailer segments automatically contain the correct child count values. This results in double output: the business operation sends out each child document individually, followed by the parent document containing each child document (again).
Single-Session
True
or
Multi-Session
Single-Session
False
or
Multi-Session Individual
False
Business service forwards each child document in the batch in its own session and does not forward objects representing the batch headers and trailers. On the outgoing side, the business operation does the same.
If you wish to add custom code to your routing process to handle batch documents specially on the output side, you can do so. The following are two possibilities: Your routing process code constructs new parent and child documents and links them, then sends each child to the business operation. The business operation must have AutoBatchParentSegs set to True. The business operation outputs parent headers when it receives the first child document, then finishes up with trailers when it receives the parent document object. Trailer segments automatically contain the correct child count values. Your routing process code constructs new parent and child documents and links them, but sends only the parent object via the business operation.
Figure 35: HL7 Business Service Class Hierarchy, Showing Inheritance of Settings
Figure 36: HL7 Business Operation Class Hierarchy, Showing Inheritance of Settings
4
Syntax for a Routing Production
Syntax rules for an HL7 Version 2 routing production are similar to those for any routing production based on virtual documents. For related information, see the following chapters in the book Ensemble Virtual Documents: Schema Category Syntax Virtual Property Syntax Literal String Syntax There are some details of literal string syntax where HL7 routing productions differ from other types of routing production, such as ASTM. The topics in this chapter describe them: HL7 Separator Characters HL7 Escape Sequences Null Mapping Codes
Finally, this chapter describes the HL7 Message Class, which plays a large role in HL7 Version 2 routing productions.
A sixth character, the segment terminator character, is not specified in MSH and is generally assumed to be a carriage return (ASCII 13).
Beyond positions 1 through 5 of the Separators string, you can supply additional characters to override the default segment terminator character, the carriage return (ASCII 13). After position 5, use \r for the carriage return (ASCII 13) and \n for the line feed (ASCII 10). You can use \x in positions 1 through 5 if you need to specify segment terminators in positions 6 and higher but want your output messages to use fewer than 5 separators. Separators designated by \x in positions 1 through 5 are not used. The purpose of \x is simply to extend the length of the list of separators so that position 6 is interpreted correctly as the first segment terminator.
This <assign> statement sets fields 2 and 3 of DG1(1):DiagnosingClinician by providing a literal string that contains the appropriate arrangement of subcomponent separator characters (^ in this case) to indicate field positions within the DG1(1):DiagnosingClinician component. Note: For this convention to work, ^ must actually be the subcomponent separator.
The following table lists the six standard HL7 escape sequences and their meanings. HL7 escape sequences begin and end with the escape character as defined in the MSH segment. HL7 escape sequences are case-sensitive, and they use the specific characters F R S T E or .br as shown in the table. In the examples shown, the \ (backslash) is the escape character.
If found within HL7 data, indicates... Carriage return Field separator character Repetition separator character Component separator character Subcomponent separator character Escape character
For example...
| ~ ^ & \
It is not necessary to provide any special processing in a DTL data transformation to handle the separator characters or escape sequences that already exist within the source message data. The business services and business operations that handle the incoming and outgoing sides of HL7 message transmission know which separator characters to expect on each side. Prior to being sent, the whole text of the message is automatically unescaped relative to the incoming set of separators, and then re-escaped relative to the outgoing set of separators. All of these HL7 issues are handled automatically when you use a DTL data transformation to <assign> fields in the source message to fields in the target message. On the other hand, if you <assign> a literal string to a target field using DTL, and that string needs to include HL7 separator characters, either as separators or as literal characters, some special handling is required. The procedures are as follows. Suppose you have a source message in which ^, \, and & are separators as listed in the MSH segment:
MSH|^~\&
Now suppose that, for all ADT_A01 messages that arrive from a certain clinical source, your DTL data transformation needs to assign a literal value to the InsuranceCompanyName field. The correct value has been agreed upon by all concerned parties, including the insurance company, whose name is Pierre DuRhne & Cie. The value is to appear in the HL7 data stream as follows:
Pierre DuRho^ne & Cie
In this case, you need HL7 escape sequences to replace ^ and & within the data, as follows:
<assign property='target.{PIDgrp.IN1grp(1).IN1:InsuranceCompanyName.organizationname}' value='"Pierre DuRho\S\ne \T\ Cie"'/>
The only other case in which you need to be concerned about separator characters is if you wish to migrate data into or out of an Ensemble HL7 virtual document without using a data transformation at all. The EnsLib.HL7.Segment class provides explicit Escape and Unescape methods that you can invoke to accomplish manually what a DTL data transformation does automatically to unescape and escape HL7 messages. A replace method also exists.
When your source application uses a null mapping convention, your HL7 data transformation can check for null mapping entries in HL7 fields and replace them with empty strings, or otherwise fill in data for the benefit of the target application. The following <if> statement represents the simplest case. It checks for a null mapping in the source and replaces it with an empty string in the target. The <if> condition tests for the null mapping code "" using a string of 2 quoted quotes. This results in a total of 6 double-quote characters, not including the single quotes that wrap the entire condition value. (Count carefully!)
<if condition='source.{PV1:7().4}=""""""'> <true> <assign property='target.{PV1:7().4}' value='""' /> </true> </if>
In the above example, the <assign> value indicates a empty string using 2 consecutive double-quote characters, with single quotes wrapping the entire value. The following syntax is equally valid:
<if condition='source.{PV1:7().4}=""""""'> <true> <assign property='target.{PV1:7().4}' value='""' /> </true> </if>
You can achieve more sophisticated goals for handling null mappings. The following example takes alternative actions based on whether there is actually a value in {PV1:3}. If the field contains a null mapping code the <true> element executes. Otherwise the <false> element executes.
<if condition='source.{PV1:3}=""""""'> <true> <assign property='target.{PV1:3.1}' value='source.{PV1:PatientType}' /> <assign property='target.{PV1:3.2}' value='source.{PV1:PatientType}' /> </true> <false> <code><![CDATA[ // Dr Chart pulls subfields as follows: // 1 location, 2 desc, 3 room, 4 bed, 5 wing, 6 floor ]]></code> <assign property='target.{PV1:3.1}' value='source.{PV1:3.1}' /> <assign property='target.{PV1:3.2}' value='source.{PV1:3.1}' /> <assign property='target.{PV1:3.3}' value='source.{PV1:3.2}' /> <assign property='target.{PV1:3.4.1}' value='source.{PV1:3.3}' /> <assign property='target.{PV1:3.5}' value='source.{PV1:3.1}' /> </false> </if>
structure is the name of a message structure within the referenced category. This means that structure must be the same as a <MessageStructure> name expressed somewhere inside the <Category> context as:
<MessageStructure name="structure" ... >
For example:
2.3.1:ORM_O01 2.4:ORD_O04 myCustomCategory:MFN_M03
When using HL7 with Ensemble, you must supply document type values, using the syntax described in this topic, for the following items: The DocType property of an HL7 message The sourceDocType attribute of a DTL <transform> element The targetDocType attribute of a DTL <transform> element
Source Doc Type Target Doc Type Message Type
or DocType in the [Ensemble] > [EDI and HL7 Manager] > [EDI Document Viewer] page
Tip:
To browse examples of category:structure combinations, use The Schema Structures Page as described in the chapter Viewing and Transforming Messages.
You can view details of any BuildMapStatus failure codes using The Schema Structures Page as described in the chapter Viewing and Transforming Messages.
kilobytes in size. It contains the first 32KB of the message, which is usually the entire message because most are smaller than 32KB.
Arguments
GetValueAt has one argument, a %String that contains a virtual property path. To compose this string, see the Virtual Property Path section in the book Ensemble Virtual Documents.
Return Value
GetValueAt returns the %String value of the virtual property named in the first argument.
Shortcuts
See Curly Bracket {} Syntax in the book Ensemble Virtual Documents.
Arguments
SetValueAt accepts two arguments: A %String value to assign to the virtual property. A %String that contains a virtual property path. To compose this string, see the Virtual Property Path section in the book Ensemble Virtual Documents.
Return Value
SetValueAt returns a value of type %Status that indicates success or failure.
Shortcuts
See Curly Bracket {} Syntax in the book Ensemble Virtual Documents.
5
Viewing and Transforming Messages
This chapter describes the Ensemble Management Portal pages that allow you to view and transform HL7 messages. From the [Ensemble] home page, you may choose options as follows: From the main menu, choose EDI / HL7 Manager. Click one of the following links:
HL7 Version 2 Displays the Web site for the American National Standards Institute (ANSI) standards developing
organization Health Level Seven (HL7). The URI is http://www.hl7.org/ Schema Structures Displays a list of the supported HL7 Version 2.x schema specifications. You can click on any link in the display to drill down for details. Message Viewer Allows you to preview the results of applying various parsing schemes or data transformations to HL7 message data.
From the main menu, choose Message Browser. The [Ensemble] > [Messages] page offers the following features for working with HL7 message data: Filter Messages Find archived HL7 messages that meet your filter criteria. You can specify detailed logical rules for the filter. Compare Messages Select two HL7 messages from the list on the [Ensemble] > [Messages] page. Click Compare Messages to display their contents side by side.
2.
3.
4. 5.
In the Username and Password fields, enter the username and password for a user account defined in the namespace. The default login is _SYSTEM with the password SYS. Click Login. The [Ensemble] home page displays.
To start the Ensemble Management Portal from Studio: 1. Choose an Ensemble namespace: 2. 3. Choose the File menu Change Namespace option. The Connection Manager displays. Choose a Server Connection and Namespace (choose an Ensemble namespace). If necessary, enter the Username and Password for that namespace and server. Click OK to save your changes, Cancel to cancel them.
Choose the Utilities menu Ensemble Management option. The Ensemble login page displays. Under the Ensemble login page title bar is a display area that contains a dialog box and a prompt to Please login. The dialog box provides Username and Password fields. Enter the username and password for a user account defined in the namespace you chose in Step 1. The default login is _SYSTEM with the password SYS. Click Login. The [Ensemble] home page displays.
4.
The HL7 schema definitions loaded into Ensemble were generated directly from the respective standards (HL7 2.1, 2.2, 2.3, 2.3.1, 2.4, 2.5, 2.5.1, and 2.6). They faithfully replicate any errors, omissions, or discrepancies that exist in these standards as published by the Health Level Seven organization. There is one exception to this rule: In the HL7 2.3.1 standard, the data structure XCN is the extended composite ID number and name for persons. The standard leaves XCN field 3 undefined by mistake. The Ensemble schema definition for HL7 2.3.1 corrects this so that XCN field 3 is correctly identified as given name. HL7 Version 3 is not listed as an HL7 schema category, because it uses entirely different data conventions from HL7 Version 2. HL7 Version 3 defines messages in XML format. Ensemble does not use virtual documents to represent HL7 Version 3 message structures. Ensemble handles the XML data directly, using XPATH and XSLT. For details, see the Ensemble HL7 Version 3 Development Guide.
Base Links
The standard category on which a custom category is based. Buttons you can click to drill down to various levels of each category: identify two Message Structures as a request/response pair. identify the sequence and grouping of Segments within a Message Structure.
Message Types
Code Tables
At the bottom of the page, a dialog offers selections that allow you to:
Import
or Export schema category definitions as XML files. a schema category from the drop-down list and Remove its definition from the Ensemble database. You cannot undo the Remove operation.
Choose
CAUTION:
The visual conventions on this page are as follows: The segments that comprise the message structure are listed in sequential order, from left to right. The three-letter name of each message segment is displayed: MSH, NTE, PID, etc. This name indicates the type of segment that exists at this location in the HL7 message structure. White lines enclose a single segment. The look is similar to a table cell (see MSH and the first NTE segment, above).
If segments are organized into a group, the entire group appears within the same table cell (see PID and ORC above). Green dotted lines enclose segments, groups, or fields that are optional. Red solid lines enclose segments, groups, or fields that, if present, may repeat several times. Orange dashed lines enclose a choice: this is a union of segments. Only one segment from the union can appear at this location within the message structure. It may be any of the segments listed. A segment, group, or field may be both repeating and optional (see any NTE above). You can navigate back to higher levels in the schema using the buttons Show All Categories and Show All Message Structures. To see the message structure you are currently viewing in a raw text format, click Show Raw Definition text. You can click Show Definition diagram to return to the segment diagram.
When you are viewing a segment diagram, if you hover the cursor over a three-letter segment name, a tooltip displays the syntax for referring to this segment in a virtual property path. In the previous example, the cursor is hovering over an ODS segment whose segment address is:
ORCgrp().OBRuniongrp.OBRunion.ODS
In the following example, the cursor is hovering over a PR1 segment whose segment address is:
PR1grp().PR1
This address is the segment portion of a virtual property path, which has the format segment:field. To discover valid values for the field portion of this path, click on the three-letter segment name in the diagram. The next several topics explore the results when you click on the PR1 segment in the message structure 2.3:ADT_A01.
The columns in the display have meaning as follows: The Field column lists the numbers you can use to access fields within the segment (if you prefer numbers). There may be a brief text Description of each field. The Property Name column lists the names you can use to access fields within the segment (if you prefer names). For more complex field values that use a data structure, you need further syntax details before you can complete the segment:field virtual property path. You can get this by clicking on a name in the Data Structure column The Symbol column indicates the syntax rules for the field. The characters in this column indicate whether you can expect this field to be present, absent, or repeated within the message segment. Possible values are: Symbol ! ? + * & n* Meaning (1 only) The field is required; it must occur only once. (0 or 1) The field is optional, but if it occurs, it may occur only once. (1 or more) The field may repeat one or more times. (0 or more) The field may repeat zero or more times. The field may be present, and may repeat, but only under certain conditions. (0 to n) The field repeats a maximum of n times.
The Repeat Count is the maximum number of times the field can repeat (if it repeats, and if there is a maximum). The Length is the maximum number of characters in the field. Each repeat of the field may contain this number of characters.
Required
displays R for required, O for optional. displays 1 for true, 0 for false.
Repeating
Click on an entry in the Code Table column (if any) to view the valid codes that may be entered in this field. There may be an Alternate Description of the field.
You can use this information, particularly the Property Name column, to build virtual property paths for Ensemble in the format segment:field. The following are examples of virtual property paths involving simple field values from the PR1
segment in the 2.3:ADT_A01 message structure. The () shortcut syntax indicates all available instances of a repeating field, whereas (1) indicates the first instance:
PR1grp().PR1:ProcedureType PR1grp().PR1:ProcedureCode() PR1grp().PR1:ProcedureCode(1) PR1grp().PR1:ProcedureCode(x) PR1grp().PR1:ProcedurePriority
The following sample page appears when you click the Data Structure item called 2.3:XCN in the segment structure page above. The page states that the category 2.3 data structure XCN describes an Extended Composite ID number and name and consists of fourteen fields. Of these, some are simple values, some are data structures, and some are codes.
Given this information, you can construct virtual property paths for the complex PR1grp().PR1:Surgeon field in the message structure 2.3:ADT_A01 as follows:
PR1grp().PR1:Surgeon.familyname PR1grp().PR1:Surgeon.degree
The example above shows that the category 2.3 code table 200 describes a Name type that can have the value L, O, M, A, C, or D. You can arrive at this page by clicking on: 1. 2. 3. 4. The message structure 2.3:ADT_A01 The message segment PR1, which has a segment address of PR1grp().PR1 The data structure DS:2.3:XCN in the optional Anesthesiologist field The code table CT:2.3:200 in the nametype field
This means that if you have an HL7 message with a DocType of 2.3:ADT_A01, it has an optional virtual property with the path PR1grp().PR1:Anesthesiologist.nametype that can contain one of the following values: L, O, M, A, C, or D. Note: For details, see the Virtual Property Path section in the book Ensemble Virtual Documents.
When HL7 Message is selected, the Document Viewer page allows you to retrieve HL7 message data from external files or the Ensemble message archives. You can: Preview the results of applying various parsing schemes or data transformations to message data. View an HL7 message as if it belonged to a particular category of HL7. Preview the results of an Ensemble data transformation by looking at the before-and-after contents of an HL7 message. Verify that you are using the correct category:structure syntax for the DocType of an HL7 message. Verify that you are using the correct segment:field syntax to use to access a specific data item within an HL7 message. Determine the DocType assignment that a particular business service would make for a particular message. View the content of messages from the Ensemble persistent store. View the content of messages from a file on disk.
The Document Viewer page allows you to try interpreting messages from a particular data source as version 2.1, or 2.2, etc., to determine which DocType is the right one to use when handling messages from that source. There are a variety of reasons why you might need to do this. For example, you might find when you update an external application that it has changed the actual version of the HL7 messages it sends, but has neglected to update the HL7 version declaration that it sends in these HL7 messages. It is also useful in determining which of the built-in categories to use as a schema base, when a message contains Z-segments. In the following example, the chosen Source is Filename and the chosen DocType/Schema is Category. The message being viewed is message number 33 within an archive file called XYZ120. No data transformation is being applied to the message at the moment. This example highlights some useful features of the Viewer: The MSH segment declares that the message is of type 2.2:ADT_O01, but the user has chosen Schema Category / Version with the category 2.3.1. The reason for this (not shown) is that when the user tried the message with Schema Category / Version 2.2 none of the message fields parsed correctly. The user moved on to try categories 2.3 and 2.3.1 before finding that 2.3.1 fit the message best. After the user clicks View HL7 Message, the bottom half of the page displays the results of parsing this message as a category 2.3.1 message. Links, such as for message segments 1 through 18, indicate that the message segments have parsed correctly using the selected Schema Category / Version. Clicking any of these links displays more specific information about the field. Non-links, such as appear for segments 19 through 24 in the illustration, indicate that the parser is not able to understand these segments of the message using the selected Schema Category / Version. This is to be expected for Z-segments if you have chosen a standard schema like 2.3.1 as the Schema Category / Version.
Just above the bottom half of the page, the parser reports that it has used a DocType of 2.3.1:ADT_O01 to parse the messsage, and that there are Z-segments at the end of the message (ZPI and following) that do not conform to this DocType. If you find a Schema Category / Version choice that allows the parser to understand all but the Z-segments in the message, then you know this standard schema is a good choice to be the basis of the custom schema that you create to parse the complete message including Z-segments. After you create a custom schema, it becomes available as a choice from the Schema Category / Version list.
Click a radio button to choose a Source for Message Data. The choices are:
Filename inside file
Click the Browse button to find a file that contains HL7 message data. Enter a number in the Message # field. Enter the object identifier of an Ensemble message.
Enter the name of an HL7 message type (<MessageType>) in the format category:type. The parser uses the message structure associated with the given message type.
HL7 Message Type (Version:Name) Use this DocType Enter the name of an HL7 message structure (<MessageStructure>) in the format category:structure.
The parser uses this message structure. The parser uses the message structure associated with the message type declared in the MSH segment of the message.
MSH declared Version:Name
The parser uses the DocType as declared in the HL7 message body object. (This option does not apply to stored messages loaded from a file.)
Objects saved DocType None The parser does not use any DocType to parse the message. It displays the raw segments without transforming
If you want to apply a data transformation to the HL7 message data, select the Apply Data Transform check box and enter the full package and class name of an Ensemble data transformation. From here you have two options: View the transformation on the [Ensemble] > [EDI and HL7 Manager] > [EDI Document Viewer] page. To do this:
Click one of the following radio buttons to determine the display format for the resulting HL7 message data:
Show Output Only
The transformed message appears in place of the original message on the page.
Show Input and Output side-by-side The format is the same, but you must use horizontal scroll bars to see
Save the transformed message to a file. To do this, enter a pathname in the field beside the Save To File button and click the button.
Following this report, the Document Viewer page displays the message data. This is the same view available on the [Ensemble] > [Messages] page when the Contents link is selected and the message contains HL7 data. There is one row in the display for each segment in the message structure. From left to right, the entries in each line reads as follows: The segment number on a white background: 1, 2, 3, etc. The segment name on a shaded background: MSH, PID, etc. Field contents and separator characters, exactly as provided in the message.
See the following close-up from a Document Viewer display of message contents. The cursor is hovering over the segment name NK1 which is segment number 5. The segment address is NK1(1) and the meaning of the segment is next of kin / associated parties.
Figure 513: Document Viewer Showing a Tooltip for the Segment Address
See the following close-up from a Document Viewer display of message contents. The cursor is hovering over the second data item in the NK1 segment, which contains the string Taylor. The field address is 2.1 or Name.familylastname. The field may repeat zero or more times. Each repeat of the field has a maximum length of 48 characters.
Figure 514: Document Viewer Showing a Tooltip for the Field Address
Figure 515: HL7 Batch Message with FHS and BHS,Top-Level Parent Document
When you click on a child document link in an HL7 batch message display, a new browser window opens to display the child document. The Message Viewer window, with the top-level parent, remains open in the original browser window. The next display is the result of clicking the child document link <2> in the previous display. This example is a two-level batch message, so the child document <2> has children of its own: child documents <3> through <32>. This example highlights a useful navigation feature of the Message Viewer. If there are more than 10 child documents in a batch message, the Message Viewer displays links to the first five and last five child documents. Between the lists is a text field, into which you can enter any identifier number between the first and last numbers. After you enter a number, click Other. A new browser window opens to display the child document.
Figure 516: HL7 Batch Message with FHS and BHS, Mid-Level Parent Document
The next display is the result of clicking the child document link <6> in the previous display. Since this is the lowest level of the batch message hierarchy, message <6> is a normal HL7 Version 2 message that begins with an MSH segment.
Figure 517: HL7 Batch Message with FHS and BHS, Child Document
When you are done viewing messages in the batch message hierarchy, you can close all the pop-up browser windows until the top-level parent document remains in the original Message Viewer window. From here, you may return to other Ensemble Management Portal activities.
For detailed instructions, see the Message Filter section in the Message Browser chapter of Managing Ensemble Productions.