getValues( )

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

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

構文

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

パラメータ

パラメータ 必須/オプション 説明
'var1', 'var2', ... 1つ以上の値を指定する必要があります。 取得するビジット、フォームまたはアイテムを定義するルール変数名。

戻り値

成功した場合は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単一アイテムに対する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 - 第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
}