<!-- BEGIN worklist/local/preregistration/specimen_edit.tt -->
  [% META title = 'Pre-screen &raquo; Edit Specimen Data' -%]

  [% # PROCESS dumper.tt dump = request_specimen.as_tree %]
  [% # PROCESS dumper.tt dump = lab_tests %]
  [% # PROCESS dumper.tt dump = specimens_map %]
  
  [% # 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_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/specimen_update/[% request_specimen.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 colspan="2" class="borderless"></td>
      </tr>

      <tr>
        <td>[% labno = request_specimen.pre_reg.labno %]
          <a href="[% app_url %]/image/=/[% labno %]">[% labno %]</a>

        </td>
        <td>
          <input type="text" name="surname" size="15" [% site.html.onfocus %]
            value="[% request_specimen.pre_reg.surname %]" />
        </td>
        <td>
          <select name="specimen">
            <option value=""></option>
            [% FOREACH type IN ['BM' 'CF' 'GU' 'LA' 'LU' 'PB' 'RU' 'XA' 'XU'];
              NEXT IF specimens_map.item(type); # skip if already used %]
            <option value="[% type %]"
                [% 'selected' IF request_specimen.specimen_code == 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"
                [% 'checked' IF lab_tests.item(test_name) %] />
            </td>          
        [% END %]
        
        <td>[% site.html.submit %]</td>     
		<td>
			<a href="[% app_url %]/local_worklist_preregistration/delete/[%
                    request_specimen.pre_reg.id %]">
				<span class="red">DELETE</span>
			</a>
		</td>
      </tr>
    </table>
  </form>
<!-- END worklist/local/preregistration/specimen_edit.tt -->
