<!-- BEGIN [% component.name %] -->
  [% IF raw_lab_test_data.lab_test_history.size;
	    # INCLUDE dumper.tt dump = raw_lab_test_data.lab_test_history;
      lab_test_history = raw_lab_test_data.lab_test_history %]
    <p class="title">Lab-test history:
	  [% div_name = 'all_lab_tests'; INCLUDE site/snippets/toggleview.tt %]
    </p>

    <div id="[% div_name %]" class="itemhidden">
      <div id="previous-lab-tests" class="indent">
        <table class="results">
		  [% FOREACH test_name IN lab_test_history.keys.sort; # sort on test-name, ignore section
                # INCLUDE dumper.tt dump = test;
                FOREACH section IN lab_test_history.item(test_name);
                    # INCLUDE dumper.tt dump = section;
                    section_name = section.key;   # INCLUDE dumper.tt dump = section_name;
                    test_data 	 = section.value; # INCLUDE dumper.tt dump = test_data;
				%]
                <tr>
                    <td align="right" valign="top">
                        <span class="info">[% test_name %] :: [% section_name %]</span>
                        [[% test_data.size %]]
                    </td>
                    <td>
                        [% FOREACH data IN test_data;
						  # PROCESS dumper.tt dump = data;
						  this_request = ( data.id == request_data.id );
						%]
                            <div>&#[% this_request ? 9898 : 9733 # circle or star %];
							  <span class="mono">
                                [% data.test_date.strftime('%d.%b.%Y') %]							  
								[ [% PROCESS site/lab_number.tt
                                    query_modifiers = [ '_return=1' ]
                                    # only want url if not this request.id:
                                    want_url = ( NOT this_request ) %] ]
							  </span>
                              <span class="warning">[% data.result %]</span>
                            </div>
                        [% END %]
                    </td>
                </tr>
            [% END; END %]
        </table>
      </div>
    </div>

    [% ELSE %]
      <p class="info">No previous lab tests found</p>
    [% END %]

<!-- END [% component.name %] -->
