[% content_only = 1 # no html wrappers %]

<html>
<head>
  <!-- BEGIN [% template.name %] -->
  <title>[% c.query.param('worklist_function') %] worksheet</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link type="text/css" rel="stylesheet" href="/css/worksheet.css?v1.2" />
</head>

<body>
    [% # FOREACH entry IN requests; PROCESS dumper.tt dump = entry.as_tree; END %]
    [% # PROCESS dumper.tt dump = c.query.self_url %]
    [% # PROCESS dumper.tt dump = request_specimen_map %]

    [% tbl_id = 'pcrWorksheet'; INCLUDE site/js/reorderRows.js %]

  <p id="back">[% site.html.back_button %]</p>

  <h2>[% c.query.param('worklist_function') %] Worksheet</h2>
  <div class="bold indent">
    [% IF test_names.size %]
        <p>Test(s): [% test_names.join('; ') %]</p>
    [% END %]
    <p>Performed by: [% c.authen.username.upper %]</p>
    <p>Date: [% USE date(format = '%d.%m.%Y @ %H:%M', locale = 'en_GB');
	  date.format %]</p>
  </div>

  <p class="info indent noPrint">[drag &amp; drop rows to re-order]</p>
  <table id="[% tbl_id %]">
    <tr>
        <td class="borderless"></td>
        <th>HMDS ref</th>
        <th>Name</th>
        <th>Date</th>
        <th>Sample</th>
        <th>Lab Test</th>
        <th>Comments/Results</th>
    </tr>
	<tbody>
	[% i = 0; # row counter
	  FOREACH entry IN requests; # PROCESS dumper.tt dump = entry.as_tree; NEXT;
        data = entry.request; # for lab_number.tt
        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; # only show requested specimens:
            NEXT UNLESS request_specimen_map.item(data.id).grep(specimen).size;
    %]
		<tr>
			<td class="index" align="right">[% i = i + 1; i %]</td>
			<td>[% PROCESS site/lab_number.tt want_url = 0 %]</td>
			<td>
				[% patient.last_name | upper %],
				[% format_firstname(patient) || patient.first_name | ucfirst %]
			</td>
			<td>[% data.created_at.strftime('%d.%m.%Y') %]</td>
			<td>[% specimen %]</td>
			<td>[% entry.lab_test.field_label %]</td>
            <td class="empty40"></td>
		</tr>
  [% END; END %]
	</tbody>
  [% BLOCK empty_row %]
	<tr>
	  <td align="right">[% i = i + 1; i %]</td>
	  <td></td><td></td><td></td><td></td><td></td><td></td>
	</tr>
  [% END; FOREACH n IN [ 1 .. 5 ]; PROCESS empty_row; END %]
  </table>

    <p class="bold">Tube order and alignment must be checked at all transfer
	  stages. Initial once done.
	</p>

	<table class="indent">
	  <tr>
		<td class="label">PCR performed by:</td><td class="empty25"></td>
        <td class="borderless"></td>
	  </tr>
	  <tr>
		<td class="label">Tube/sample order checked by:</td><td></td></td>
	  </tr>
	  <tr>
		<td class="label">Plate name:</td><td class="empty50" colspan="2"></td>
	  </tr>
	  <tr>
		<td class="label">Tube prefix:</td><td colspan="2"></td>
	  </tr>
	  <tr>
		<td class="label">Sample transfer (if required):</td><td class="empty25"></td>
        <td class="borderless"></td>
	  </tr>
	  <tr>
		<td class="label">Data transfer (if required):</td><td class="empty25"></td>
        <td class="borderless"></td>
	  </tr>
	</table>

    <p class="spacer"></p>

	<table class="indent">
	  <tr>
		<th class="empty15">Reagent</th>
		<th class="empty15">Batch number</th>
		<th class="empty15">Reagent</th>
		<th class="empty15">Batch number</th>
	  </tr>
      [% FOR [1..4] %]
        <tr>
            [% FOR [1..4 ] %]<td>&nbsp;</td>[% END %]
        </tr>
      [% END %]
	</table>

    <p class="spacer"></p>

	<table class="indent">
	  <tr>
		<td class="label">Reagent expiry checked by:</td>
		<td class="empty50"></td>
	  </tr>
    </table>

    <p class="spacer"></p>

 	<table class="indent">
	  <tr>
		<td class="label">Primary reported by:</td>
		<td class="empty50"></td>
	  </tr>
	  <tr>
		<td class="label">Results checked by:</td>
		<td class="empty50"></td>
	  </tr>
	  <tr>
		<td class="label">QC params checked by:</td>
		<td class="empty50"></td>
	  </tr>
    </table>

   <h4>Other / comments</h4>
</body>
</html>
<!-- END [% template.name %] -->
