<!-- BEGIN [% template.name %] -->
  [% META title = 'Pre-screen &raquo; New Data' -%]

  [% # PROCESS dumper.tt dump = request %]
  [% # PROCESS dumper.tt dump = specimens_map %]

  [% # define some data structures:
    labno = request.labno;
    col_names = [ 'PCS','BLS','SCS','TLS','RIT','OUT' ];
    lab_tests_map = {
      PCS => 'plasma_cell',
      BLS => 'b_lymphoid',
      SCS => 'stem_cell',
      TLS => 't_lymphoid',
      RIT => 'rituximab',
      OUT => 'outreach',
    };
    record_ids = [];
    record_ids.push(request.id);
    record_ids.push(request.specimen_lab_test_data.id); # optional
    record_id = record_ids.join('/'); # for 'post' requests (pre-reg.id & pre-reg-specimen.id)
  %]

  [% pre_screen_data_dfv_js %]

  <h3 class="header">Edit pre-screen data</h3>

  [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_surname %]
            <dd>surname [% error_surname %]</dd>[% END %]
        [% IF error_specimen %]
            <dd>specimen [% error_specimen %]</dd>[% END %]
    </dl>
  [% END %]

  <form action="[% app_url %]/local_worklist_preregistration/update/[% record_id %]"
    method="post" name="pre-screen" id="pre-screen" [% pre_screen_data_onsubmit %]>

    <input type="hidden" name="lab_section_id" value="[% lab_section_id %]" />

    <table class="indent">
      <tr>
        <th>LabNo</th>
        <th>Surname</th>
        <th [% IF error_specimen %]class="error"[% END %]>Specimen</th>
        [% FOREACH col IN col_names %]
          <th [% IF error_lab_tests %]class="error"[% END %]>[% col %]</th>
        [% END %]
        <td class="borderless"></td>
      </tr>

      <tr>
        <td>
            <!-- href no point:
                <a href="[% app_url %]/image/=/[% labno %]">[% labno %]</a>
            -->
            [% labno %]
        </td>
        <td>
          <input type="text" name="surname" size="15" [% site.html.onfocus %]
            value="[% request.surname %]" />
        </td>
        <td>
          <select name="specimen">
            <option value=""></option>
            [% FOREACH type IN ['BM' 'CF' 'EF' 'GU' 'LA' 'LU' 'PB' 'RU' 'XA' 'XU'];
                NEXT IF specimens_map.${type} # can't re-request same specimen type
                    AND type != request.specimen_lab_test_data.specimen_code; # keep existing
            %]
                <option value="[% type %]" [% 'selected' IF
                    type == request.specimen_lab_test_data.specimen_code %]>
                        [% type %]</option>
            [% END %]
          </select>
        </td>

        [% FOREACH col IN col_names;
            test_name = lab_tests_map.item(col); # test_name %]
          <td width="35" align="center">
              <input type="checkbox" name="[% test_name %]" value="x"
                [% 'checked' IF request.lab_tests.${test_name} %] />
          </td>
        [% END %]

        <td>[% site.html.submit %]</td>
		<td>
			<a href="[% app_url %]/local_worklist_preregistration/delete/[% record_id %]">
				<span class="red">DELETE</span>
			</a>
		</td>
      </tr>
    </table>
  </form>

  <p>[% site.html.back_button %]</p>
<!-- END [% template.name %] -->
