RSS Git Download  Clone
Raw Blame History
<!-- BEGIN [% component.name %] -->
    [% # set Report link:
        screen   = data.request_initial_screen.screen.description;
        specimen = specimen_map.item(data.id).sample_code.join(' ');
        # CMP needs to be screened as outreach or expected data structures not loaded:
        report_link = specimen.match('CMP') AND screen.lower.match('outreach')
            AND c.cfg('settings').have_outreach ? 'outreach' : 'report';
    %]

    [%
        IF # unscreened:
            NOT has_optional.initial_screen
            AND c.user_can('screen');
                url = app_url _ '/screen/=/' _ data.id;
                link = c.html_link(url, 'Screen');
                all_links.push(link);

        ELSIF # outreach case & user can report or edit outreach:
            report_link.match('outreach')
            AND ( c.user_can('report')
                OR c.user_can([ 'view_outreach_data', 'edit_outreach_data' ]) );
                url = app_url _ '/report/outreach/' _ data.id;
                link = c.html_link(url, 'Outreach');
                all_links.push(link);

        ELSIF # screened but not reported:
            has_optional.initial_screen
            AND c.user_can('report')
            AND NOT history.reported.user;
                url = app_url _ '/' _ report_link _ '/=/' _ data.id;
                title = report_link | ucfirst;
                link = c.html_link(url, title);
                all_links.push(link);

        ELSIF # reported but not authorised (if 'authorise' option active):
            has_optional.report
            AND c.user_can('report')
            AND status_options.authorised.is_active.match('yes')
            AND NOT history.authorised.user
            AND NOT data.status_option.description.match('complete');
                IF history.reported.user.username == c.authen.username;
                    url = app_url _ '/report/=/' _ data.id;
                    link = c.html_link(url, 'Report'); # allow edit own report
                ELSE;
                    url = app_url _ '/report/authorise/' _ data.id;
                    link = c.html_link(url, 'Authorise');
                END;
                all_links.push(link);

        ELSIF # reported & authorised (if in use) but still incomplete:
            has_optional.report
            AND c.user_can('report')
            AND ( history.authorised.user # in case authorisation disabled:
                OR status_options.authorised.is_active.match('no') )
            # AND NOT data.status_option.description.match('complete')
            AND NOT is_locked;
                url = app_url _ '/' _ report_link _ '/=/' _ data.id;
                title = report_link | ucfirst;
                link = c.html_link(url, title);
                all_links.push(link);

        ELSE;
            # all_links.push('Report'); # don't really need it
        END;
    %]
<!-- END [% component.name %] -->