[% META title = 'Resources &raquo; Stats &amp; Audit &raquo; Turnaround times by specimen' %]

<!-- BEGIN [% template.name %] -->
    [% # PROCESS dumper.tt dump = data %]

    <h2>Non-trial request turnaround times (95 percentile) by specimen:</h2>

    [% PROCESS site/date_constraints.tt
        func_name = 'get_page'
        target_url = app_url _ '/audit/turnaround/percentile'
        restricted = { # too slow to allow these:
            no_constraint = 1,
            all_since     = 1,
        }
    %]

    <p class="indent title">[% title | upper %]</p>

    [% IF data.size %]
    <table class="indent">
        <caption></caption>
        <tr>
            <th>Specimen</th>
            <th><div>Total</div><div>Reported</div></td>
            <th colspan="2">
                <div>
                    <span class='acronym'
                          title='time from registration, in number of week days'>
                        Delta days (95%):
                    </span>
                </div>
                <div>Report | Auth'n</div>
            </th>
            <th>
                <span class='acronym' title='report to authorisation difference'>
                    R &#187; A</span>
            </th>
            <td class="borderless"></td>
        </tr>

        [%
            FOREACH entry IN data; # PROCESS dumper.tt dump = entry;
                specimen = entry.key;
                count = entry.value.count;
                delta_report = entry.value.delta_report;
                delta_auth = entry.value.delta_authorise;
       %]
        <tr class="[% count < 20 ? 'grey' : 'normal' %]">
            <td align="right">
                <a href="[%
                    c.query.self_url.replace(
                        'turnaround/percentile',
                        "turnaround_chart/${specimen}"
                    ) %]">[% specimen %]</a>
            </td>
            <td align="center">[% count %]</td>
            <td align="center">[% delta_report OR site.html.grey_null %]</td>
            <td align="center">[% delta_auth OR site.html.grey_null %]</td>
            <td>[% IF delta_auth AND delta_report;
                '+'; delta_auth - delta_report; ELSE; site.html.grey_null; END %]
            </td>
            <td class="borderless">
                [% IF c.user_can('report') %]
                <a href="[%
                    c.query.self_url.replace(
                        'turnaround/percentile',
                        "turnaround_data/${specimen}"
                    ) %]" class="image"><img src="/images/table-icon.png" /></a>
                [% END %]
            </td>
        </tr>
        [% END %]
    </table>
    [% ELSE %]
        <p class="info indent">no data for time period specified</p>
    [% END %]

    <p class="indent">[% site.html.back_button %]</p>
<!-- END [% template.name %] -->
