From: Archie C. <ar...@de...> - 2004-08-24 22:00:16
|
Archie Cobbs wrote: > > I've just upgraded to 0.4.2 and am encountering some problems. > > I've also just switched to a new HL7 feed so some of these problems > > may be related to that switch as well. > > > > #1: Infinite loops > > > > I'm receiving some ADT^A24 messages that seem to contain > > no PID segments (which is wrong I think). In any case, they > > send the HL7 server into an infinite loop when it tries to > > parse them! See log trace below. Oddly, when I cut & paste > > the same message into the Message Tester Swing app, it seems > > to parse it fine. > > Oops, correction: the ADT^A24 is properly formatted and does > contain the required PID segments. I was missing the latter half > of the message with cut&paste because of the carriage returns > without linefeeds. > > Also, the Message Tester Swing app goes into an infinite loop > (ie., hangs) also when trying to parse this message. > > I've attached a sanitized version below of a message that causes > this loop. FYI, ..continuing my conversation with myself... :-) This bug seems to be triggered by the fact that this message specifies that it is version "2.2" but actually contains a 2.3 segment, PD1. In any case, as a stopgap I've added the patch below to work around the problem. -Archie __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com diff -ur /home/archie/hapi/hapi-0.4.2/src/ca/uhn/hl7v2/model/AbstractGroup.java ./ca/uhn/hl7v2/model/AbstractGroup.java --- /home/archie/hapi/hapi-0.4.2/src/ca/uhn/hl7v2/model/AbstractGroup.java 2004-08-24 12:25:07.000000000 -0500 +++ ./ca/uhn/hl7v2/model/AbstractGroup.java 2004-08-24 16:48:12.000000000 -0500 @@ -140,6 +140,17 @@ if (version == null) throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null"); Class c = ca.uhn.hl7v2.parser.Parser.findSegmentClass(name, version); + + // Hack to try the next version if segment not found in this version + if (c == null) { + String[] vlist = new String[] { "2.1", "2.2", "2.3", "2.3.1", "2.4", "2.5" }; + for (int i = 0; i < vlist.length - 1; i++) { + if (version.equals(vlist[i])) { + c = ca.uhn.hl7v2.parser.Parser.findSegmentClass(name, vlist[i + 1]); + break; + } + } + } if (c == null) c = GenericSegment.class; |