ca.uhn.hl7v2.app
Class Responder

java.lang.Object
  extended by ca.uhn.hl7v2.app.Responder

public class Responder
extends java.lang.Object

Performs the responding role in a message exchange (i.e receiver of the first message, sender of the response; analagous to the server in a client-server interaction), according to HL7's original mode processing rules.

At the time of writing, enhanced mode, two-phase reply, continuation messages, and batch processing are unsupported.

Author:
Bryan Tripp

Constructor Summary
Responder(Parser parser)
          Creates a new instance of Responder that optionally validates parsing of incoming messages using a system property.
Responder(Parser parser, boolean checkParse)
          Creates a new instance of Responder that optionally validates parsing of incoming messages.
 
Method Summary
static java.lang.String logAndMakeErrorMessage(java.lang.Exception e, Segment inHeader, Parser p, java.lang.String encoding)
          Logs the given exception and creates an error message to send to the remote system.
static void main(java.lang.String[] args)
          Test code.
protected  java.lang.String processMessage(java.lang.String incomingMessageString)
          Processes an incoming message string and returns the response message string.
 void registerApplication(Application a)
          Registers an Application with this Responder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Responder

public Responder(Parser parser)
          throws LLPException
Creates a new instance of Responder that optionally validates parsing of incoming messages using a system property. If the system property ca.uhn.hl7v2.app.checkparse equals "true", parse integrity is checked, i.e. each message is re-encoded and differences between the received message text and the re-encoded text are written to the file /parse_check.txt.

Throws:
LLPException

Responder

public Responder(Parser parser,
                 boolean checkParse)
Creates a new instance of Responder that optionally validates parsing of incoming messages.

Parameters:
validate - if true, encodes each incoming message after parsing it, compares the result to the original message string, and prints differences to the file "/parse_check.txt" in the working directory. This process is slow and should only be used during testing.
Method Detail

processMessage

protected java.lang.String processMessage(java.lang.String incomingMessageString)
                                   throws HL7Exception
Processes an incoming message string and returns the response message string. Message processing consists of parsing the message, finding an appropriate Application and processing the message with it, and encoding the response. Applications are chosen from among those registered using registerApplication. The Parser is obtained from the Connection associated with this Responder.

Throws:
HL7Exception

logAndMakeErrorMessage

public static java.lang.String logAndMakeErrorMessage(java.lang.Exception e,
                                                      Segment inHeader,
                                                      Parser p,
                                                      java.lang.String encoding)
                                               throws HL7Exception
Logs the given exception and creates an error message to send to the remote system.

Parameters:
encoding - The encoding for the error message. If null, uses default encoding
Throws:
HL7Exception

registerApplication

public void registerApplication(Application a)
Registers an Application with this Responder. The "Application", in this context, is the software that uses the information in the message. If multiple applications are registered, incoming Message objects will be passed to each one in turn (calling canProcess()) until one of them accepts responsibility for the message. If none of the registered applications can process the message, a DefaultApplication is used, which simply returns an Application Reject message.


main

public static void main(java.lang.String[] args)
Test code.



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