getValues( )
使用此辅助函数可按访问顺序以数组格式提取多个访问中一个或多个变量的值。
这是聚合函数。在目标位于重复表单上时,将为每个表单实例运行规则。对于重复表单和两部分表单中的空行,将仅包括输入并随后清除的行。从未向其中输入数据的行将不会返回。
语法
getValues('var1', 'var2', ...)
参数
参数 | 必选/可选 | 说明 |
---|---|---|
'var1', 'var2', ... |
至少需要一项。 | 用于定义要检索的访问、表单或项的规则变量名称。 |
返回值
在成功时返回 true
;否则返回 false
。
此外,在调用此函数时,使用 getten 值重新定义在规则变量(var1、var2...)中传递的值。因此,每个变量存储一个包含属性的数组。
数组中的每个项(例如
警告:
如果没有与此变量相关的数据元素,则规则变量将重新定义为null
。因此,在将变量用于处理数据之前,应始终验证变量是否包含任何数组元素。
var1[0]
)都包含以下信息作为属性:
属性 | 说明 |
---|---|
var1[0].visitName |
访问的名称。 |
var1[0].deleted |
如果删除重复表单实例,则为 True。 |
var1[0].tableRowInstance |
重复表行实例,以防它在表中。 |
var1[0].branchName |
分支的名称。 |
var1[0].eventType |
访问类型:
|
var1[0].formRepeatNumber |
案例表单中的重复表单实例编号是重复表单。 |
var1[0].value |
数据元素值,或 null (如果清除值)。
|
var1[0].cycleNumber |
访问的周期编号,以防它处于周期中。 |
var1[0].empty |
如果值已清除或从未以重复形式输入,则为 True。 |
var1[0].cleared |
如果清除重复表单实例,则为 True。 |
var1[0].treatmentArm |
治疗臂。 |
使用提示
- 如果您使用的是为 -Any Visit- 定义的变量,则必须使用此帮助程序函数来获取值并在表达式中使用它们。您无法直接在逻辑中使用此类变量。使用以下格式,其中
'variable'
是任何访视类型变量:getValues('variable')
此类型的变量定义允许您使用在与创建规则的目标表单相同的访问中不存在的表单中收集的数据。有关详细信息,请参阅定义规则变量。
- 如果问题存在于多个访视中,则 getValues( ) 返回的数据量可能很大。考虑一下这可能会影响性能。
- 将变量传递到 getValues( ) 后,不能将其重新用作规则中其他位置的离散值。如果需要引用行的离散值并访问其他位置,则需要声明第二个变量。
示例
示例 3-102 查看单个项的 getValues 函数调用的结果
// this can be helpful during rule development to view the results returned by the getValues function
// using a read-only text field as the target
var val = getValues("item1");
if (val == true) {
return JSON.stringify(item1);
}
/* example results:
[
{
"visitName": "visit1",
"deleted": false,
"tableRowInstance": null,
"branchName": null,
"eventType": "ScheduleAbleVisit",
"formRepeatNumber": null,
"value": "Test",
"cycleNumber": null,
"empty": false,
"treatmentArm": null
},
{
"visitName": "visit2",
"deleted": false,
"tableRowInstance": null,
"branchName": null,
"eventType": "ScheduleAbleVisit",
"formRepeatNumber": null,
"value": "Test",
"cycleNumber": null,
"empty": false,
"treatmentArm": null
}
]
*/
示例 3-103 对所有访问的所有肿瘤直径值求和
var sumTotalLongestDiameter = -1;
function calculateTumor(item, index)
{
if ( longestDiameter[index] !== null )
{
sumTotalLongestDiameter += longestDiameter[index].value;
}
}
var rc = getValues("tumorID", "longestDiameter");
if ( rc === true )
{
tumorID.forEach(calculateTumor);
// Set the value for the current row where this rule runs
return sumTotalLongestDiameter;
}
示例 3-104 在所有访问中汇总肿瘤直径值,使用过滤功能排除筛查访问
var rc = getValues("tumorID", "longestDiameter");
//filter by visit name
function filterFunction(item) {
return item.visitName !== 'Screening';
}
var sumTotalLongestDiameter = -1;
function calculateTumor(item, index)
{
if ( longestDiameter[index] !== null )
{
sumTotalLongestDiameter += longestDiameter[index].value;
}
}
if ( rc === true )
{
//exclude Screening visit
var filterResult = tumorID.filter(filterFunction);
filterResult.forEach(calculateTumor);
// Set the value for the current row where this rule runs
return sumTotalLongestDiameter;
}
示例 3-105 使用相同格式的目标和操作数查找上一个/下一个值
规则变量:
brDateForFunc
- 引用日期的规则变量。brDate
- 引用日期的规则变量(与第一个引用不同名称的规则变量相同,以防应比较不同访问上的相同项)。
var visitName = getCurrentVisitPropertyValue("visitid");
var currCycle = getCurrentCycle();var prevValue = null;
var prevValueFound = false;
function getPrevValue(item){
if(prevValueFound) return;
if(item.visitName==visitName && item.cycleNumber==currCycle){
prevValueFound = true; return;
}
if(item.eventType!='UnScheduleAbleVisit' && item.value!=null)
prevValue = item.value;
}
var res = getValues('brDateForFunc');
if(res){
brDateForFunc.forEach(getPrevValue);
//in case the next visit should be found the array should be reverted:
//brDateForFunc.reverse().forEach(getPrevValue);
//here should go the necessary logic to compare brDate with previous value which is now in variable prevValue
}
示例 3-106 使用不同表单上的目标和操作数查找下一个值或最接近的下一个值
规则变量:
aeDate
- 引用 AE 表单上的日期的规则变量。cycleDate1
- 引用第一次周期访问时的日期的规则变量。cycleDate2
- 引用第二次周期访问日期的规则变量。cycleCheck1
- 规则变量,引用第一次周期访问时的某个条件。cycleCheck2
- 规则变量,引用第二个周期访问中的某个条件。vsd
- 具有“所有访问”选项的访问开始日期
var lastStartedlVisit = null;
var lastVisitFound = false;
var cycleDate = null;
var cycleCheck = null;
var cycleNumber = null;
function getLastStartedlVisit(item){
if(lastVisitFound || item.eventType=='UnScheduleAbleVisit') return;
//condition may depend on where the point of comparison is, at some situation it can be <if(item.value==null)> or something else
if(item.eventType=='AdverseEvent'){
lastVisitFound = true;
return;
}
if(item.value!=null) {
lastStartedlVisit = item;
}
}
function findItem(item, index){
if(item.cycleNumber === cycleNumber){
if(this.valueOf()=='cycleDate') cycleDate = item.value;
if(this.valueOf()=='cycleCheck') cycleCheck = item.value;
}
}
var res = getValues('vsd');
if(res){
//the first visit before AE
vsd.forEach(getLastStartedlVisit);
//in case the next visit should be found the array should be reverted:
//vsd.reverse().forEach(getLastStartedlVisit);
cycleNumber = lastStartedlVisit.cycleNumber;
res = getValues('cycleDate1');
if( cycleDate1[cycleDate1.length-1].visitName == lastStartedlVisit.visitName){
cycleDate1.forEach(findItem, 'cycleDate');
res = getValues('cycleCheck1');
cycleCheck1.forEach(findItem, 'cycleCheck');
}
else{
res = getValues('cycleDate2');
if( cycleDate2[cycleDate2.length-1].visitName == lastStartedlVisit.visitName){
cycleDate2.forEach(findItem, 'cycleDate');
res = getValues('cycleCheck2');
cycleCheck2.forEach(findItem, 'cycleCheck');
}
}
}
//logMsg(JSON.stringify(aeDate))
//logMsg(JSON.stringify(cycleDate));
//logMsg(JSON.stringify(cycleCheck));
//logic to compare cycleDate cycleCheck and aeDate
示例 3-107 将日期与下次访问开始日期进行比较
规则变量:
brDate
- 引用日期的规则变量。vsd
- 引用“所有访问”选项的访问开始日期的规则变量。
var visitName = getCurrentVisitPropertyValue("visitid");
var currCycle = getCurrentCycle();
//logMsg(visitName);
//logMsg(currCycle);
//logMsg(brDate);
var nextValue = null;
var nextValueFound = false;
function getNextValue(item){
if(nextValueFound) return;
if(item.visitName==visitName && item.cycleNumber==currCycle){
nextValueFound = true;
return;
}
if(item.eventType!='UnScheduleAbleVisit' && item.value!=null)
nextValue = item.value;
}
var res = getValues('vsd');
if(res){
vsd.reverse().forEach(getNextValue);
//logMsg(nextValue);
//logMsg(brDate);
//compare next vsd with cycle date: vsd
}
父主题:格式设置和其他函数