getValues( )

このヘルパー関数を使用して、複数の訪問にまたがる1つ以上の変数の値を、訪問順に配列形式でフェッチします。

注意:

これは集計関数です。ルールは、ターゲットが繰返しフォームにある場合に、各フォーム・インスタンスに対して実行されます。繰返しフォームおよび2セクション・フォームの空の行の場合、入力してからクリアした行のみが含まれます。データが入力されたことがない行は返されません。

2セクション・フォームとともに使用すると、GetCurrentRFInstance( )を使用して、現在の2セクション・フォーム・インスタンスでのみルールを実行するように制限できます。

構文

getValues('var1', 'var2', ...)

パラメータ

'var1', 'var2', ...
ルール変数名(訪問、フォームまたは項目を定義します)。

戻り値

成功した場合はtrue、それ以外の場合はfalseを返します。

また、この関数のコール中に、取得した値を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
  • 日付要素:
    • 返される変数値は、変数が完全な日付の場合のDateオブジェクトです。
    • 返される変数値は、変数が日付の一部である場合のC1Dateオブジェクトです。
      • C1Dateオブジェクト(部分日付)の場合、日付値は、item.valueではなく、item.value.dayitem.value.monthなどの日付部分を使用してフェッチする必要があります。
        // Sample JSON response for a partial date item:
        [
            {
                "visitName": "visit1",
                "deleted": false,
                "tableRowInstance": null,
                "branchName": null,
                "eventType": "ScheduleAbleVisit",
                "formRepeatNumber": null,
                "value": {
                    "partialDate": true,
                    "date": null,
                    "day": "UNK",
                    "month": 2,
                    "year": 2021
                },
                "cycleNumber": null,
                "empty": false,
                "treatmentArm": null
            }
        ]
  • 選択制御要素:変数が選択制御(チェックボックス、ラジオまたはドロップダウン)の場合、返される変数値はJSON形式の文字列です:
     "[{\"value\":\"3\",\"label\":\"TestLabel\"}]"
    これは、JSON.parseまたはparseChoice( )を使用して解析できます。
var1[0].cycleNumber サイクル内にある場合のビジットのサイクル番号。
var1[0].empty 値がクリアされた場合、または繰返しフォームに入力されなかった場合はtrue。
var1[0].cleared 繰返しフォーム・インスタンスがクリアされている場合はtrue。
var1[0].treatmentArm 治療アーム。

使用上のヒント

-Any Visit-に定義された変数を使用する場合は、このヘルパー関数を使用して値を取得し、式で使用する必要があります。ロジックで変数を直接操作することはできません。次の形式を使用します。'variable'は、任意のビジット・タイプ変数です:
getValues('variable')
このタイプの変数定義を使用すると、ルールを作成しているターゲット・フォームと同じビジットに存在しないフォームで収集されたデータを操作できます。詳細は、ルール変数の定義を参照してください。

制限

  • 質問が複数の訪問に存在する場合、getValues( )によって返されるデータの量は大きくなる可能性があります。これは、データ送信のパフォーマンスに影響する可能性があります。
  • getValues( )に変数を渡した後は、ルール内の別の場所にある個別値として再利用することはできません。行の個別値を参照し、他の場所にアクセスする必要がある場合は、2番目の変数を宣言する必要があります。

例3-102 1つのアイテムに対する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- rule variable which references date on AE form.
  • cycleDate1 - 最初のサイクル・ビジットの日付を参照するルール変数。
  • cycleDate2 - 第2サイクル・ビジットの日付を参照するルール変数。
  • cycleCheck1 - 最初のサイクル・ビジットで一部の条件を参照するルール変数。
  • cycleCheck2 - 第2サイクル・ビジットで一部の条件を参照するルール変数。
  • 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
}