RSS Git Download  Clone
Raw Blame History
[% # INCLUDE dumper.tt dump = data.packs;
    USE today = DateTime(today = 1); # INCLUDE dumper.tt dump = today;
%]
	
<div class="panel panel-info">
  <div class="panel-heading">
	<h4 class="panel-title">Your current status</h4>
  </div>
  <div class="panel-body">
        [% 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 %]
              <span class="text-success">
                Next assessment is due on [% current.pack_due.strftime('%d.%b.%Y') %]
              </span>
            [% 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; %]
              <span class="text-[% class %]">
                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 %]
              </span>
            [% ELSE %]
              <span class="text-success">
                [% current.outcome.ucfirst %]
                <!-- current request status complete but pack_due not &ge; today
                and pack_sent not %lt; today -->
              </span>
            [% END %]
        [% ELSIF current.request_status.match('new') %]
          <span class="text-success">
            A pack was received on [% current.registered.strftime('%d.%b.%Y') %] and
            laboratory tests have been initiated.
          </span>
        [% ELSIF current.request_status.match('screened') %]
          <span class="text-success">
            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.
          </span>
        [% ELSE %]** current request status is not complete **
        [% END %]
  </div>
</div>