Summary
This method compares a current value against a baseline value and returns the percentage increase or decrease. The item values being compared can exist on different forms scheduled against different study events.
Formal Expression
The following variables may need to be updated based on specific study design naming conventions…
BASELINE_STUDY_EVENT
BASELINE_FORM
BASELINE_ITEM_NAME
THIS_ITEM_NAME
//calculates percent increase or decrease compared to BASELINE_STUDY_EVENT //adjust the first four variables var BASELINE_STUDY_EVENT = 'Screening'; //study event name associated with the baseline form var BASELINE_FORM = "Baseline Form"; //baseline form name var BASE_ITEM_NAME = 'AverageSys'; //baseline item name to be compared var THIS_ITEM_NAME = 'AverageSys'; //the name of the current item var ret = null; var baseForms = findFormData(BASELINE_STUDY_EVENT, BASELINE_FORM); //find the baseline form if (baseForms !== null && baseForms.length === 1) { //if the form exists perform the following var baselineSum = findFirstItemValueByName(baseForms[0], BASE_ITEM_NAME); //find the baseline item value var thisFormSum = findFirstItemValueByName(formJson, THIS_ITEM_NAME); //find the value of the current item if (!isNaN(baselineSum) && !isNaN(thisFormSum)) { //ensure neither value is null ret = Math.round(((Number(thisFormSum) - Number(baselineSum)) / Number(baselineSum))*100); //perform the calculation... ((current - baseline)/baseline)*100 } } return ret;