<!-- BEGIN outreach/data_summary.tt -->
<table>
<tr>
<th>Parameter</th>
[% FOREACH entry IN vals.datasets %]
<th>[% entry.date %]</th>
[% END %]
<th>Reference</th>
<th>Units</th>
</tr>
[% FOREACH field IN vals.reported_fields %][% # field %]
<tr>
<td class="header">[% field.replace('_', ' ') FILTER ucfirst %]:</td>
[% # field = field | lower # now lowercase field to match vals hashref %]
[% FOREACH entry IN vals.datasets %]
[% SET result = entry.$field ; SET default = ranges.$field.default %]
[% IF field.match('electrophoresis') && result.match('Isotype undetermined'); result = ''; END %]
[% IF result && default != '' && ( 10 * result ) == ( 10 * default) # if default value %]
[% IF field.match('Ig'); result = '' %]
[% ELSIF field.match('paraprotein') %]
[% IF entry.electrophoresis.match('Ig'); result = 'Unquantifiable' %]
[% ELSIF entry.electrophoresis.match('No paraprotein'); result = '' %]
[% ELSE; result = 'N/K'; END %]
[% ELSE; result = 'N/K'; END # 9.9 != 9.90, etc %]
[% END %]
[% # IF result.match('<') OR result.match('N/K') OR ! result; class = 'center' %]
[% SET class = 'center' # reset to default %]
[% IF is_num(result) # no maths funcs unless numerical: %]
[% IF ranges.item(field).flag_lower && result < ranges.item(field).flag_lower;
class = 'highlight' %]
[% ELSIF ranges.item(field).flag_higher && result > ranges.item(field).flag_higher;
class = 'highlight' %]
[% END %]
[% END %]
<td class="$class">[% # remove_me_to_test field ':' %]
[% result | html %]
</td>
[% END %]
[% IF ranges.$field.units %]
<td align="center">[% ranges.$field.lower_range %] - [% ranges.$field.upper_range %]</td>
<td>[% ranges.$field.units.replace('10/9', '10<sup>9</sup>') %]</td>
[% ELSE %]
<td colspan="2"> </td>
[% END %]
</tr>
[% END %]
[% # FOREACH field IN vals.calculated_fields # done manually now: %]
[% # END %]
<tr>
<td class="header">Swelling:</td>
[% FOREACH entry IN vals.datasets; DEFAULT entry.adenopathy = 'none' %]
<td align="center">
[% entry.adenopathy.replace('_\w+', '') # _(swelling|pain) %]
</td>
[% END %]
<td colspan="2"> </td>
</tr>
<tr>
<td class="header">Bone pain:</td>
[% FOREACH entry IN vals.datasets %]
<td align="center">
[% IF ! entry.bone_pain.total_count %]
[% entry.bone_pain.skip ? ' ' : 'none' # leave blank if no entry in bone pain table %]
[% ELSIF entry.bone_pain.total_count > 2 # generalised %]
[% SET class = entry.bone_pain.severe ? 'red' : 'normal' %]
<span class="$class">generalised</span>
[% ELSE # 1 or 2 entries %]
[% IF entry.bone_pain.severe %]
[% FOREACH pain IN entry.bone_pain.severe %]
<span class="red">[% pain.replace('_\w+', '') %]</span>
[% END %]
[% END %]
[% IF entry.bone_pain.moderate %]
[% FOREACH pain IN entry.bone_pain.moderate %]
[% pain.replace('_\w+', '') %]
[% END %]
[% END %]
[% END %]
</td>
[% END %]
<td colspan="2"> </td>
</tr>
</table>
<!-- END outreach/data_summary.tt -->