showing or hiding items on a CRF using a rule-file

As we've seen in the page about the SimpleConditionalDisplay it is indeed simple to show or hide an item on your CRF, provided that
- this depends on just one other item and
- that this item is numerical and
- that this item is on the same CRF.
But what if you want to show or hide an item based on multiple conditions and/or multiple items? In that case we can write a Rule.
Let's first make a CRF with information about the end of study.


fig. 1: CRF with three items

If the user chooses option 2, 5 or 6, then we would like the specify field to be shown and otherwise we would like to hide it. Before we go to the rule-file, we must fill in a columns: ITEM_DISPLAY_STATUS (Z), so we can set the default status to HIDE, because at the start of entry we do not want the specify-item to be visible.


fig. 2: The ITEM_DISPLAY_STATUS

After uploading our CRF looks like this:


fig. 3: The CRF

the Rule-file

Now we are ready to compose our rule-file and we start with finding the OIDs of the variables we will use. Information on how to do this can be found here.
We start with documenting the rule-file and here we list the OIDs of all the variables we use. In this case the important one are I_TDSEN_REASONSSTUDYSTOP_2849, which is the list of radio-buttons, and I_TDSEN_SPECIFY_6063 for the specification.


fig. 4: Documentation of the rule-file.

The target for our rule is I_TDSEN_REASONSSTUDYSTOP_2849 and we write this first. It may be a bit confusing to speak of the radio-buttons as the "target", because the "target" of this whole exercise is the specify-field. But in the rule-file this field will be referred to as the "Destination": we'll come to that. For now keep in mind that the "target" is used in building the Expression.


fig. 5: Target

Now let's first do the easy part: the expression to evaluate. This is the target, I_TDSEN_REASONSSTUDYSTOP_2849, and the values to check for are 2, 5 and 6.


fig. 6: Expression

Once we've made our expression, we must define what to do when this expression evaluates to True and what when it evaluates to False. This is done in ShowAction and HideAction. In both cases the "Destination" for the Action is I_TDSEN_SPECIFY_6063 In the ShowAction a message will be displayed: Please specify the reason.


fig. 7: ShowAction and HideAction

Show me!

Everything's in place and we enter data: 06-Jul-2011 for the date, Patient decision, please specify for the Reason and then we hit Save.


fig. 8: ShowAction in action

The first thing we see is the field Specify in yellow. Then we see the standard message Based on your answers, you need to answer additional questions below. ======= on the top of our screen. Then in the grey area where we normally have our validation-messages, we now see our message Please specify the reason.

What happens if we change the reason for example to Normal? Then we can click Save and the CRF will close and everything's fine.

And what if we had something already in the Specify-field? And then chose for Normal? This is surprising: we can save the data and the Specify-field will be visible, despite the HideAction! If you do not want this situation, you still must write a rule to tell the user to delete the content of Specify.


fig. 9: Unwanted behaviour

And your rule would be something like:


fig. 10: Rule to fix it

Other how-to-pages can be found here.

this page was last reviewed August 2013