<!-- BEGIN [% component.name %] -->
  [%
    lab_data = outreach.haematology; # PROCESS dumper.tt dump = lab_data;
    fields = lab_data.keys; # PROCESS dumper.tt dump = fields;
  %]
  
	[% # use sysmex data for use if no outreach haematology data:
		sysmex_data = raw_lab_test_data.haematology_data; # PROCESS dumper.tt dump = sysmex_data.as_tree;

		IF sysmex_data;
			USE Math; # need to skip *000 entries:
			UNLESS sysmex_data.lymph.match('\*000');
        import_data.lymphs = sysmex_data.lymph / 10 | format('%.1f');
      END;
			UNLESS sysmex_data.wbc.match('\*000');            
        import_data.wbc = sysmex_data.wbc / 10 | format('%.1f');
      END;
   		UNLESS sysmex_data.plt.match('\*000');
        import_data.plts = Math.int( sysmex_data.plt / 1 );
      END;
			UNLESS sysmex_data.hb.match('\*000');
        import_data.hb = Math.int( sysmex_data.hb / 1 );
      END; # PROCESS dumper.tt dump = import_data;
		END;
	%]

  [% outreach_haematology_dfv_js %]
  
  <form method="post" action="[% app_url %]/outreach/lab_results/[% request_data.id %]"
      name="outreachHaematology" id="outreachHaematology" [% outreach_haematology_onsubmit %]>
     <input type="hidden" name="department" value="haematology" />
    <table class="indent">
      <tr>
        [% FOREACH param IN fields;
          class = # highlight if param result below param lower_limit:
            lab_data.item(param).result AND # have data
            lab_data.item(param).lower_flag AND # and lower_limit
            lab_data.item(param).result < lab_data.item(param).lower_flag # data below lower_limit
          ? 'highlight' : 'normal'
        %]
          <th class="[% class %]">
            [% INCLUDE th_default_val lab_data_param = lab_data.item(param) %]
          </th>
        [% END %]
      </tr>  

			<tr>
			[% FOREACH param IN fields; error = errs.item(param);
				highlight = import_data.item(param) AND NOT lab_data.item(param).result;
			%]
				<td>[% # PROCESS dumper.tt dump = highlight %]
					<input type="text" size="3" name="[% param %]" id="[% param %]"
            value="[% lab_data.item(param).result || import_data.item(param) %]"
				    [% IF highlight %]style="border: 2px dotted #f00"[% END %] />
            [% error %]
				</td>				
			[% END %]
				<td class="borderless">[% IF highlight; button_class="red button"; END;
					INCLUDE outreach_submit %]</td>
			</tr>
		</table>
	</form>
<!-- END [% component.name %] -->    
