Menu

#123 Responder Issue

None
closed-fixed
None
5
2013-01-09
2011-06-26
James Agnew
No

Documenting this issue reported by Nicholas Lefebvre

----

I have found a problem with the Responder.java class of Hapi-Base since release 1.1, in the "ca.uhn.hl7v2.app" package. One Hl7Exeption is not handle. To correct this, I suggest this improvement (in bold) in the Responder.java file :

protected String processMessage(String incomingMessageString) throws HL7Exception {
HapiLog rawOutbound = HapiLogFactory.getHapiLog("ca.uhn.hl7v2.raw.outbound");
HapiLog rawInbound = HapiLogFactory.getHapiLog("ca.uhn.hl7v2.raw.inbound");

log.info( "Responder got message: " + incomingMessageString );
rawInbound.info(incomingMessageString);

Message incomingMessageObject = null;
String outgoingMessageString = null;
try {
incomingMessageObject = parser.parse(incomingMessageString);
}
catch (HL7Exception e) {
try {
outgoingMessageString = logAndMakeErrorMessage(e, parser.getCriticalResponseData(incomingMessageString), parser, parser.getEncoding(incomingMessageString));
} catch (HL7Exception e2) {
outgoingMessageString = null;
}
for (Object app : apps) {
if (app instanceof ApplicationExceptionHandler) {
ApplicationExceptionHandler aeh = (ApplicationExceptionHandler) app;
outgoingMessageString = aeh.processException(incomingMessageString, outgoingMessageString, e);
}
}
}

if (outgoingMessageString == null) {
try {
//optionally check integrity of parse
try {
if (checkWriter != null)
checkParse(incomingMessageString, incomingMessageObject, parser);
}
catch (IOException e) {
log.error( "Unable to write parse check results to file", e );
}

//message validation (in terms of optionality, cardinality) would go here ***

Application app = findApplication(incomingMessageObject);
Message response = app.processMessage(incomingMessageObject);

//Here we explicitly use the same encoding as that of the inbound message - this is important with GenericParser, which might use a different encoding by default
outgoingMessageString = parser.encode(response, parser.getEncoding(incomingMessageString));
}
catch (Exception e) {
outgoingMessageString = logAndMakeErrorMessage(e, (Segment) incomingMessageObject.get("MSH"), parser, parser.getEncoding(incomingMessageString));
}
}

log.info( "Responder sending message: " + outgoingMessageString );
rawOutbound.info(outgoingMessageString);

return outgoingMessageString;
}

I tested this modification and it is solving that problem.

I hope you can take it into account before your next release of Hapi.

I worked about this bug with one of my colleague, Gabriel Landais.

Thanks a lot in advance,

Discussion

  • James Agnew

    James Agnew - 2013-01-09

    Fix checked in.

    Not that it was applied to ApplicationRouterImpl, as the functionality above was migrated there in the current release.

     
  • James Agnew

    James Agnew - 2013-01-09
    • status: open --> closed-fixed
    • milestone: -->
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.