[% # INCLUDE dumper.tt dump = data.packs; USE today = DateTime(today = 1); # INCLUDE dumper.tt dump = today; %]

Your current status

[% current = data.packs.first; # INCLUDE dumper.tt dump = current %] [% IF current.request_status.match('complete'); # manipulate some dates to ensure always part or future: IF user.nhs_number.match(1111111111); # force pack_due to future current.pack_due = today.clone.add(days = 2); END; IF user.nhs_number.match(5555555555); # ensure always within past 2-3 days: # current.pack_sent = today.clone.subtract(days = 3); # gives: # "Reference found where even-sized list expected" current.pack_sent = today.clone.add(days = -3); # avoids above error END; # INCLUDE dumper.tt dump = current.pack_sent name = 'post'; %] [% IF current.pack_due AND current.pack_due >= today %] Next assessment is due on [% current.pack_due.strftime('%d.%b.%Y') %] [% ELSIF current.pack_sent AND current.pack_sent < today; # INCLUDE dumper.tt dump = current.pack_sent name = 'pre'; delta_pack_sent = current.pack_sent.delta_days(today).delta_days; class = delta_pack_sent > 7 ? 'danger' : 'success'; # INCLUDE dumper.tt dump = delta_pack_sent; %] A pack was sent on [% current.pack_sent.strftime('%d.%b.%Y') %] [[% delta_pack_sent %] days ago] [% IF class.match('danger') %] but has not been received. Please call us to discuss.[% END %] [% ELSE %] [% current.outcome %] [% END %] [% ELSIF current.request_status.match('new') %] A pack was received on [% current.registered.strftime('%d.%b.%Y') %] and laboratory tests have been initiated. [% ELSIF current.request_status.match('screened') %] A pack was received on [% current.registered.strftime('%d.%b.%Y') %] and initial results indicate that no urgent action is required. It may take three weeks to obtain all the laboratory test results but we will contact your GP if there are any issues. [% ELSE %]** current request status is not complete ** [% END %]
[% FOREACH entry IN data.packs.reverse; # because data collected in reverse order NEXT IF entry.option.match('dead'); # oops %] [% END %]
Pack Received Lab number Action Pack sent
#[% loop.count %] [% entry.registered.strftime('%d.%b.%Y') %] [% entry.request_number %]/[% use String(entry.year - 2000); String.format('%02d') %] [% IF entry.option.match('month'); 'next pack '; UNLESS entry.label.match('immediate'); 'in '; END; END; entry.outcome; %] [% # INCLUDE dumper.tt name = loop.count dump = entry.pack_due >= date; IF entry.option.match('clinic_return'); '[not required]'; ELSIF entry.pack_due AND entry.pack_due >= today; '[ due '; entry.pack_due.strftime('%d.%b.%Y'); ' ]'; ELSIF entry.pack_sent; entry.pack_sent.strftime('%d.%b.%Y'); END; %]