<!-- BEGIN [% component.name %] -->
	[% setnum  = event.key;   # PROCESS dumper.tt dump = setnum %]
	[% dataset = event.value; # PROCESS dumper.tt dump = dataset %]

  <div class="indent [% scan %]-imaging">
	<form method="post" name="imaging-[% scan %]-scan" id="imaging-[% scan %]-scan"
		action="[% app_url %]/hmrn_data/new_imaging_data/[% data.id %]/[% patient.id %]">

	[% IF data_entry; # is data entry %]
		[% IF # provide a name="error" for internal anchor:
			error_scan_stage OR	error_scan_date        
		%]<a name="error"><span>&nbsp;</span></a>[% END %]

        <script type="text/javascript">
            $(document).ready(function() {
                $("#imaging-[% scan %]-scan").validationEngine()
            })
        </script>

		<p class="bold indent">			
			New scan:
			<select name="scan_stage">
				<option value="">-- select --</option>
				<option value="initial">initial scan</option>
				<option value="follow-up" [% 'selected=1' IF ndatasets # previous data %]>
					follow-up</option>
			</select>
			[% error_scan_stage %]
			date:
			<input type="text" size="8" name="scan_date" id="date-[% scan %]-scan"
                class="validate[ajax[ajaxDate]]" />
			[% error_scan_date %]
		</p>
		<input type="hidden" name="scan_type" value="[% scan %]" />
		<input type="hidden" name="dataset" value="[% ndatasets + 1 %]" />
        
        [% IF scan.match('pet') # SUVmax & Deauville: %]
            <p class="bold indent">	
                SUV<sub>max</sub>: <input type="text" size="4" name="suv_max" />
            [% IF ndatasets; # ie a follow-up dataset %]
                Deauville score:
                <select name="deauville">
                    <option value="">--</option>
                    [% FOREACH i IN [1 .. 5] %]
                        <option value="[% i %]">[% i %]</option>
                    [% END %]
                </select>
            [% END %]
        [% END %]
        
	[% ELSE %]
		<p class="indent">
			<span class="bold">[% dataset.stage | ucfirst %] scan</span>
			on <span class="bold">[% dataset.date.dmy('/') %]</span>
			[ <a href="[% app_url %]/hmrn_data/edit_imaging/[% data.id %]/[%
                dataset.event_id %]">edit</a> ]
			[ <a href="[% app_url %]/hmrn_data/delete_imaging/[% data.id %]/[%
                dataset.event_id %]?scan=[% scan %];stage=[% dataset.stage %];date=[%
                  dataset.date.dmy('/') %]">
                    <span class="red acronym" title="delete">X</span>
            </a> ]                
		</p>
        [% IF scan.match('pet') # SUVmax & Deauville: %]
            <p class="bold indent">	
              SUV<sub>max</sub>: <input type="text" size="4" name="suv_max"
                value="[% dataset.suv_max %]" readonly="readonly" />
              [% IF dataset.stage.match('follow-up') %]
                Deauville score:
                  <select name="deauville" readonly="readonly">
                    <option value="">[% dataset.deauville || '--' %]</option>
                  </select>
              [% END %]
            </p>
        [% END %]
		[% # find nodal & extra-nodal entries for display:
			nodal_sites = []; extranodal_sites = []; other_options = [];
			FOREACH site_opt IN dataset.site_opts; # PROCESS dumper.tt dump = site_opt;
				NEXT UNLESS site_opt.key.match('\d'); # skip non-numeric
				opt_type = imaging_opts.map.item(site_opt.key).option_type; # PROCESS dumper.tt dump = opt_type;
				
				nodal_sites.push(1) IF opt_type.match('_nodal'); # upper/lower
				extranodal_sites.push(1) IF opt_type.match('extranodal');
				flag_options.push(1) IF opt_type.match('flag');
			END; 
			have_flag_opts = flag_options.size; # PROCESS dumper.tt dump = have_flag_opts;
			have_nodal_sites = nodal_sites.size; # PROCESS dumper.tt dump = have_nodal_sites;
			have_extranodal_sites = extranodal_sites.size; # PROCESS dumper.tt dump = have_extranodal_sites;			
		%]
	[% END %]

    <table class="indent">
        <tr>
			[% IF data_entry OR have_nodal_sites OR have_flag_opts;
                INCLUDE hmrn/data/nodal_sites.tt %]				
                <td class="borderless">&nbsp;</td>
			[% END;
              IF data_entry OR have_extranodal_sites OR dataset.other;
                INCLUDE hmrn/data/extranodal_sites.tt;
			  END;
            %]
        </tr>

        [% IF user_can_enter_data AND data_entry # allow data entry %]
          <tr class="borderless" align="center">
            <td colspan="2">[% site.html.submit %] [% site.html.reset %]</td>
          </tr>
        [% END %]
    </table>
  </form>
  </div>
<!-- END [% component.name %] -->
 