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

  [% # PROCESS dumper.tt dump = prereg_data.as_tree %]
  [% # PROCESS dumper.tt dump = specimens_map %]
  [% # PROCESS dumper.tt dump = c.stash.errs %]

  [% # define some data structures:
    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',
    };
  %]

  [% pre_screen_new_dfv_js %]

  <h3 class="header">Pre-screen - add new specimen data</h3>

  [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_lab_tests %]
            <dd>require one or more lab tests</dd>[% END %]
        [% IF error_specimen %]
            <dd>specimen [% error_specimen %]</dd>[% END %]
    </dl>
  [% END %]

  <form action="[% app_url %]/local_worklist_preregistration/new_data/[% c.param('id') %]"
    method="post" name="preScreen" id="preScreen" [% pre_screen_new_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/=/[% prereg_data.labno %]"> -->
            [% prereg_data.labno %]
          <!-- </a> -->
        </td>
        <td>
          <input type="text" name="surname" size="15" [% site.html.disabled %]
            value="[% prereg_data.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.item(type); # can't re-request same specimen type %]
            <option value="[% type %]">[% 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" />
        </td>
        [% END %]

        <td>[% site.html.submit %]</td>
      </tr>
    </table>

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