Table instance count

Find table row instances where the rule is currently being executed for a two-section form.

Rule description: if Yes is selected for Does the subject have any relevant Medical History?, then there must be at least one non-deleted table instance recorded or a query is issued.

Rule expression

If(MHSTDT!==null || MHONG!==null || MHENDT!==null){…..}
var instval=getCurrent2SFormInstance();
if(getStringFromChoice(MHYes)==='Yes' )  
{
var instcnt=list2SInstances(MHTERM,instval,0);
if(instcnt.length > 0)
{
return true;
}
else
{
return false;               //System sends query when return false condition is met
}
}
else
{
return true;
}

Query message: "Does the subject have any relevant Medical History?" has been answered "Yes", therefore data is expected in the table. Please review and complete.

Definitions

MHSTDT, MHONG, MHENDT

Table section items in two-Section form.

MHYes

Item on Flat section which is target item.

MHTERM

Table section item in two-Section form used as parameter to the "list2SInstances()" helper function.

getCurrent2SFormInstance( )

Gets the form instance number of the current two-section form.

getStringFromChoice( )

Converts selected label for the choice element (drop-down, radio buttons or checkboxes) to a string or a comma-separated value. Takes in the choice element as parameter.

list2SInstances( )

Lists all table instances of the passed-in variable in a two-section form. Takes an item variable of the table section in the form as a parameter.

Return value

Boolean

Returns either true or false. System raises query when return false condition is met.

Usage tips

To make sure the rule runs whenever any of the items in the table section of a two-section form is completed or updated, you must create global variables for each of them and use the variables to evaluate if any of these are not null. This is done in the first line of the rule expression.

Note:

For this evaluation, you should not include the item passed as a parameter to the ListRFInstances( ) helper function in the rule expression logic.

Verification steps

  1. Using a subject for testing, go to the given visit and form containing the iems to check, in this example the Does the subject have any relevant Medical History? question <MHYes> .
  2. Update the form item MHYes as in the following table and verify the result is as listed:
    Step Result

    a. In the flat section of a first instance of a two-section form (Form1), enter the MHYes item as 'Yes'.

    Query

    b. In Form1, create a first table instance and complete all items.

    No query

    c. In Form1, clear all items in the first table instance.

    No query

    d. In Form1, delete the first table instance.

    Query

    e. In the flat section of Form1, update the MHYes item as 'No'.

    No query

    f. In the flat section of Form1, update the MHYes item as 'Yes'.

    Query

    g. In Form1, create a new first table instance and complete some items.

    No query

    h. Create a second two-section form instance (Form2) and enter the MHYes item as 'Yes' in the flat section.

    Query in Form2

    i. In Form2, create a first table instance and complete some items.

    No queries

    j. Delete Form2.

    No query

Note:

Repeat the above steps if the form is present in multiple visits.

Other examples

Example 4-29 Trigger query if the read only "Was PE Date populated?' is populated with "Yes", and there is no date completed in the repeating section.

var instval=getCurrent2SFormInstance();
if(getStringFromChoice(PEDT)==='Yes')  
{
var instcnt=list2SInstances(RES,instval,0);
if(instcnt.length > 0)
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}

Query message: Date of Physical Exam is entered. However, there is no entry in the table.