getValues( )

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

ノート:

これは集計関数です。ターゲットが繰返しフォーム上にある場合、ルールは各フォーム・インスタンスに対して実行されます。

2項形式で使用する場合、GetCurrentRFInstance( )を使用して、現在の2項フォームインスタンスでのみ実行するようにルールを制限できます。

構文

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

パラメータ

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

戻り値

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

また、この関数のコール時に、getten値を使用してルール変数が再定義されます。

ノート:

この変数に関連するデータ要素がない場合、ルール変数はnullに再定義されます。このため、データの処理に使用する前に、変数に配列要素が含まれているかどうかを常に検証する必要があります。
  • var1、 var2、 ... - パラメータとして渡される各変数は、結果を持つ配列を保持します。配列内の各項目(var1[0]など)には、次のものが含まれます。
    • var1[0].visitName - 訪問の名前
    • var1[0].deleted - 繰返しフォーム・インスタンスが削除された場合、true
    • var1[0].tableRowInstance - 表内にある場合の繰返し表の行インスタンス
    • var1[0].branchName - ブランチの名前
    • var1[0].eventType - 訪問のタイプ- ScheduleAbleVisit、UnScheduleAbleVisit、イベントなど
    • var1[0].formRepeatNumber - ケース・フォームの繰返しフォーム・インスタンス番号は繰返しフォームです
    • var1[0].value - データ要素値、または値がクリアされた場合はnull
    • var1[0].cycleNumber - サイクルの場合の訪問のサイクル番号
    • var1[0].empty - 値がクリアされたか、繰返しフォームに入力されなかった場合はtrue
    • var1[0].treatmentArm - トリートメントアーム
  • 日付要素:
    • 変数が完全な日付の場合、返される変数値はDateオブジェクトです。
    • 変数が部分的な日付の場合、返される変数値は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( )を使用して解析できます。

使用方法のヒント

- 任意の訪問-に定義された変数を操作している場合は、このヘルパー関数を使用して値を取得し、式で使用する必要があります。ロジックで変数を直接操作することはできません。次の形式を使用します。'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
}