ca.uhn.hl7v2.app
Class DefaultApplication

java.lang.Object
  extended by ca.uhn.hl7v2.app.DefaultApplication
All Implemented Interfaces:
Application
Direct Known Subclasses:
AcceptApplication

public class DefaultApplication
extends java.lang.Object
implements Application

An Application that does nothing with the message and returns an Application Reject message in response. To be used when there are no other Applications that can process a given message.

Author:
Bryan Tripp

Constructor Summary
DefaultApplication()
          Creates a new instance of DefaultApplication
 
Method Summary
 boolean canProcess(Message in)
          Returns true.
 void fillDetails(Message ack)
          Fills in the details of an Application Reject message, including response and error codes, and a text error message.
static void fillResponseHeader(Segment inbound, Segment outbound)
          Populates certain required fields in a response message header, using information from the corresponding inbound message.
static Message makeACK(Segment inboundHeader)
          Creates an ACK message with the minimum required information from an inbound message.
 Message processMessage(Message in)
          Creates and returns an acknowledgement -- the details are determined by fillDetails().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultApplication

public DefaultApplication()
Creates a new instance of DefaultApplication

Method Detail

canProcess

public boolean canProcess(Message in)
Returns true.

Specified by:
canProcess in interface Application

processMessage

public Message processMessage(Message in)
                       throws ApplicationException
Creates and returns an acknowledgement -- the details are determined by fillDetails().

Specified by:
processMessage in interface Application
Throws:
ApplicationException

fillDetails

public void fillDetails(Message ack)
                 throws ApplicationException
Fills in the details of an Application Reject message, including response and error codes, and a text error message. This is the method to override if you want to respond differently.

Throws:
ApplicationException

makeACK

public static Message makeACK(Segment inboundHeader)
                       throws HL7Exception,
                              java.io.IOException
Creates an ACK message with the minimum required information from an inbound message. Optional fields can be filled in afterwards, before the message is returned. Pleaase note that MSH-10, the outbound message control ID, is also set using the class ca.uhn.hl7v2.util.MessageIDGenerator. Also note that the ACK messages returned is the same version as the version stated in the inbound MSH if there is a generic ACK for that version, otherwise a version 2.4 ACK is returned. MSA-1 is set to AA by default.

Parameters:
inboundHeader - the MSH segment if the inbound message
Throws:
java.io.IOException - if there is a problem reading or writing the message ID file
DataTypeException - if there is a problem setting ACK values
HL7Exception

fillResponseHeader

public static void fillResponseHeader(Segment inbound,
                                      Segment outbound)
                               throws HL7Exception,
                                      java.io.IOException
Populates certain required fields in a response message header, using information from the corresponding inbound message. The current time is used for the message time field, and MessageIDGenerator is used to create a unique message ID. Version and message type fields are not populated.

Throws:
HL7Exception
java.io.IOException


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