[% META title = 'Resources &raquo; Stats &amp; Audit &raquo; Turnaround times for lab tests' %]

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

    <h2>Lab test turnaround times [[% title %]]:</h2>

    [% PROCESS site/date_constraints.tt
        func_name = 'get_page'
        target_url = app_url _ '/audit/turnaround/lab_test'
        query_args = 'order_by=' _ c.query.param('order_by');

        tooltip = 'time from lab-test request to completion, in number of week days';
        USE math = format('%.1f');
        i = 0;
    %]

    [% FOREACH section IN data.keys.sort;
        tests = data.item(section);
        NEXT UNLESS tests.size;
        i = i + 1;
    %]
        <h3>[% i %]) [% section %]</h3>

        <table class="indent">
            <tr>
                <th>Test name</th>
                <th>Total</th>
                <th>
                    <span class='acronym' title='[% tooltip %]'>delta</span>
                </th>
            </tr>
            [% FOREACH test IN tests.keys.sort;
                result = tests.item(test);
                delta = result.delta_days / result.count;
            %]
                <tr>
                    <td align="right">[% test %]</td>
                    <td>[% result.count %]</td>
                    <td align="center">[% math(delta) %]</td>
                </tr>
            [% END %]
        </table>
    [% END %]
    [% IF NOT data.size %]
        <p class="info indent">no data for time period specified</p>
    [% END %]

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