<!-- BEGIN [% component.name %] -->
  [% # PROCESS dumper.tt dump = section_result_lab_tests.item(section) %]
  [% # PROCESS dumper.tt dump = completed_lab_tests %]
  [% # PROCESS dumper.tt dump = this_section %]

  <p class="indent"><span class="title">Single tests:</span></p>

  [% # get list of tests:
    tests = [ ];
    FOREACH test IN this_section.test; # PROCESS dumper.tt dump = test;
      tests.push(test.key);
      END;
    sorted_tests = natural_sort(tests); # PROCESS dumper.tt dump = sorted_tests;
  %]

    <div class="indent">
      <table class="results">
        <tr>
          [% count = 1 %]

        [% FOREACH test_name IN sorted_tests;
            test_data = this_section.test.item(test_name);
              # PROCESS dumper.tt dump = test_data;
            # NEXT IF test_data.result; # already has result on test of same name - moved below
            NEXT UNLESS test_data.is_active.match('yes');
            # get td background 'color' (expects 'test_data'):
            PROCESS result/colour.tt
        %]

          <td align="right" width="170">
            <span style="color: [% clr %]; background: [% bgclr %]; padding: 2px">
            [% IF test_data.status; user = test_data.user; %]
              <span class="acronym" title="[% user.first_name _ ' ' _ user.last_name %]">
                [% test_name | html %]
              </span>
              [% ELSE %]
                [% test_name | html %]
              [% END %]
            </span>
          </td>

          <td style="width: 35px">
            [% IF is_locked %]
                <img src="/images/checkbox.png" title="locked" />
            [% ELSIF test_data.result %]
                <span title="test result present, delete before re-requesting"
                        class="acronym" style="margin-left: 6px">
                    <i style="vertical-align: text-top" class="fa fa-ban"></i>
                </span>
            [% ELSE %]
                <input type="checkbox" name="test_id" value="[% test_data.id %]" />
                [% IF c.user_can('modify_results') AND test_data.status
					AND NOT test_data.status.match('complete');
                  USE url(
                    app_url _ '/worklist/display/' _ this_section.id,
                    lab_test_id = test_data.id,
                    request_id = data.id,
                    display_format = "Data Entry");
                %]
                  <a href="[% url %]" title="data entry worklist">
                    <i style="vertical-align: text-top" class="fa fa-plus-square"></i>
                  </a>
                [% END %]
            [% END %]
          </td>
          [% UNLESS loop.last OR # don't start new table unless multiple of 6:
            ( this_section.test.size > 4 AND count % 4 ) %]
            </tr>
          </table>
          <table class="results">
            <tr>
          [% END %]
          [% count = count + 1 %]
        [% END %]
        [% '<td></td>' IF count == 1 # or get invalid html %]
        </tr>
      </table>
    </div>
<!-- END [% component.name %] -->
