<!-- BEGIN [% template.name %] -->
  [% META title = 'Worklist &raquo; Unverified Haematology Data' -%]

    [% # PROCESS dumper.tt dump = haem_data %]
    [% # PROCESS dumper.tt dump = request_id %]
    
  [% IF haem_data.size %]
  <h3 class="header">Unverified haematology data [[% haem_data.size %]]</h3>

  <table class="indent">
    <tr>
        <td class="borderless"></td>
        <th>LabNo</th>
        <th>Date</th>
        <th>WBC</th>
        <th>RBC</th>
        <th>Hb</th>
        <th>Plt</th>
        <th>HCT</th>
        <th>MCV</th>
        <th>MCH</th>
        <th>MCHC</th>
        <th>Lym %</th>
        <th>Lym #</th>
        <th>Mix %</th>
        <th>Mix #</th>
        <th>Neu %</th>
        <th>Neu #</th>
        <td class="borderless" colspan="2">
    </tr>
    [% FOREACH entry IN haem_data;
        BLOCK calculate;
            DEFAULT factor = 10; # unless supplied
            result = entry.item(var);
            flag = var _ '_f'; # eg wbc_f
            class = result.match('\*') || entry.item(flag) ? 'red' : 'normal';
            %]
            <td class="[% class %]">
                [%  IF result.match('\*'); result; # ie *000
                    ELSE; 
                        IF float; # needs formatting:
                            FILTER format('%.' _ float _ 'f'); result / factor; END;
                        ELSE;
                            result / factor;
                        END;
                    END;
                %]
            </td>
        [% END %]
    <tr>
        <td>[% loop.count %]</td>
        <td>
          [% IF request_id.item(entry.lab_number) %]
            <a href="[% app_url %]/search/=/[% request_id.item(entry.lab_number)
                %]?_return=1">[% entry.lab_number %]</a>
          [% ELSE; entry.lab_number;END %]
        </td>
        <td>[% entry.created_at.dmy %]</td>
            [% INCLUDE calculate(var = 'wbc',  float = 1) %]
            [% INCLUDE calculate(var = 'rbc',  float = 2, factor = 100) %]
            [% INCLUDE calculate(var = 'hb',   float = 1)  %]
            [% INCLUDE calculate(var = 'plt',  float = 0, factor = 1) %]
            [% INCLUDE calculate(var = 'hct',  float = 1) %]
            [% INCLUDE calculate(var = 'mcv',  float = 1) %]
            [% INCLUDE calculate(var = 'mch',  float = 1) %]
            [% INCLUDE calculate(var = 'mchc', float = 1) %]
            [% INCLUDE calculate(var = 'lymph_percent', float = 1) %]
            [% INCLUDE calculate(var = 'lymph', float = 1) %]
            [% INCLUDE calculate(var = 'mixed_percent', float = 1) %]
            [% INCLUDE calculate(var = 'mixed', float = 1) %]
            [% INCLUDE calculate(var = 'neutr_percent', float = 1) %]
            [% INCLUDE calculate(var = 'neutr', float = 1) %]
        <td>
            <a href="[% app_url %]/result/accept_haem_data/[%
                entry.lab_number %]">ACCEPT</a>
        </td>
        <td>
            <a href="[% app_url %]/result/delete_haem_data/[%
                entry.lab_number %]">DELETE</a>
        </td>
    </tr>
    [% END %]
  </table>
  [% END %]
<!-- END [% template.title %] -->
