/** * <p> * New instance which always uses the given acknowledgment code, and generates an * appropriate message for the given code, according to the following rules: * </p> * <table> * <tr><th>Code</th><th>Message</th></tr> * <tr> * <td>{@link AcknowledgmentCode#AA}<br/>{@link AcknowledgmentCode#AA}</td> * <td><code>null</code> (no message)</td> * </tr> * <tr> * <td>{@link AcknowledgmentCode#AR}<br/>{@link AcknowledgmentCode#AR}</td> * <td>{@link #MSG_NO_APPROPRIATE_DEST}</td> * </tr> * <tr> * <td>{@link AcknowledgmentCode#AE}<br/>{@link AcknowledgmentCode#AE}</td> * <td>{@link #MSG_INTERNAL_ERROR}</td> * </tr> * </table> * * @param theAcknowledgmentCode The code to always use (must not be null) */ public DefaultApplication(AcknowledgmentCode theAcknowledgmentCode) { this(theAcknowledgmentCode, defaultMessage(theAcknowledgmentCode)); }
/** * Returns the first Application that has been bound to messages of this type. */ private <T extends Message> ReceivingApplication<T> findApplication(T theMessage) throws HL7Exception { Terser t = new Terser(theMessage); AppRoutingData msgData = new AppRoutingDataImpl(t.get("/MSH-9-1"), t.get("/MSH-9-2"), t.get("/MSH-11-1"), t.get("/MSH-12")); ReceivingApplication<T> app = findDestination(theMessage, msgData); //have to send back an application reject if no apps available to process if (app == null) { app = (ReceivingApplication<T>)new DefaultApplication(); } return app; }
/** * {@inheritDoc} */ public Message processMessage(Message theIn) throws ApplicationException, HL7Exception { String encodedMessage = new PipeParser().encode(theIn); System.out.println("Received message:\n" + encodedMessage + "\n\n"); // Now we need to generate a message to return. This will generally be an ACK message. MSH msh = (MSH)theIn.get("MSH"); ACK retVal; try { // This method takes in the MSH segment of an incoming message, and generates an // appropriate ACK retVal = (ACK)DefaultApplication.makeACK(msh); } catch (IOException e) { throw new HL7Exception(e); } return retVal; }
/** * Returns the first Application that has been bound to messages of this type. */ private <T extends Message> ReceivingApplication<T> findApplication(T theMessage) throws HL7Exception { Terser t = new Terser(theMessage); AppRoutingData msgData = new AppRoutingDataImpl(t.get("/MSH-9-1"), t.get("/MSH-9-2"), t.get("/MSH-11-1"), t.get("/MSH-12")); ReceivingApplication<T> app = findDestination(theMessage, msgData); //have to send back an application reject if no apps available to process if (app == null) { app = (ReceivingApplication<T>)new DefaultApplication(); } return app; }
/** * <p> * New instance which always uses the given acknowledgment code, and generates an * appropriate message for the given code, according to the following rules: * </p> * <table> * <tr><th>Code</th><th>Message</th></tr> * <tr> * <td>{@link AcknowledgmentCode#AA}<br/>{@link AcknowledgmentCode#AA}</td> * <td><code>null</code> (no message)</td> * </tr> * <tr> * <td>{@link AcknowledgmentCode#AR}<br/>{@link AcknowledgmentCode#AR}</td> * <td>{@link #MSG_NO_APPROPRIATE_DEST}</td> * </tr> * <tr> * <td>{@link AcknowledgmentCode#AE}<br/>{@link AcknowledgmentCode#AE}</td> * <td>{@link #MSG_INTERNAL_ERROR}</td> * </tr> * </table> * * @param theAcknowledgmentCode The code to always use (must not be null) */ public DefaultApplication(AcknowledgmentCode theAcknowledgmentCode) { this(theAcknowledgmentCode, defaultMessage(theAcknowledgmentCode)); }