[% i = 0;
FOREACH data IN requests; # PROCESS dumper.tt dump = data.as_tree;
patient = data.patient_case.patient;
report = data.as_tree.request_report; # as_tree to prevent tt lookup if empty
# want to split specimens into new line for each:
specimens = specimen_map.item(data.id).sample_code; # PROCESS dumper.tt dump = specimens;
# force CHIM's to 3 lines:
IF specimens.join.match('CHIM'); # is, or contains 'CHIM'
specimens.push('CHIM','CHIM'); END; # PROCESS dumper.tt dump = specimens;
FOREACH specimen IN specimens; # only show requested specimens:
NEXT UNLESS request_specimen_map.item(data.id).${specimen};
%]