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

« Previous Version 8 Next »

Overview

In terms of functionality, anything that is available in the JavaScript programming language is available for use in Subject Reports. Thus, there is considerable power that can be leveraged by Subject Reports (e.g., automated clinic note generator).

How It's Done

Referencing Variables
To reference a variable value use: <%= #VariableCode %>

If the variable is categorical (e.g., picklist), adding .Name will insert the label associated with the numeric value: <%=#VariableCode.Name %>

If Statement

The if statement is helpful when you only want text to appear under specific conditions

 

<% indicates begin JavaScript and %> indicates end JavaScript

<% if (#VariableCode == 0) %>Text if true <% else %>Text if false

An alternate way of writing the same code is to keep the entire statement in JavaScript

<% if (#VariableCode==0) Output.Write("Text if true");

      else Output.Write("Text if false"):

%> 

You can also reference other variable values within the if statement

<% if (#VariableCode == 0) { %> <% =#VariableCode2 %> <% }else { %>Text if false <% }%>

Example Basic Report


Patient Name: <%= #FirstName %> <%=#LastName %>
MRN: <%= #ReferenceId %>
Sex: <%= #sex.Name %>
Dob: <%= #birth %>
Age: <%= ageAsOf(#birth, #EncounterDate) %>
Race: <%= #race.Name %>

Referral Reason:
<%= #FName %> <%= #LName %> is a <%= ageAsOf(#birth, #EncounterDate) %> year old active
<%= #sex.Name %> outpatient <%= #height %> inches tall, weighing <%= #weight %> lbs, who underwent neuropsychological testing on <%= #EncounterDate %> for assessment of Attention Deficit Disorder......

Test Results

Test 1
Section A subscore <%= #section_a_subscore %>
Section B subscore <%= #section_b_subscore %>
Section C subscore <%= #section_c_subscore %>


Where To Place The Code

Typically code blocks (begin and end with <% and %>, respectively) are best placed at the top of the report like this:


<%

var srgiResult;
var beckResult;

if (#cgi_s_sr==1) srgiResult="Normal; not at all ill";
else if (#cgi_s_sr==2) srgiResult="Borderline mentally ill";
else if (#cgi_s_sr==3) srgiResult="Mildly ill";
else if (#cgi_s_sr==4) srgiResult="Moderately ill";
else if (#cgi_s_sr==5) srgiResult="Markedly ill";
if (#bditot>=0 && #bditot<=13) beckResult="Minimal depression";
else if (#bditot<=19) beckResult="Mild depression";
else if (#bditot<=28) beckResult="Moderate depression";
else if (#bditot<=63) beckResult="Severe depression";

var Tcog1 = 0;
var Tcog2 = 0;
var Zcog1 = 0;
var Zcog2 = 0;

Tcog1 = (#cog1) / 2;
Tcog1 = Math.round(Tcog1*100) / 100;
Tcog2 = (#cog2) / 2;
Tcog2 = Math.round(Tcog2*100) / 100;

Zcog1 = (Tcog1 - 50) / 10;
Zcog1 = Math.round(Zcog1*100) / 100;
Zcog2 = (Tcog2 - 50) / 10;
Zcog2 = Math.round(Zcog2*100) / 100;

%>

Patient Name: <%= #FirstName %> <%= #LastName %>
<% Tcog1 %>


Referencing More Than One Encounter

You can display data values from more than one variable by using the ENCOUNTERS method as in the example below which generates a table with values from multiple encounters


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

for (var index=0; index < ENCOUNTERS.Count; index++) {
   var encounter = ENCOUNTERS.GetEncounter(index);
   var encounterName = encounter.#IntervalName;
   var encounterDate = encounter.#EncounterDate;
   var encounterScore1 = encounter.#score1;  
   var encounterScore2 = encounter.#score2;
   var encounterScore3 = encounter.#score3;
   var encounterScore4 = encounter.#score4;
   Output.Write("<tr><td>" + encounterName + "</td>");
   Output.Write("<td>" + encounterDate + "</td>");
   Output.Write("<td>" + encounterScore1 + "</td>");
   Output.Write("<td>" + encounterScore2 + "</td>");
   Output.Write("<td>" + encounterScore3 + "</td>");
   Output.Write("<td>" + encounterScore4 + "</td></tr>");
}
Output.Write("</table>");
%>

  • No labels