[% META title = 'Haematological Malignancy Research Network &raquo; Delete Data' -%]
<!-- BEGIN [% template.name %] -->

	[%
		patient = data.patient_case.patient;
		request_id   = c.param('id');
		data_section = c.param('Id'); # e.g. lymphoid

	    # PROCESS dumper.tt dump = data.as_tree;
		# PROCESS dumper.tt dump = c.param('id'); # e.g. 1
		# PROCESS dumper.tt dump = data_section;
		# PROCESS dumper.tt dump = hmrn_data.params.$data_section;
		# PROCESS dumper.tt dump = hmrn_data.maps.parameters;
		# PROCESS dumper.tt dump = hmrn_data;
		# PROCESS dumper.tt dump = shared_data;
    %]

	[% IF shared_data.size;
		# do we have any sections with its own (non-shared) data?
		have_unique_section_data = 0;
		FOREACH d IN shared_data; # INCLUDE dumper.tt dump = d;
			FOREACH pair IN d.value.in_categories; # INCLUDE dumper.tt dump = pair;
				NEXT UNLESS pair.value; # to avoid Argument "" isn't numeric in addition
				have_unique_section_data = have_unique_section_data + pair.value;
			END;
		END;
	%]
		<div class="warning">NOTE:
			<div class="indent">
				* deleting data items from the [% data_section.upper %] section
				will also remove them from other sections
			</div>
			[% IF have_unique_section_data %]
				<div class="indent">
					* sections highlighted in red also contain additional
					(non-shared) data
				</div>
			[% END %]
		</div>
		<p class="spacer"></p>
        <table class="indent">
            <tr>
                <th>Parameter</th>
                <th>Value</th>
                <th>Will Be Deleted From Section</th>
            </tr>
            [% FOREACH entry IN shared_data %]
                <tr>
                    <td>[% entry.key %]</td>
                    <td>[% entry.value.result; %]</td>
                    <td>
                        [% FOREACH x IN entry.value.in_categories; IF x.value %]
						  <span style="color: red;"
						    title="[% x.key; ' also contains additional unique '
								_ 'data which may need to be checked before '
								_ 'deleting.' %] ">[% x.key %]</span>
                            [% ELSE; x.key; END %]
                        [% END %]
                    </td>
                </tr>
            [% END %]
        </table>
	[% END # IF shared_data %]

	<form method="post" action="[% app_url %]/hmrn_data/delete_section_data/[%
        request_id %]/[% data_section %]">
        <p class="indent warning">Confirm you want to <u>permanently</u> delete
            the [% data_section.upper.replace('_', ' ') %] dataset for patient
            [% patient.first_name.ucfirst %] [% patient.last_name.upper %] /
            [% patient.dob.dmy %] / [% patient.nhs_number %]
            <input type="checkbox" name="confirm_delete" value="1" />
            <input type='submit' value='Delete' name='.submit' class='button' />
        </p>
    </form>
    <p>[% site.html.back_button %]</p>
<!-- END [% template.name %] -->
