Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

*** Please note code below is no longer needed.  Use the point-and-click method using the Repeater control Image Added  ***

Data Across Encounters

Displaying a table with one row per encounter

Code that can be entered into a Report Template:

...

Output.Write("<table border='1' cellspacing='0' cellpadding='5'>");
Output.Write("<tr><th>Encounter Date</th> <th>Encounter Name</th></th> <th>Variable 1</th> <th>Variable 2</th> </tr>");

// Loop through the encounters and output the encounter date and encounter name 
   // Each time through will create a row in the table with the next encounter  

for (var index=0; index < ENCOUNTERS.Count; index++) {
     var encounter = ENCOUNTERS.GetEncounter(index);
         var encounterDate = encounter.#EncounterDate.displayValue.toString();
         var encounterName = encounter.#IntervalName.displayValue.toString();
         var variable1value = encounter.#Variable1.value.value;
         var variable2value = encounter.#Variable2.value.value;

   Output.Write("<tr><td>" + encounterDate + "</td>");
   Output.Write("<td>" + encounterName + "</td>");
   Output.Write("<td>" + variable1value + "</td>");
   Output.Write("<td>" + variable2value + "</td></tr>");

}

Output.Write("</table>");

%>

An example of the output from the Report Template code above:

Encounter Date

Encounter Name

Variable 1

Variable 2

10/1/2011

Baseline

128

75

11/5/2011

Month 1

123

60

12/2/2011

Month 2

118

62


Displaying a table with one row per encounter with the encounters sorted in descending order

Code that can be entered into a Report Template:

<%

Output.Write("<table border='1' cellspacing='0' cellpadding='5'>");
Output.Write("<tr><th>Encounter Date</th> <th>Encounter Name</th> <th>Variable 1</th> <th>Variable 2</th> </tr>");

var encountersSorted = ENCOUNTERS.Sort(#EncounterDate.ID, false);

for (var index=0; index < encountersSorted.Count; index++) {

     var encounter = encountersSorted.GetEncounter(index);
         var encounterDate = encounter.#EncounterDate.displayValue.toString();
         var encounterName = encounter.#IntervalName.displayValue.toString();
         var variable1value = encounter.#Variable1.value.value;
         var variable2value = encounter.#Variable2.value.value;

   Output.Write("<tr><td>" + encounterDate + "</td>");
   Output.Write("<td>" + encounterName + "</td>");
   Output.Write("<td>" + variable1value + "</td>");
   Output.Write("<td>" + variable2value + "</td></tr>");

}

Output.Write("</table>");

%>

An example of the output from the Report Template code above:

Encounter Date

Encounter Name

Variable 1

Variable 2

12/2/2011

Month 2

118

62

11/5/2011

Month 1

123

60

10/1/2011

Baseline

128

75


Outputting the data from latest encounter which meets a condition

Code that can be entered into a Report Template:

<%

Output.Write("<table border='1' cellspacing='0' cellpadding='5'>");
Output.Write("<tr><th>Encounter Date</th> <th>Encounter Name</th> <th>Variable 1</th> <th>Variable 2</th> </tr>");

var encountersSorted = ENCOUNTERS.Sort(#EncounterDate.ID, false);

for (var index=0; index < encountersSorted.Count; index++) {

     var encounter = encountersSorted.GetEncounter(index);
         var encounterDate = encounter.#EncounterDate.displayValue.toString();
         var encounterName = encounter.#IntervalName.displayValue.toString();
         var variable1value = encounter.#Variable1.value.value;
         var variable2value = encounter.#Variable2.value.value;

 if (variable1value >= 150) }

   Output.Write("<tr><td>" + encounterDate + "</td>");
   Output.Write("<td>" + encounterName + "</td>");
   Output.Write("<td>" + variable1value + "</td>");
   Output.Write("<td>" + variable2value + "</td></tr>");

  break;

 }

}

Output.Write("</table>");

%>

An example of the output from the Report Template code above:

Encounter Date

Encounter Name

Variable 1

Variable 2

11/5/2011

Month 1

190

60


Displaying data in a custom layout from fixed encounters
 

Code that can be entered into a Report Template:

...

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 the desired layout

Encounter Name

Variable

Encounter Date

Baseline

Variable

Month 1

Variable

Month 2

Baseline

Encounter Date

<%=BaselineEncounter.#EncounterDate%>

<%=

BaselineEncounter

Month1Encounter.

#Variable1%>

#EncounterDate%>

<%=

BaselineEncounter

Month2Encounter.

#Variable2%>

#EncounterDate%>

Month 1

Variable 1

<%=

Month1Encounter

BaselineEncounter.

#EncounterDate%>

#Variable1%>

<%=Month1Encounter.#Variable1%>

<%=

Month1Encounter

Month2Encounter.

#Variable2%>

#Variable1%>

Month 2

Variable 2

<%=

Month2Encounter

BaselineEncounter.

#EncounterDate%>

#Variable2%>

<%=

Month2Encounter

Month1Encounter.

#Variable1%>

#Variable2%>

<%=Month2Encounter.#Variable2%>

%>

An example of the output from the Report Template above:

Encounter Name

Variable

Encounter Date

Baseline

Variable

Month 1

Variable 2

Month 2

Baseline

Encounter Date

10/1/2011

128

75

Month 1

11/5/2011

123

Month 2

60

12/2/2011

Variable 1

128

123

118

Variable 2

75

60

62