[% content_only = 1 # no html wrappers %]
    [% worklist_function = c.query.param('worklist_function') %]

<html>
<head>
  <!-- BEGIN [% template.name %] -->
  <title>[% worklist_function.replace('_', ' ') %] 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.4" />
</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 %]
    <div class="noPrint">
        [% INCLUDE site/snippets/message_stack.tt # error, warning & info msgs %]
    </div>

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

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

  <h2>[% worklist_function.replace('_', ' ') %] 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>Flow Purity</th>
        <th>Flow performed by:</th>
        <th>Adequate for FISH/molecular?</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></td>
                <td></td>
                <td></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>
      <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 colspan="4" class="borderless bold">
                Selections performed by:</td>
        </tr>
        <tr>
            <td>Sample/lysing tube order checked by:</td>
            <td class="empty20"></td>
            <td>Final product/DNA tube order checked by:</td>
            <td class="empty20"></td>
        </tr>
        <tr>
            <td>Lysing tube/Facstube for microbeads order checked by:</td>
            <td class="empty20"></td>
            <td>MAA sample transfer (FISH LAB) performed by:</td>
            <td class="empty20"></td>
        </tr>
        <tr>
            <td>Final product tube labelling/sample order in chilled rack checked by:</td>
            <td class="empty20"></td>
            <td>MAA sample transfer (FISH LAB) checked by:</td>
            <td class="empty20"></td>
        </tr>
	</table>

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

    [% UNLESS worklist_function.match('MLPA_myeloma') %]
	<table class="indent">
<tr>
    <th colspan="2">AutoMacs HD number:</th>
    <th colspan="2"></th>
</tr>
	  <tr>
		<th class="empty15">Reagent</th>
		<th class="empty15">Batch number</th>
		<th class="empty15">Opened date</th>
		<th class="empty15">Comments</th>
	  </tr>
          [% items = [ 'Washing Solution',
                       'Running Buffer',
                       'CD138 Microbeads',
                       'CD19 Microbeads'  ];
        FOREACH i IN items %]
        <tr>
        <td>[% i %]</td>
            [% FOR [1..3 ] %]<td>&nbsp;</td>[% END %]
        </tr>
    [% END %]
	</table>
    <p class="spacer"></p>
    [% END %]

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

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