Your basis appears to b e incorrect. You should never use the variable in your basis that you are just defining. %f1 is just being defined. It is used for the field repetition counter in your case. Notice that the basis drops off the (0) after the #5. That is where the variable that you are defining will be used.
#5(%f1)
Your iterates should start at the PID grouping, with 1 as your basis and %g1 as the variable, next inside the PID iterate group would be the ORC iterate group with 1(%g1).1 as you first nested basis with a variable of %g2, third would be the OBX/NTE grouping inside the ORC grouping with the basis 1(%g1).1(%g2).1 and %g3 as the variable. Last would be the field iterate nested under these iterates with the basis 1(%g1).1(%g2).1(%g3).OBX(0).#5 with variable %f1.
The variables become counters. Lets say the PID group usually has one group per messaage. The %g1 would have the value 0. Inside that group it contains all segments down through CTI. In your message strructure that is where the top curly brace end. It could have multiple ORC groups stating with the curly brace before the ORC sement. %g2 will count the number of times that ORC and all the segments contained within the curly braces that define that group. Notice that OBX and NTE are grouped, and the 3rd counter %g3 counts those repetitions. Finally if you are after the repeating contents of OBX:5, the %f counts the repetitions of the OBX:5 field usually by the repetition character.
As Gary has indicated, make use of your testing tool and review the message with the level turned up. You will then see the numbers increment based on those iterations. The real trick is that once you understand your inbound addresses, is to make use of those variables in the outbound if you choose to contruct your messages diffently. For instance if you wanted to copy each field repetition into its own OBX segment, you might have something like:
1(%g1).1(%g2).1(%g3).OBX(0).#5(%f1) –> 1(%g1).1(%g2).1(%f1).OBX(0).#5
Notice the use of %f1 instead of the %g3 on the outbound side of the copy. Without testing….but this should create a new OBX segment for each field repetition. Of course there is cleanup etc… required to make this happen cleanly…. Happy motoring!!!