Looping Through Grouped NTE Segments
Does anyone have a cleaner approach than this for looping through grouped NTE segments in order to set the segment ID in an ORM? I am aiming to avoid the NTE segments that may follow the PID segment and find the NTE's that follow the OBR segment. By using the below If statement in the While loop, I'm finding NTE's that have comments in the fourth field (PID NTE's tend not to have these in the messaging I'm seeing, I'm awaiting confirmation on this), as well as finding my newly inserted NTE segment using $FIND to locate the colon (I've concatenated some values).
Although this code is working, my worry is that if an NTE:4 field after the OBR segment happens to be blank for whatever reason then the If statement will miss out that NTE segment, also, if the NTE following the PID includes an NTE:4 then that will be recognised as part of this loop which isn't what I'd want. I don't suppose anyone has done something similar/cleaner without the need for this complexity?