比较相关实例
检查重复表单中匹配实例的值。
规则说明:同一相关“逆事件”(AENUM) 的严重性(单选控件)必须不同于上一个控制。
规则表达式
//variable declaration
var rc;                         //Radio Control - severity
var ins;                        //placeholder for Repeating Form instance 
var outc='';                    //placeholder for severity label value
var cnt=0;                      //counter variable
//function definition to identify number of instances matching the severity value
function functi(item,index)
{
	if(item.deleted===false && item.value!==null && index!==(ins-1) && index<ins-1)
	{
	
		if(item.value===aenum1val)                                    //Checks if the passed-in instance has a matching AE number value with the current instance
		{
		     if(newsev[index]!==null && sevval!==null)                    
		     {
			     outc=JSON.parse(newsev[index].value)[0].label;     //Retrieves label from severity selection made by the user in the related instance
			     if(outc===sevval)                                //Checks if the severity value in the related instance is matching in the current instance
			     {
			          cnt=cnt+1;                                 //Updates the number of identified matching instances
			     }
			     else
			     {
				    cnt=cnt;
			     }			
	            }
		     else
		     {
		          cnt=cnt;
		     }
		}
		else
		{
		     cnt=cnt;
		}
     }
     else
     {
          cnt=cnt;
     }		
}
try
{
//variable declaration
	ins = GetCurrentRFInstance();                                //Retrieves instance of the current AE form
	var aenum1val=aenum1;                                        //Adverse event number item
	var sevval=getStringFromChoice(newsev1);                    //Variable for severity item to retrieve the label for the severity choice item selected by the user
	rc=getValues('aenum','newsev');                              //Gets values entered for AE number and severity items
	if(rc===true && aenum1val!==null && sevval!==null && ins>1)     //Checks if getValues function retrieved results array, if AE number and severity values are not null and if current instance is not the first instance of the form
	{
		aenum.forEach(functi);        //Execute the function code for all AE number values entered in the form
		if(cnt>0 )
		{
			return false;          //System sends query when return false condition is met
		}
		else 
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}
catch(err)
{
    setQueryMessage(err);                 //set query message to display an encountered error
    return false;                         //System sends query when return false condition is met
}
                  查询:新的严重性与前一个严重性相同。请检查。
定义
- newsev
 - 
                        
                        
根据规则说明为严重性项创建了变量。
 - aenum
 - 
                        
                        
对应于规则说明中的反向事件编号项。
 - GetCurrentRFInstance( )
 - 
                        
                        
获取当前重复表单的表单实例编号。
 - getStringFromChoice( )
 - 
                        
                        
将选择元素(下拉列表、单选按钮或复选框)的选定标签转换为字符串或逗号分隔值。接受选择元素作为参数。
 - getValues( )
 - 
                        
                        
在多次访问中按访问顺序以数组格式提取一个或多个变量的值。在这种情况下,将采用上述 aenum 和 newsev 变量。
 - setQueryMessage( )
 - 
                        
                        
指定作为参数传入的动态查询文本。
 - functi(item,index)
 - 
                        
                        
函数已在代码中声明。标识与给予严重性值匹配的实例数。
 
验证步骤
- 使用主题进行测试,转至包含要检查的 iems 的给定访问和表单,在此示例中,指定重复表单实例中的反向事件编号 <
aenumval> 和严重性 <sevval>。 - 按照下表更新表单项 
aenumval和sevval,并验证结果是否已列出:步骤 附注 结果 a. 在第一个重复形式 (1RF) 实例中,将
aenumval项输入为 '1' (AE1),然后选择sevval作为 'Grade 1'。仅一个重复表单实例。 无查询。
b. 转到第二个重复形式 (2RF) 实例,并将
aenumval项输入为 '1' (AE1),然后选择sevval作为 'Grade 1'(与上一步相同)。匹配 1RF 和 2RF 中的值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE1
 - 严重性级别 1
 
 
在 2RF 中查询。
c. 将 2RF 实例中的
sevval项更新为“ 2 级”。1RF 和 2RF 中的不同值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE1
 - 严重性级别 2
 
 
无查询。
d. 将 2RF 实例中的
sevval项更新为“ 1 级”。匹配 1RF 和 2RF 中的值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE1
 - 严重性级别 1
 
 
在 2RF 中查询。
e. 将 2RF 实例中的
aenumval项更新为 '2' (AE2)。1RF 和 2RF 中的不同值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE2
 - 严重性级别 1
 
 
无查询。
f. 创建一个 thrid 重复形式 (3RF) 实例,然后将
aenumval项输入为 '1' (AE1),将sevval输入为 'Grade 1'。匹配 1RF 和 3RF 中的值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE2
 - 严重性级别 1
 
 - 3RF:
                                             
- AE1
 - 严重性级别 1
 
 
在 3RF 中查询。
g。 将 3RF 中的
aenumval更新为 '3' (AE3)。所有重复表单实例中的不同值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE2
 - 严重性级别 1
 
 - 3RF:
                                             
- AE3
 - 严重性级别 1
 
 
无查询。
您好。 将 3RF 中的
aenumval项更新为 '2' (AE2)。匹配 2RF 和 3RF 中的值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE2
 - 严重性级别 1
 
 - 3RF:
                                             
- AE2
 - 严重性级别 1
 
 
在 3RF 中查询。
i。 将 2RF 中的
sevval项更新为“ 3 级”。所有重复表单实例中的不同值: - 1RF: 
                                             
- AE1
 - 严重性级别 1
 
 - 2RF:
                                             
- AE2
 - 严重性级别 3
 
 - 3RF:
                                             
- AE2
 - 严重性级别 1
 
 
无查询。
 - 1RF: 
                                             
 
其他示例
示例 4-28 治疗的开始日期必须晚于或等于同一药物上一处方的治疗停止日期
var rc;
var ins;
var ind=-1;
var res='';
function functi(item,index)
{
	if(item.deleted===false && item.value!==null && index!==(ins-1) && index<ins-1)
	{
		if(item.value===trtname1)
		{
			if(stpdt[index]!==null && stdt[ins-1]!==null)
			{
				if(getDatesCompareResult(stdt[ins-1].value,true,stpdt[index].value,true,'>='))
				{
					ind=1;	
					
				}
				else{  ind = 0;}
			}
		}
	}
}
	ins = GetCurrentRFInstance();
	rc=getValues("trtname","stdt","stpdt");
	if(rc===true && ins!==1)
	{
		trtname.forEach(functi);
		if(ind===0)
		{			
			return false;
		}
		else { return true; }
	}
	else
	{
		return true;
	}
                  查询消息:起始日期早于上一个处方的终止日期。请更正或确认。
父主题:重复表单示例