© 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

Version 1 Current »

Summary

This edit check ensures that if the end of study ‘Reason for Completion or Termination’ item value is “ADVERSE EVENT”, then an adverse event form must exist for the subject of interest and the item value for the ‘Treatment Action’ item within an adverse event form must be “Drug Withdrawn”

Formal Expression

// Constants for hardcoded strings
var ADV_REASON_STRING = 'ADVERSE EVENT';
var STUDY_EVENT_NAME = 'AE / CM';
var FORM_NAME = 'AE / CM';
var AE_TREATMENT_ACTION_ITEM = 'AE_TREATMENT_ACTION';
var DRUG_WITHDRAWN_VALUE = 'Drug Withdrawn';

// Fetch the current reason value
var reason = itemJson.item.value;
logger('reason: ' + reason);

// If reason is not ADVERSE EVENT (case insensitive), log and return true
if (reason.toLowerCase() !== ADV_REASON_STRING.toLowerCase()) {
    logger('The reason is not an ADVERSE EVENT.');
    return true;
}

// Otherwise, perform lookup using findFormData
var aeForms = findFormData(STUDY_EVENT_NAME, FORM_NAME);
logger('Number of AE / CM forms found: ' + aeForms.length);

// Initialize flag to check for 'Drug Withdrawn'
var drugWithdrawnFound = false;

// Iterate over each form and check AE_TREATMENT_ACTION value
for (var i = 0; i < aeForms.length; i++) {
    var form = aeForms[i];
    var treatmentActionItem = findFirstItemByName(form, AE_TREATMENT_ACTION_ITEM);
    
    if (treatmentActionItem && treatmentActionItem.value) {
        logger('AE_TREATMENT_ACTION value in form ' + (i + 1) + ': ' + treatmentActionItem.value);
        
        // Check if the value is 'Drug Withdrawn' (case insensitive)
        if (treatmentActionItem.value.toLowerCase() === DRUG_WITHDRAWN_VALUE.toLowerCase()) {
            drugWithdrawnFound = true;
            break; // No need to continue, we found a match
        }
    } else {
        logger('AE_TREATMENT_ACTION not found or has no value in form ' + (i + 1));
    }
}

// If 'Drug Withdrawn' is found, return true
if (drugWithdrawnFound) {
    return true;
}

// If no 'Drug Withdrawn' is found, return false with an error message
customErrorMessage('No AE_TREATMENT_ACTION item with the value "Drug Withdrawn" was found.');
return false;

  • No labels