From the source I downloaded 3/20/07, I parsed an 835 with a PLB segment in it (appears in the footer right above the SE segment). I get the error 'Improper sequencing noted with segment PLB at segment 22017, field 1. From tracing through the code, I noticed that from loop level 2 you try to close three levels of loops (I guess to go to level zero). When I take out the check in your code that is checking this condition, a IndexOutOfBounds exception occurs. I worked around it by changing the LoopDescriptor assigned for the PLB segment to use loop level 1 like this:
---------
public ANSI_835() {
super("835", "Health Care Claim Payment Advice");
loops = new LoopDescriptor[] { new LoopDescriptor("1000A", "N1"),
new LoopDescriptor("1000B", "N1", 1, "1000A"),
new LoopDescriptor("2000", "LX", 1),
new LoopDescriptor("2100", "CLP", 2),
new LoopDescriptor("2110", "SVC", 3),
new LoopDescriptor("", "PLB", 1), };
}
-----------
This results in a complete parsing, but represents the PLB in a loop with Id="".
I think the intent of the level 0 loop was to go back to the interpretation of segments you get when you start parsing a document before the loops start.
Here is the last part of console debug log. Please forgive me for not posting my x12 source as it contains patient data. I don't think it would be hard to reproduce this error - just add a PLB segment:
...nextToken in the QTY
...nextToken in the QTY
parsing segment CLP within the 835 document
considering segment CLP while in loop 2100 with stack /2000/2100
plugin query for segment CLP
Number of descriptors found: 1
checking level context -1
checking loop context * with current loop stack /2000/2100
considering segment CLP using descriptor loop 2100 at nesting level 2: encountering segment CLP anytime
transitioning to level 2
closing 1 loops
popped LoopContext loopName:2100 position:0 repetitions:0 mandatory: off the stack
pushed 2100 onto the stack
closing 1 loops
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
...nextToken in the CLP
parsing segment CAS within the 835 document
considering segment CAS while in loop 2100 with stack /2000/2100
plugin query for segment CAS
No descriptors found
considering segment CAS using descriptor null
...nextToken in the CAS
...nextToken in the CAS
...nextToken in the CAS
...nextToken in the CAS
parsing segment NM1 within the 835 document
considering segment NM1 while in loop 2100 with stack /2000/2100
plugin query for segment NM1
No descriptors found
considering segment NM1 using descriptor null
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
parsing segment NM1 within the 835 document
considering segment NM1 while in loop 2100 with stack /2000/2100
plugin query for segment NM1
No descriptors found
considering segment NM1 using descriptor null
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
...nextToken in the NM1
parsing segment REF within the 835 document
considering segment REF while in loop 2100 with stack /2000/2100
plugin query for segment REF
No descriptors found
considering segment REF using descriptor null
...nextToken in the REF
...nextToken in the REF
parsing segment DTM within the 835 document
considering segment DTM while in loop 2100 with stack /2000/2100
plugin query for segment DTM
No descriptors found
considering segment DTM using descriptor null
...nextToken in the DTM
...nextToken in the DTM
parsing segment DTM within the 835 document
considering segment DTM while in loop 2100 with stack /2000/2100
plugin query for segment DTM
No descriptors found
considering segment DTM using descriptor null
...nextToken in the DTM
...nextToken in the DTM
parsing segment QTY within the 835 document
considering segment QTY while in loop 2100 with stack /2000/2100
plugin query for segment QTY
No descriptors found
considering segment QTY using descriptor null
...nextToken in the QTY
...nextToken in the QTY
parsing segment PLB within the 835 document
considering segment PLB while in loop 2100 with stack /2000/2100
plugin query for segment PLB
Number of descriptors found: 1
checking level context -1
checking loop context * with current loop stack /2000/2100
considering segment PLB using descriptor loop at nesting level 0: encountering segment PLB anytime
transitioning to level 0
closing 3 loops
ERROR: 'Improper sequencing noted with segment PLB at segment 22017, field 1'
Failure to transform: javax.xml.transform.TransformerException: com.berryworks.edireader.EDISyntaxException: Improper sequencing noted with segment PLB at segment 22017, field 1
com.berryworks.edireader.EDISyntaxException: Improper sequencing noted with segment PLB at segment 22017, field 1