UPDATE:
Upon further testing and asking around, it looks like my initial reading of the AND_NOT
logical connector was based on an older version of the documentation. It turns out that the AND_NOT
logical connector is broken and is not recognized by the VGR parser. It seems that the OR_NOT
operator works, but I still need to do some testing to confirm it. I've made some notations to this article where needed.
Original Post
When reading the VGR documentation and putting together my VGR Cheat Sheet, I found that, in addition to the familiar logical connectors {AND, OR, THEN}
, there are also the AND_NOT
and OR_NOT
connectors. If you're not sure what I'm talking about when I say logical connectors, this is how the VGR Handbook defines them:
Connector: A logical connector for linking multiline VGR rules. This only applies to IF statements with multiple conditions, and IF statements where there are multiple commands in the THEN clause.
That's to say, that seventh piece of your VGR code that:
- Connects multiple
IF
statements:IF ... AND ... AND ... THEN
- Connects multiple lines after the
IF
:IF ... THEN ... AND ...
If you look at the Logical Connectors section of my VGR Cheat Sheet, you'll see four entries: AND
, AND_NOT
, OR
, and OR_NOT
. Just as you might expect, the AND
returns true
if both IF
statements evaluate to true
and the OR
returns true
if either IF
statements evaluate to true
.
So what about the AND_NOT
andOR_NOT
logical connectors? They are a little more specific. The Similarly, the AND_NOT
returns true
if the first IF
evaluates to true
and the second IF
evaluates to false
.OR_NOT
evaluates to true
if the first IF
evaluates to true
or the second IF
evaluates to false
When would I ever need to use these?
I had wondered the same thing. Why use something like:
INIT,IF,,a,EQ,b,OR_NOT INIT,IF,,x,EQ,y,THEN
...when you could just as easily use NE
(Not Equal), the logical inverse of EQ
(Equal), in the second line and code it as:
INIT,IF,,a,EQ,b,OR INIT,IF,,x,NE,y,THEN
The same could be said about using inverse logic for most of the logical operators (GT
/LT
, VALID
/INVALID
, etc).
It wasn't until recently that I actually came across a required usage of these other logical connectors. Consider the CONTAINS
operator. Unlike most of the other logical operators, there is no inverse statement to say that the variable does not contain your search string.
Consider this example of Active Orders Awareness with a multi-select prompt. The spec calls for the checkbox to be pre-checked if the order exists and has "Comfort measures"
selected. If the order existed beforehand, but didn't have "Comfort Measures"
selected, then modify the order prompt to contain it.
INIT,MAP,LOCAL,pneumoniaUI,TO,get_order.ui.356601.1 INIT,MAP,LOCAL,pneumoniaExclusion,TO,get_order.244168.356601.1 INIT,IF,,pneumoniaUI,NE,"???",THEN INIT,IF,,pneumoniaExclusion,CONTAINS,"Comfort measures",THEN INIT,SET,,chkDiagnosisPneumonia,TO,"yes" ################### # SKIP SOME STUFF # ################### # Modify EDIT,IF,,pneumoniaUI,NE,"???",AND EDIT,IF,,chkDiagnosisPneumonia,EQ,"yes",AND_NOT EDIT,IF,,pneumoniaExclusion,CONTAINS,"Comfort measures",THEN EDIT,SET,,orderstring,CAT,"@MODIFY_ORDER=UI=`pneumoniaUI^^^244168=Comfort measures\"
So while in the INIT
stage, the pre-checking occurs when the prompt contains the string, but the modify only occurs when the order exists and the prompt does not contain the string.
If you've found any other good uses of the AND_NOT
or OR_NOT
logical connectors, leave a comment below; I'd love to hear how different people approach these problems.
Updated Code
Given that AND_NOT
isn't supported by VGR, the code snippet listed above will not work. Here is how I rewrote it, using extra variables as true/false "flags":
INIT,MAP,LOCAL,pneumoniaUI,TO,get_order.ui.356601.1 INIT,MAP,LOCAL,pneumoniaExclusion,TO,get_order.244168.356601.1 INIT,SET,LOCAL,pneumoniaPrecheck,TO,"false" INIT,IF,,pneumoniaUI,NE,"???",THEN INIT,IF,,pneumoniaExclusion,CONTAINS,"Comfort measures",THEN INIT,SET,,chkDiagnosisPneumonia,TO,"yes",AND INIT,SET,,pneumoniaPrecheck,TO,"true" ################### # SKIP SOME STUFF # ################### # Modify EDIT,IF,,pneumoniaUI,NE,"???",AND EDIT,IF,,chkDiagnosisPneumonia,EQ,"yes",AND EDIT,IF,,pneumoniaPrecheck,EQ,"false",THEN EDIT,SET,,orderstring,CAT,"@MODIFY_ORDER=UI=`pneumoniaUI^^^244168=Comfort measures\"
Scott Morris is available for training, mentoring, troubleshooting, and iForms consulting. Find out more at www.thinkiforms.com
0 comments: