<!-- BEGIN [% template.name %] -->
  [% META title = 'Worklist &raquo; Plasma Storage Worksheet' -%]

  [% IF requests.size;
    i = 0; BLOCK row;
        data = entry.request; # for lab_number.tt
		IF restrict_request_map;
		  NEXT UNLESS restrict_request_map.${data.id};
		END;
		location = data.patient_case.referral_source.display_name
		patient  = data.patient_case.patient;
		# want to split specimens into new line for each:
		specimens = specimen_map.item(data.id).sample_code;
		FOREACH specimen IN specimens;
    %]
	  <tr>
        <td>[% i = i + 1; i %]</td>
        <td>
          [% PROCESS site/lab_number.tt want_url = 1 %]
        </td>
        [% class = request_options_map.item(data.id).urgent ? 'red' : 'normal' %]
        <td class="[% class %]">
          [% patient.last_name   | upper %],
          [% patient.first_name  | ucfirst %]
          [% patient.middle_name | ucfirst %]
        </td>
		<td>[% data.created_at.strftime('%d.%m.%Y') %]</td>
        <td>
            [% specimen # specimen_map.item(data.id).sample_code.join(', ') %]
            [% INCLUDE site/snippets/doi.tt IF request_options_map.item(data.id).doi %]
        </td>
		<td>[% PROCESS site/display_name.tt %]</td>
        <td>
          [% IF data.request_initial_screen %]
            [% data.request_initial_screen.screen.description | html %]
          [% ELSE %]
            [% site.html.grey_null %]
          [% END %]
		</td>
        <td>[% entry.lab_test.field_label %]
		  [% '[P]' IF entry.lab_test.test_type.match('panel') %]
        </td>
        <td align="center">
            <input type="checkbox" name="request_specimen"
                value="[% data.id %]~[% specimen # request_specimen lacks 'id' !! %]" />
        </td>
      </tr>
    [% END; END %]

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

    <h3>Print plasma storage worksheets</h3>

    <form action="[% app_url %]/local_worklist/plasma_storage_worksheet"
		method="post" name="worksheet" id="worksheet">
	  <input type="hidden" name="function_name" value="[% function_name %]" />
    <table>
        <tr>
            <td colspan="9" align="right" class="borderless">
                <input type="button" name="CheckAll" value="Select all"
                  onClick="checkAll(document.worksheet.request_specimen)">
                <input type="button" name="UnCheckAll" value="Clear all"
                  onClick="uncheckAll(document.worksheet.request_specimen)">
            </td>
        </tr>
      <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>Investigation</th>
		<th>Print</th>
      </tr>

      [% FOREACH entry IN requests; PROCESS row; END %]
    </table>
    <p class="indent">
      <input type="button" name="UnCheckAll" value="Clear all"
        onClick="uncheckAll(document.worksheet.request_specimen)">
        [% site.html.submit %]
    </p>
    </form>

  [% ELSE %]<p class="indent info">No requests found</p>[% END %]
<!-- END [% template.name %] -->
