Variables in Rows

Displaying data in a custom layout from fixed encounters

 

Code that can be entered into a Report Template:

<%
// Declare variables that will track the interval's index number
   var BaselineIndex="";
   var Month1Index="";
   var Month2Index="";

// Loop through all encounters to assign the interval's index number

for (var index=0; index < ENCOUNTERS.Count; index++) {
  var encounter = ENCOUNTERS.GetEncounter(index);
  var encounterName = encounter.#IntervalName.displayValue.toString();
      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);

// Create the desired layout

Variable

Baseline

Month 1

Month 2

Encounter Date

<%=BaselineEncounter.#EncounterDate%>

<%=Month1Encounter.#EncounterDate%>

<%=Month2Encounter.#EncounterDate%>

Variable 1

<%=BaselineEncounter.#Variable1%>

<%=Month1Encounter.#Variable1%>

<%=Month2Encounter.#Variable1%>

Variable 2

<%=BaselineEncounter.#Variable2%>

<%=Month1Encounter.#Variable2%>

<%=Month2Encounter.#Variable2%>



An example of the output from the Report Template above:

Variable

Baseline

Month 1

Month 2

Encounter Date

10/1/2011

11/5/2011

12/2/2011

Variable 1

128

123

118

Variable 2

75

60

62