...
for (var index=0; index < ENCOUNTERS.Count; index++) {
var encounter = ENCOUNTERS.GetEncounter(index);
var encounterName = encounter.#IntervalName;
if (encounterName =="Baseline") var BaselineIndex=index;
else if (encounterName=="Month 1") var Month1Index=index;
else if (encounterName=="Month 2") var Month2Index=index;
}
// create variables for each encounter and assign all the values from that encounter to the variables
var BaselineEncounter = ENCOUNTERS.GetEncounter(BaselineIndex);
var Month1Encounter = ENCOUNTERS.GetEncounter(Month1Index);
var Month2Encounter = ENCOUNTERS.GetEncounter(Month2Index);