[% content_only = 1 # no html wrappers %]

<html>
<head>
  <!-- BEGIN [% template.name %] -->
  <title>DNA/RNA stabilisation worksheet</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link type="text/css" rel="stylesheet" href="/css/worksheet.css" />
</head>

<body>
    [% # INCLUDE dumper.tt dump = all_lab_tests %]
    [% # PROCESS dumper.tt dump = requests %]
    [% # FOREACH rs IN result_summaries_map; PROCESS dumper.tt dump = rs; END %]

    <p class="classname">[% site.html.back_button %]</p>

    <h2>DNA/RNA stabilisation worksheet</h2>

    [% IF requests.size;
        USE date(format = '%d.%m.%Y @ %H:%M', locale = 'en_GB');
    %]
      <div class="indent">
        <p class="bold">[% c.authen.username | upper %] / [% date.format %]</p>

        <table>
            <tr style="font-size: smaller">
                <th>LabRef</th>
                <th>Name</th>
                <th>Type</th>
                <th>Specimen</th>
                <th>Presentation</th>
                <th>Registered</th>
                <th>Location</th>
                <th>External Reference</th>
                <th>Sample to&nbsp;lysis</th>
                <th>Transfer&nbsp;to eppendorf</th>
            </tr>
            [% # highlight if screened as (escape brackets):
                do_highlight = c.get_yaml_file('xna_stabilisation_highlight');
                    # INCLUDE dumper.tt dump = highlight_screens;
                FOREACH entry IN requests; # INCLUDE dumper.tt dump = entry.as_tree;
                    data  = entry.request; # for lab_number.tt
                    # xna tests:
                    lab_test = entry.lab_test; # INCLUDE dumper.tt dump = lab_test.as_tree;
                    # all lab-tests:
                    all_tests = all_lab_tests.${entry.request_id}; # INCLUDE dumper.tt dump = all_tests;
                    location  = data.patient_case.referral_source.display_name;
                    screened  = data.request_initial_screen.screen.description;
                    results   = result_summaries_map.item(data.id); # INCLUDE dumper.tt dump = results;
                    patient   = data.patient_case.patient;
                    class     = 'normal'; # but override if result summary matches

                    #### screens & results terms all replaced by test names in RfC578:
                        # one of highlighted screens:
                    #FOREACH s IN do_highlight.screens; # INCLUDE dumper.tt dump = s;
                    #    IF screened.match(s); class = 'highlight-blue'; LAST; END;
                    #END; # INCLUDE dumper.tt dump = screened;
                        # manually set class if specific result summary:
                    #IF results;
                    #    FOREACH pair IN do_highlight.results; # INCLUDE dumper.tt dump = pair;
                    #        section = pair.key;
                    #        result  = pair.value;
                    #        IF results.${section}.match(result);
                    #            class = 'highlight-blue'; LAST;
                    #        END;
                    #    END;
                    #END;
                    FOREACH t IN do_highlight.tests;
                        IF all_tests.grep(t).size;
                            class = 'highlight-blue'; LAST;
                        END;
                    END;
            %]
                <tr class="[% class %]">
                    <td>[% INCLUDE site/lab_number.tt want_url = 1 %]</td>
                    <td>
                        [% patient.last_name | upper %],
                        [% patient.first_name | ucfirst %]
                    </td>
                    <td>[% lab_test.field_label.remove(' extraction') %]</td>
                    <td>
                        [% specimen_map.item(data.id).sample_code.join(',') %]
                        [% INCLUDE site/snippets/doi.tt
                            IF request_options_map.item(data.id).doi %]
                    </td>
                    <td>[% screened %]</td>
                    <td>[% data.created_at.strftime('%d.%b.%Y') %]</td>
                    <td>[% INCLUDE site/display_name.tt %]</td>
                    <td>[% data.request_external_ref.external_reference | html %]</td>
                    <td>[% %]</td>
                    <td>[% %]</td>
                </tr>
            [% END %]
        </table>
      </div>
    [% ELSE %]
      <h5 class="indent info">No samples to stabilise</h4>
    [% END %]
</body>
</html>
<!-- END [% template.name %] -->
