RSS Git Download  Clone
Raw Blame History
<!-- BEGIN [% template.name %] -->
	[% # PROCESS dumper.tt dump = is_locked %]
	[% # PROCESS dumper.tt dump = data.as_tree %]

	[%
        # initialise array for active links:
        all_links = [];
        # either auth not required, or authorised:
		can_view_if_reported = status_options.authorised.is_active.match('no') OR
			( status_options.authorised.is_active.match('yes') AND history.authorised )
		? 1 : 0;
	%]

	[% IF c.user_can('view_history');
        url = app_url _ '/history/=/' _ data.id;
        link = c.html_link(url, 'History');
        all_links.push(link) %]
	[% END %]

	[% IF c.user_can('modify_results'); # AND NOT is_locked # moved to results tmpl
        url = app_url _ '/result/=/' _ data.id;
        link = c.html_link(url, 'Results');
        all_links.push(link) %]
	[% END %]

	[% PROCESS site/report_link_options.tt # Report link - complex options %]

	[% IF c.user_can('log_errors');
		class = request_errors.size ? 'red' : 'normal';
        url = app_url _ '/error/=/' _ data.id;
        link = c.html_link(url, 'Errors', class);
        all_links.push(link) %]
    [% END %]

	[% IF c.user_can('phone_log');
		class = has_phonelog ? 'red' : 'normal';
        url = app_url _ '/phone-log/=/' _ data.id;
        link = c.html_link(url, 'CommsLog', class);
        all_links.push(link) %]
	[% END %]

	[% IF c.user_can('view_history');
        url = app_url _ '/image/=/' _ data.id;
        link = c.html_link(url, 'DataFiles');
        all_links.push(link) %]
	[% END %]

    [% IF c.cfg('settings').xtr_96_addr AND  c.user_can(['view_storage', 'modify_results']);
        url = app_url _ '/storage/=/' _ data.id;
        link = c.html_link(url, 'Storage');
        all_links.push(link) %]
    [% END %]

	[% IF c.user_can(['view_clinical_data','edit_clinical_data'])
			AND clinical_data_link.is_elegible;
		class = clinical_data_link.has_data ? 'red' : 'normal';
        url = app_url _ '/hmrn_data/=/' _ data.id;
        link = c.html_link(url, 'HMRN', class);
        all_links.push(link) %]
	[% END %]

	[% IF c.user_can('print_one');
        link = ''; # reset - may not get a value:

        IF report_link.match('outreach') AND c.user_can('report'); # allowed interim report
            url = app_url _ '/request/print_record/' _ data.id;
            link = can_view_if_reported
                ? c.html_link(url, 'Print')
                : c.html_link(url, 'Interim'); # allowed to print incomplete report
        ELSIF has_optional.report; # must be reported
            IF can_view_if_reported;
                url = app_url _ '/request/print_record/' _ data.id;
                link = c.html_link(url, 'Print');
            ELSIF c.user_can('report'); # reported but not authorised:
                url = app_url _ '/request/print_draft/' _ data.id;
                link = c.html_link(url, 'Draft');
            END;
        END;
        all_links.push(link) IF link; %]
	[% END %]

	[% IF c.user_can('email_report') AND (
            ( has_optional.report AND can_view_if_reported ) OR
            ( report_link.match('outreach') AND c.user_can('report') )
        );
        url = app_url _ '/request/email_report/' _ data.id;
        link = c.html_link(url, 'Email');
        all_links.push(link) %]
	[% END %]

<p id="navbar">
	[% IF c.query.param('_return'); site.html.back_button; END %]

    [% IF c.is_lab_staff %]
        <i>Record status:</i>
		[% IF is_locked;
            IF c.has_unlock_permission;
                url = app_url _ '/request/unlock_request/' _ data.id;
                title = '<img class="href" src="/images/locked.png" alt=""
					title="unlock record" />';
                c.html_link(url, title);
            ELSE;
                '<img src="/images/locked.png" alt="" />';
            END;
        ELSE;
            '<img src="/images/unlocked.png" alt="" />';
        END %]

		[% UNLESS data.status_option.description.match('complete');
			USE date = DateTime(today = 1);
			delta = data.created_at.delta_days(date).delta_days; # INCLUDE dumper.tt dump = delta;
			IF delta; # don't show zero
				IF delta > 5;    class = 'highlight';
				ELSIF delta > 2; class = 'warning';
				ELSE;            class = 'info';
				END;
		%]
		  <span class="[% class %]" title="days post-registration">
			[% delta %]</span>
		[% END; END %]
    [% END %]

    [% all_links.join(' :: ') %]
</p>
<!-- END [% template.name %] -->