#19 Terser getSegment() throws exception if segment not found

open
nobody
None
5
2010-11-12
2010-11-12
Steve Short
No

I'm trying to process a message that may (or may not) contain a non-standard ROL segment. I'm calling the Terser getSegment() method:

ISegment segment = messageTerser.getSegment("/.ROL");

This works fine when the non-standard ROL segment is present but fails with an HL7Exception and the message "End of message reached while iterating without loop" in MessageNavigator.iterate() if the segment is not present in the message.

Is this behaviour by design ?

If so, is there any way that I can programatically check whether the non-standard segment exists in the message before calling getSegment ? I've looked at methods such as Message.GetAll() and Terser.Finder.nextChild() but these only return the defined segments and don't include the non-standard segments. I can't find a way of determining whether the non-standard segment is present in the message or not.

Any help gratefully received...

Discussion