<!-- BEGIN [% component.name %] -->
  [% IF previous_requests.size;
		BLOCK previous; # INCLUDE dumper.tt dump = data.as_tree(deflate=0);
		  specimens = []; # reset
		  FOREACH rs IN data.request_specimen;
			specimens.push(rs.specimen.sample_code);
		  END;
		%]
          <tr>
            <td class="lab-ref">[% PROCESS site/lab_number.tt
                want_url = 1, query_modifiers = [ '_return=1' ] %]
            </td>
            <td class="mono">[% data.created_at.strftime('%d.%b.%Y') %]</td>
            <td>[% specimens.join(', ') %]</td>
			[% IF data.as_tree.authorised_report.size # none pre-2004 so does db lookup %]
              <td>[% data.authorised_report.diagnosis %]</td>
              <td>[% data.authorised_report.auth_date.strftime('%d.%b.%Y') %]</td>
			[% END %]
          </tr>
	  [% END %]

    <p class="title">Other records
      [[% previous_requests.this_id.size || 0 %] + [% previous_requests.others.size || 0 %]]:
	  [% div_name = 'previous'; INCLUDE site/snippets/toggleview.tt %]
    </p>

    <div id="[% div_name %]" class="itemhidden">
      <div id="previous-requests" class="indent">
        <table class="results">
		  [% FOREACH data IN previous_requests.this_id; INCLUDE previous; END %]
        </table>

        [% IF previous_requests.others.size # possible matches:
			# AND NOT is_outreach # requires NHS number so have unique ID %]
          <p><i>Possible matches</i>:</p>
          <div class="indent">
            <table class="results">
		      [% FOREACH data IN previous_requests.others; INCLUDE previous; END %]
			</table>
          </div>
        [% END %]
      </div>
    </div>

    [% ELSE %]
      <p class="info">No previous patient matches found</p>
    [% END %]
<!-- END [% component.name %] -->
