<!-- BEGIN [% template.name %] -->
  [% META title = 'Worklist &raquo; Print FISH Worksheets' -%]

    [% # PROCESS dumper.tt dump = data %]

    [% BLOCK row;
        request = entry.request;
		patient = request.patient_case.patient;
    %]
	  <tr>
        <td>[% i = ( i || 0 ) + 1; i # can't do loop.count if using NEXT %]</td>
        <td>
          [% data = request; PROCESS site/lab_number.tt want_url = 1;
            # expects request object 'data' %]
        </td>
        [% class = request_options_map.item(request.id).urgent ? 'red' : 'normal' %]
        <td class="[% class %]">
          [% patient.last_name   | upper %],
          [% patient.first_name  | ucfirst %]
          [% patient.middle_name | ucfirst %]
        </td>
		<td>[% request.created_at.strftime('%d.%m.%Y') %]</td>
        <td>
          [% specimen_map.item(request.id).sample_code.join(', ') %]
          [% INCLUDE site/snippets/doi.tt IF request_options_map.item(request.id).doi %]
        </td>
		<td>
		    [% SET location = request.patient_case.referral_source.display_name %]
            [% PROCESS site/display_name.tt %]
		</td>
        <td>
          [% IF request.request_initial_screen %]
            [% request.request_initial_screen.screen.description | html %]
          [% ELSE %]
            [% site.html.grey_null %]
          [% END %]
		</td>
        <td>
		  [% prefix = entry.lab_test.test_type.match('panel') ? 'P' : 'T' %]
		  [[% prefix %]] [% entry.lab_test.field_label %]
        </td>
        <td>
		  [% entry.status.description | upper %]
        </td>
        <td align="center">
            <input type="checkbox" name="request_id" value="[% request.id %]" />
        </td>
      </tr>
    [% END %]

    <p class="classname">[% site.html.back_button %]</p>

    <h3>Print FISH worksheets</h3>
    <form action="[% c.query.self_url # doesn't pass query params %]" method="get">
	  <input type="hidden" name="function_name"
		  value="[% c.query.param('function_name') %]" />
	  <input type="hidden" name="restrict_by_status" value="1" />
	  <p class="bold indent">Restrict by status:</p>
	  <div class="indent">
		[% status = [];
		  FOREACH entry IN data;
			status.push(entry.status.description)
			  UNLESS status.grep(entry.status.description).size; END;
		  FOREACH s IN status %]
			<div><input type="checkbox" name="status" value="[% s %]"
			  [% 'checked' IF c.query.param('status').grep(s).size %] />
			  [% s | upper %]</div>
		[% END %]
	  </div>
	  <p class="indent">[% site.html.submit %]<p>
	</form>

    <form action="[% app_url %]/local_worklist_fish-worksheet" method="post"
        name="fish_worksheets" id="fish_worksheets">
    <table>
      <tr>
        <td class="borderless"></td>
        <th>Lab No</th>
        <th>Name</th>
        <th>Date</th>
        <th>Sample</th>
        <th>Source</th>
		<th>Presentation</th>
		<th><a href="[% app_url
            %]/local_worklist?function_name=fish_worksheets;sort_by=lab_tests">
            Investigation</a>
        </th>
		<th>Status</th>
		<th>Print</th>
      </tr>

      [% FOREACH entry IN data; # PROCESS dumper.tt dump = entry
		  IF c.query.param('restrict_by_status');
			NEXT UNLESS c.query.param('status').grep(entry.status.description).size;
		  END;
        PROCESS row; END %]
    </table>

    <p class="indent">
      <input type="button" name="CheckAll" value="Select all"
        onClick="checkAll(document.fish_worksheets.request_id)">
      <input type="button" name="UnCheckAll" value="Clear all"
        onClick="uncheckAll(document.fish_worksheets.request_id)">
        [% site.html.submit %]
    </p>
    </form>
<!-- END [% template.name %] -->
