[% # set Report link: specimen = specimen_map.item(data.id).sample_code.join(' '); report_link = specimen.match('CMP') AND c.cfg('settings').have_outreach ? 'outreach' : 'report'; %] [% IF # unscreened: NOT has_optional.initial_screen AND c.user_can('screen') %] Screen [% ELSIF report_link == 'outreach' AND ( c.user_can('report') OR c.user_can('edit_outreach_data') ) %] Outreach [% ELSIF # screened but not reported: has_optional.initial_screen AND c.user_can('report') AND NOT history.reported.user %] [% report_link | ucfirst %] [% ELSIF # reported but not authorised (if 'authorise' option active): has_optional.report AND c.user_can('report') AND NOT history.authorised.user AND NOT data.status_option.description.match('complete') AND status_options.authorised.is_active.match('yes') %] Authorise [% ELSIF # reported & authorised but still incomplete: has_optional.report AND c.user_can('report') # AND NOT data.status_option.description.match('complete') AND NOT is_locked %] [% report_link | ucfirst %] [% ELSE %] Report [% END %]