the ct-operator for a rule with a multi-option-item

One of the lesser-known operators to use in a rule is the ct-operator.
Ct stands for contains. It is used on a string, takes one parameter and returns True or False.
An example could be that you want to check if in a CRF-item anything is mentioned about the heart. Your Rule Expression would then be:
ItemOID ct "heart" or ItemOID ct "cardi"

multi-option-item

This previous example is a bit far-fetched. Let's have a look at a real-life example. Think of a CRF with End of Study data.


fig. 1: The CRF

It is possible that more than one reason exists to end a study, so the option-list is made of checkboxes. All reasons that apply can be ticked. You do this by choosing checkbox for RESPONSE_TYPE and defining all the different options in RESPONSE_OPTIONS_TEXT and RESPONSE_VALUES_OR_CALCULATIONS.
Notice the double backslash as escape-character for the comma in "Patient decision, please specify".
Also notice that the DATA_TYPE (column T) is ST for string, and not INT for integer.


fig. 2: The XL-sheet

Now the CRF is in place we'll take a look at the ItemData. Let's say both item 2 and item 5 have been ticked:


fig. 3: Items 2 and 5 ticked

In the dataset this results in a string 2,5


fig. 4: The result

With this information we can create our rule. Did I mention Notepad++? And the page about finding OIDs? Right, then we put all the essential information in the header of the Rule file.


fig. 5: Header, full of info.

Then the easy part: defining the target for this rule and writing the discrepancy-message:


fig. 6: Target and message.

Then the fun part: the rule, with the ct-operator:
I_TDSEN_REASONSSTUDYSTOP ct "2" and I_TDSEN_SPECIFY eq ""


fig. 7: the rule with the ct-operator.

It's probably clear what this rule does: it check for the condition that the string with ticked options contains 2 and at the same time the field to Specify is empty.

that wasn't very impressive

You may find this not very impressive and say: "yeah, OK, you check the tick on one, just one little item: big deal. But what if I have, say, three items that need specifying?" Of course you can add more to your rule like:
(I_TDSEN_REASONSSTUDYSTOP ct "2" or I_TDSEN_REASONSSTUDYSTOP ct "5" or I_TDSEN_REASONSSTUDYSTOP ct "6") and I_TDSEN_SPECIFY eq ""

That's valid and it works, but it's not very legible and with more items it becomes a mess. So here's another approach.

In the example so far, we defined the values as integers, but we can also use characters for them. Or character-combinations. We will define all values as a, b, c, d, e and f. And for each option where we want a specification, we'll add spc. The result looks like this:


fig. 8: Alternative approach.

Now if options a, b and f are ticked as in fig. 9, then the output will be like fig. 10


fig. 9: Three options ticked.


fig. 10: Output.

Now our rule becomes very easy, because we only have to check for spc:
I_TDSEN_REASONSSTUDYSTOPALT ct "spc" and I_TDSEN_SPECIFY eq ""

Neat, isn't it?