[% 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.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>[% 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>
        [% IF worklist_function.match('MLPA_quantification') %]
            <th>DNA Conc<sup>n</sup></th><th>Comments</th>
        [% ELSIF worklist_function.match('MLPA_myeloma') %]
            <th>QC peaks checked by</th><th>Comments/Results</th>
        [% ELSE %]
            <th>Comments/Results</th>
        [% END %]
    </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>
            [% IF worklist_function.match('MLPA') %]
                <td class="empty20"><td class="empty30">
            [% ELSE %]
                <td class="empty40"></td>
            [% END %]
		</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>
      [% IF worklist_function.match('MLPA') %]<td></td>[% END %]
	</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">
            [% IF worklist_function.match('MLPA_quantification'); 'Quantification';
                ELSIF worklist_function.match('MLPA_myeloma'); 'MLPA'; ELSE; 'PCR'; END %]
                performed by:</td><td class="empty25">
          </td>
        <td class="borderless"></td>
	  </tr>
	  <tr>
        [% IF worklist_function.match('MLPA_myeloma') %]
            <td class="label">Data transfer from worklist to 96-well plate layout
                sheet checked by:</td><td></td></td>
        [% ELSE %]
            <td class="label">Tube/sample order checked by:</td><td></td></td>
        [% END %]
	  </tr>
      [% UNLESS worklist_function.match('MLPA_quantification') %]
        <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>
        [% UNLESS worklist_function.match('MLPA_myeloma') %]
            <tr>
              <td class="label">Sample transfer (if required):</td><td class="empty25"></td>
              <td class="borderless"></td>
            </tr>
        [% END %]
        <tr>
          <td class="label">Data transfer [% IF worklist_function.match('MLPA_myeloma');
            'to Coffalyser '; END %](if required):</td><td class="empty25"></td>
          <td class="borderless"></td>
        </tr>

        <tr>
          <td class="label">PCR machine:</td><td class="empty25"></td>
          <td class="borderless"></td>
        </tr>
      [% END %]
	</table>

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

    [% UNLESS worklist_function.match('MLPA_myeloma') %]
	<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>
    [% END %]

	<table class="indent">
	  <tr>
		<td class="label">Reagent expiry checked by:</td>
		<td class="empty50"></td>
	  </tr>
      [% IF worklist_function.match('MLPA_quantification') %]
        <tr>
          <td class="label">Standard curve checked by:</td>
          <td class="empty50"></td>
        </tr>
      [% ELSIF worklist_function.match('MLPA_myeloma') %]
        <tr>
          <td class="label">Transfer to genescan plate checked by:</td>
          <td class="empty50"></td>
        </tr>
        <tr>
          <td class="label">Genescan used:</td>
          <td class="empty50"></td>
        </tr>
      [% END %]
    </table>

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

    [% UNLESS worklist_function.match('MLPA_quantification') %]
 	<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>
      [% UNLESS worklist_function.match('MLPA_myeloma') %]
	  <tr>
		<td class="label">QC params checked by:</td>
		<td class="empty50"></td>
	  </tr>
      [% END %]
    </table>
    [% END %]

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