Home Applications UnitTest_RuleSet


This application is not supported by InterSystems Corporation. Please be notified that you use it at your own risk.
1 reviews
IPM installs
Pull requests
Unit Tests for HL7 Routing in IRIS Integration

What's new in this version

Initial Release


IRIS UnitTest TestCase Template. UnitTest for HL7 Routing Rules in IRIS Integration.

Code consists of:

  • UnitTest.RuleSet.HL7 - Subclass this to generate new unit tests for your HL7 routing rules

Also included to demonstrate implementation:

  • UnitTest.RuleSet.Example - An example subclass to demonstrate how to create routing unit tests
  • UnitTest.RuleSet.TestHL7 - An example production where
  • UnitTest.RuleSet.TestHL7.RoutingRule - An example routing rules to be tested

To run all UnitTest on a new UnitTest class manually:

Do ##class(UnitTest.RuleSet.Example).Debug()

How it works

When messages are routed they generate logs with two interesting properties:

  • Reason - This will contain the Rule number that processed: “rule#1(SYSA):when#1”
  • ReturnValue - This will contain the name of the routing target used: “send:To_SystemA: “
    Exact or Contains (Default) matching to values for these log properies are baked into the unit tests.
    The subsequent UnitTest requires these expected routing outcomes are confirmed during testing.

The output of tests are recorded and available via the normal test url.
This is dispayed at the conclusion of the unit test on the command line.

Display Terminal output at end of test

Summary of Test Run

Detail of Test Run

Environment configuration

Leveraging the built-in TestCase Runner we require that the global “UnitTestRoot” points to a physical directory for example “c:\temp”

Set ^UnitTestRoot="c:\temp"

TestCases contain a suite name parameter. So if this is called “RuleSetHL7” you also need to create a subdirectory with this name

mkdir c:\temp\RuleSetHL7

How to create a new HL7 routing UnitTest

Define a class overriding UnitTest.RuleSet.HL7 :

  1. Parameter TestSuite - To a suitable name if required
  2. Parameter HL7Schema - The HL7 Schema of your message. Useful to augment per-Test message content, before sending to be evaluated for routing.
  3. Parameter SourceBusinessServiceName - The Name of your HL7 Business Service in your production. Not to update the pool size to 2 for testing.
  4. Parameter TargetConfigName = The name of your Business Process that is an instance of an HL7 Routing Engine
  5. Create new Methods with names prefixed “Test”. These will invoke the method “SendMessage” with critera about the message routing result expected.
  6. XData SourceMessage - Replace with base HL7 messages suitable to your business need. Note the HL7Schema should match to effect per-test updates.
/// d ##class(UnitTest.RuleSet.Example).Debug()
Class UnitTest.RuleSet.Example Extends UnitTest.RuleSet.HL7

Parameter TestSuite = "RuleSetHL7";

/// Override for different schema
Parameter HL7Schema = "2.5.1:OUL_R22";

/// Override with name of existing service on production
Parameter SourceBusinessServiceName = "From_SystemZ";

/// Override with name of existing business process routing engine on production
Parameter TargetConfigName = "MsgRouter";

Method TestMessageA()
#dim message as EnsLib.HL7.Message
set message=..HL7Message.%ConstructClone(1)
do message.PokeDocType(message.DocType)
do message.SetValueAt("SYSA","MSH:3.1")
set expectSuccess=1
set expectReturn="send:To_SystemA:"
set expectReason="rule#1"
do ..SendMessage(message,"TestMessageA", expectSuccess, expectReturn, expectReason)

XData SourceMessage


1.0.013 Jul, 2022
Works with
InterSystems IRIS for HealthHealthShare
First published
13 Jul, 2022