The biggest thing you want to do is use three-argument $order to collapse from two global references to one: $ORDER(^[Nspace]LAB(PIDX),1,Data)
In regards to the question about setting BBData or other small variants like that, it may very much be data-dependent and depend on what happens later in the loop that you haven't showed us. But generally speaking if you're going to calculate the $p more than once, you probably do want to store it in a (private) variable.
You can certainly combine multiple conditions with and and or operators (&& and ||) if that's what you're asking. Also, constructs like $case and $select can help (in case you haven't encountered them before).
- Log in to post comments