senaranya/HL7

Contructing a segment but not adding it in message leaves a gap in index numbering

Closed this issue · 0 comments

To reproduce: Create a segment:

$pid1 = new PID();

Do not add this to HL7 message (there can be reasons - e.g., we may decide not to add if the segment size isn't greater than 1).

Now create another segment:

$pid2 = new PID();

Add this one:

$hl7Msg->addSegment($pid2);

Expected message:

MSH|........|
PID|1|....|

Received Message:

MSH|........|
PID|2|....|

That is, it leaves a gap in place of the un-added segment.
This happens as we use a static variable to count serial index.