ca.uhn.hl7v2.validation.app
Class TestApplication

java.lang.Object
  extended by ca.uhn.hl7v2.validation.app.TestApplication
All Implemented Interfaces:
Application
Direct Known Subclasses:
MultiTestApplication, ProfileTestApplication

public abstract class TestApplication
extends java.lang.Object
implements Application

An application intended for testing messages. The intended use is to route a copy of (selected) messages to a test application, which identifies and acts on problems independently of the normal error acknowledgement path (for example by notifying an administrator). This makes the most sense when used within an interface engine, for example if the sending nor receiving system use HAPI, but it is desired to route messages to HAPI in parallel so that they can be fully validated.

Author:
Bryan Tripp

Constructor Summary
TestApplication()
          Creates a new instance of TestApplication
 
Method Summary
abstract  boolean canProcess(Message in)
          Returns true if this Application wishes to accept the message.
 Message processMessage(Message in)
          Calls test(Message in), routes resulting exceptions to configured destinations, and returns an ack (which should not normally be used since the test app is intended to operate in parallel with system-to-system communication).
abstract  HL7Exception[] test(Message in)
          Tests the message in some way (as defined by implementing class).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestApplication

public TestApplication()
Creates a new instance of TestApplication

Method Detail

canProcess

public abstract boolean canProcess(Message in)
Returns true if this Application wishes to accept the message. By returning true, this Application declares itself the recipient of the message, accepts responsibility for it, and must be able to respond appropriately to the sending system.

Specified by:
canProcess in interface Application

processMessage

public Message processMessage(Message in)
                       throws HL7Exception

Calls test(Message in), routes resulting exceptions to configured destinations, and returns an ack (which should not normally be used since the test app is intended to operate in parallel with system-to-system communication).

Notification routing is performed using log4j, so you need appropriate settings in a log4j config file (by default, ./log4j.properties). Different types of exceptions are all given the same severity (ERROR) but they have different loggers, based on the exception class name. Specifically, the loggers will be named ca.uhn.hl7v2.validation.error.{exception class name}. For example: "ca.uhn.hl7v2.validation.error.DataTypeException". Note that this allows default settings for all validation errors using the logger "ca.uhn.hl7v2.validation.error". The intent is for different exceptions to result in different actions, e.g. a ProfileNotHL7CompliantException should probably just be logged or ignored, while a ProfileNotFollowedException should probably be emailed to an administrator.

Specified by:
processMessage in interface Application
Throws:
HL7Exception

test

public abstract HL7Exception[] test(Message in)
                             throws HL7Exception
Tests the message in some way (as defined by implementing class).

Returns:
exceptions that describe any identified problems with the message
Throws:
HL7Exception - if the message can't be tested (not for errors disovered during testing)


Copyright © 2001-2011 University Health Network. All Rights Reserved.