When inserting a repetition in the last field of the segment, the insertRepetion method fails because the check on the fieldNum parameter is incorrect. The boolean expression on line 556 reads
if (fieldNum < 1 || fieldNum >= fields.size())
Because field number is indexed starting at 1 according to the HL7 standard, the expression must read
if (fieldNum < 1 || fieldNum > fields.size())
This will allow inserts to the last field in a segment. The same problem exists in the removeRepetion method.
Log in to post a comment.