[% # INCLUDE dumper.tt dump = data.packs; USE today = DateTime(today = 1); # INCLUDE dumper.tt dump = today; USE format; USE year_as_yy = format('%02d'); %]

Your current pack status

[% current = data.packs.first; # INCLUDE dumper.tt name = 'current' dump = current %] [% IF current.request_status.match('complete') %] [% # if pack_due on or after today: IF current.pack_due AND current.pack_due >= today %] Next assessment is due on [% current.pack_due.strftime('%d.%b.%Y') %] [% # if pack_due before today and pack_sent before today: 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 %] [% # pack due before today (not default unknown date) and pack not sent: ELSIF current.pack_due AND current.pack_due.year > 2000 AND NOT current.pack_sent; %] Pack was due for dispatch on [% current.pack_due.strftime('%d.%b.%Y') %] but has not been sent. Please call us to discuss. [% ELSE # ? no pack_due date ? %] Pack dispatch not scheduled: [% IF current.outcome.match('other'); 'see report'; ELSE; current.outcome; END %] [% END %] [% ELSIF current.section_data_count > 1 %] 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. [% ELSIF current.request_status.match('^(new|screened|reported)$') %] A pack was received on [% current.registered.strftime('%d.%b.%Y') %] and laboratory tests have been initiated. [% ELSE # should never get here %] ** UNKNOWN RECORD STATUS ** [% 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); # gives .t error!! String.format('%02d') %][% year_as_yy(entry.year - 2000) %] [% IF entry.option.match('month'); 'next pack '; IF loop.last AND entry.pack_due AND NOT entry.pack_sent; entry.outcome = ' due out ' _ entry.pack_due.strftime('%d.%b.%Y'); ELSIF NOT entry.outcome.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; %]