[%
  # META title = '' # using my.meta_title to allow processing dynamic vars:
  status_query = c.query.param('status_query') | ucfirst;
  my.meta_title = "Worklist &raquo; Request Status &raquo; ${status_query}"
-%]
    
<!-- BEGIN [% template.name %] -->	
    [% # PROCESS dumper.tt dump = request_options_map %]
    
    [% status_query = c.query.param('status_query') %]
    
  <h3>Request status - [% status_query %] cases [[% requests.size %]]</h3>

  <div class="indent">
    <table>
      <tr>
        <td></td>
        <th>Lab No</th>
        <th>Name</th>
        <th>Date</th>
        <th>Sample</th>
        <th>Source</th>
        [% UNLESS status_query == 'unscreened' %]
            <th>Presentation</th>
        [% END %]
		<th>Delta</th>
      </tr>
      
      [% FOREACH data IN requests %] [% # PROCESS dumper.tt dump = entry.request %]
        [% patient = data.patient_case.patient %]        
      <tr>
        <td>[% loop.count %]</td>
        <td>
          [% PROCESS site/lab_number.tt want_url = 1; # expects request object 'data' %]
        </td>
        [% class = request_options_map.item(data.id).urgent ? 'red' : 'normal' %]
        <td class="[% class %]">
          [% patient.last_name | upper %],
          [% format_firstname(patient) || patient.first_name | ucfirst %]
          [% patient.middle_name | ucfirst %]
        </td>
		<td>[% data.created_at.strftime('%a %d.%b.%Y') %]</td>
		[% class = request_options_map.item(data.id).doi ? 'red' : 'normal' %]
        <td class="[% class %]">
		  [% specimen_map.item(data.id).sample_code.join(', ') %]
		</td>
		<td>
		    [% SET location = data.patient_case.referral_source.display_name %]
            [% PROCESS site/display_name.tt %]
		</td>
        [% UNLESS status_query == 'unscreened' %]
        <td>
		  [% IF data.request_initial_screen;
			  data.request_initial_screen.screen.description;
			ELSE; site.html.grey_null; END; %]
		</td>
        [% END %]
        <td>[% duration_map.item(data.id) %]</td>
      </tr>
      [% END %]
    </table>
  </div>
  
  <p>
	[% site.html.back_button %]
  </p>
    
<!-- END [% template.name %] -->	
