Text Template Renderer Groovy

Adding different types of data

In order to add

Define this data

Give it a column label (eg)

And add it to your template like this

In order to add

Define this data

Give it a column label (eg)

And add it to your template like this

Full Name

Preferred Name

patientName

<b>Full Name:</b> $data.patientName

Full Name (Last, First)

Preferred Name

patientName

<b>Name:</b> $data.patientName.familyName, $data.patientName.givenName

Age (years)

Age

age

<b>Age:</b> $data.age years old

Age (years and months)

Age

age

<b>Age:</b> $data.age.fullYears years $data.age.fullMonthsSinceLastBirthday months old

Birthdate

Birthdate

birthdate

<b>Birthdate:</b> <%= util.format(data.birthdate, "dd/MMM/yyyy") %>

Gender

Gender

gender

<b>Gender:</b>
<%= msg.translate(data.gender == "M" ? "Patient.gender.male" : "Patient.gender.female") %>

Address

Preferred Address

address

<b>Address:</b> $data.address.address1, $data.address.cityVillage

First Encounter of Type(s)

Encounters For Patient

firstXyzEncounter

First XYZ Encounter occurred
on ${util.format(data.firstScheduledVisit.encounterDatetime, "dd/MMM/yyyy")} at $data.firstScheduledVisit.location.name

Most Recent Weight

Obs For Person

lastWeight

Most recent weight:
$data.lastWeight.valueNumeric (${util.format(data.lastWeight.obsDatetime, "dd/MMM/yyyy")})

Obs Active List

 

obs

Active observations:
<ol>
<% activeItems = util.sort(data.obs.activeItems, "obsDatetime desc")
for(item in activeItems) {
%>
<li>$item.valueCoded.name <small><i>${util.format(item.obsDatetime, "dd-MMM-yyyy")}</i></small></li>
<% } %>
</ol>

Three Most Recent Weights

Obs For Person

weights

<%     
    obsList = data.weights
    obsList = util.sort(obsList, "obsDatetime desc")
    count = 0
    for (obs in obsList) {
        if (++count > 3) {
            break
        }
        println obs.valueNumeric  + '  (' + util.format(obs.obsDatetime, 'dd/MMM/yyyy') + ')'
    }
%>