The following examples will demonsrate how to use the contains (ct) operator with the following data types:

  • ST
  • INT
  • REAL
  • DATE
  • FILE

Example 1: 

The first example will demonstrate how, when using checkbox or multi-select items with a data type of ST, to check if a certain option is selected. For example, if you have a checkbox item with three options (Option 1, Option 2, and Unknown), you may want to make sure that ‘Option 1’ and ‘Option 2’ are not selected if ‘Unknown’ is selected:

    <RuleDef OID=”RULE1″ Name=”This is an example using ST data type”>
        <Description>’Unknown’ and at least one other option selected</Description>
        <Expression>(ITEM_OID_1 ct “1” or ITEM_OID_1 ct “2”) and ITEM_OID_1 ct “99”</Expression>

Similarly, the contains operator can be used with data types INT and REAL. Please note that all values must be enclosed in quotation marks in the expression when using the ct operator (i.e. “1” and “2”).

Example 2:

This example will demonstration how to use the contains operator to check for a certain year when using an item of data type DATE. For example you may want to write a Rule that will verify that the dat of informed consent occurred during the year 2014:

    <RuleDef OID=”RULE2″ Name=”This is an example using DATE data type”>
        <Description>The year is 2014</Description>
        <Expression>ITEM_OID_1 ct “2014”</Expression>

When set to evaluate to true, the Rule will fire if the date occurs in the year 2014. Alternatively, you could set the Rule to evaluate to false so that the Rule fires if the date does not occur in the year 2014.

Example 3: 

When an item is defined as a FILE data type, a Rule can be written to make sure the filename is a certain extension type. For example, the contains operator can be used to check for a PDF file:

<RuleDef OID=”RULE3″ Name=”This is an example using FILE data type”>
        <Description>The extension must be .pdf</Description>
        <Expression>ITEM_OID_1 ct “.pdf”</Expression>

If written to evaluate to false, the Rule will fire and an error message will appear if a file type other than .PDF is uploaded.