© 2024 IQVIA - All Rights Reserved

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Summary

This method retrieves a value from another collected form in the same study event. It filters the forms returned to find only Complete data.

INSERT VIDEO HERE

Formal Expression

// set the name of the item which contains the desired value
var DATE_OF_VISIT_ITEM_NAME = 'SV_DATE'
var studyEventName = formJson.form.studyEventName;
logger('studyEventName '+studyEventName);
var allVisitData = findFormData(studyEventName,'Date of Visit');
var completedVisitData = collectCompleted(allVisitData);

var visitDataForm = null
if (completedVisitData.length == 0) {
    logger('no completedVisitData found');
} else if (completedVisitData.length == 1) {
    visitDataForm = completedVisitData[0];
} else if (completedVisitData.length > 1) {
    logger('multiple values of completedVisitData found.  Picking the first');
    visitDataForm = completedVisitData[0];
}

var value = null;
if (visitDataForm != null) {
    value = findFirstItemValueByName(visitDataForm, DATE_OF_VISIT_ITEM_NAME);
}
return value;

function collectCompleted(formDataArray) {
    if (formDataArray == null) { return []; }
    var keepers = [];
    for (var i = formDataArray.length - 1; i >= 0; i--) {
        var formData = formDataArray[i];
        if (formData.form.canceled == false && formData.form.itemGroups[0].canceled == false && (formData.form.dataCollectionStatus == 'Complete'
        )) {
            keepers.push(formData);
        }
    }
    return keepers;
}

  • No labels