<!-- BEGIN [% component.name %] -->
    [% sites = hmrn_data.imaging; # PROCESS dumper.tt dump = sites %]
    [% imaging_opts = hmrn_data.maps.imaging_options; # PROCESS dumper.tt dump = imaging_opts %]
    
    [% BLOCK build_checkbox;
        # PROCESS dumper.tt dump = dataset; # 'dataset' defined locally in calling block
        IF cols; # have left & right nodal sites:
            IdL = imaging_opts.description.item(field _ '_left');  # table id for left-hand site
            IdR = imaging_opts.description.item(field _ '_right'); # table id for right-hand site
        ELSE; # single site:
            IdX = imaging_opts.description.item(field);
        END;
		
		site_opts = dataset.site_opts; # PROCESS dumper.tt dump = site_opts;
		
		# if data entry show all rows, otherwise just 'positive' rows:
		IF data_entry OR ( site_opts.item(IdL) OR site_opts.item(IdR) OR site_opts.item(IdX) ) %]
        <tr>
            <td class="label" align="right">
                <span title="[% span %]" class="[% span ? 'acronym' : 'normal' %]">
                    [% IF NOT label; field | ucfirst; ELSE; label; END %]</span>:
            </td>
            <td class="content" style="text-align: center">
				[% IF cols %]
					[% IF data_entry %]
						<input type="checkbox" name="option_id" value="[% IdL %]" />
						<input type="checkbox" name="option_id" value="[% IdR %]" />
					[% ELSE; # just show checkbox images:
						imgL = site_opts.item(IdL) ? 'checked' : 'checkbox';
						imgR = site_opts.item(IdR) ? 'checked' : 'checkbox';
					%]
						<img src="/images/[% imgL %].png" />
						<img src="/images/[% imgR %].png" />
					[% END %]
                [% ELSE %]
					[% IF data_entry %]
						<input type="checkbox" name="option_id" value="[% IdX %]" />
					[% ELSE; img = site_opts.item(IdX) ? 'checked' : 'checkbox' %]
						<img src="/images/[% img %].png" />
					[% END %]
                [% END %]
            </td>
        </tr>
		[% END %]
    [% END %]
    
	[% BLOCK build_scan_form; # scan = ct or pet
		array_size = sites.${scan}.size || 0;
    %]
		<p class="bold indent">[% scan | upper %] scan [[% array_size %]]:
			[% div_name = "${scan}-scan"; INCLUDE site/snippets/toggleview.tt %]
		</p>
		<div id="[% div_name %]" class="itemhidden">
			[%
				IF array_size; # has previous data, display in read-only mode:
					FOREACH event IN sites.$scan; # PROCESS dumper.tt dump = d;
						INCLUDE hmrn/data/imaging_form.tt;
					END;
				END;
				# add form for new dataset:
				INCLUDE hmrn/data/imaging_form.tt
					scan_type  = scan
					data_entry = 1 # triggers data entry fields
					ndatasets  = array_size; # sets initial/followup options
			%]
		</div>	
	[% END %]
	
  <div class="indent">
	<h4>Imaging data:</h4>	
	[% INCLUDE build_scan_form FOREACH scan IN ['ct' 'pet'] %]
  </div>
<!-- END [% component.name %] -->
