[% META
    title  = 'Haematological Malignancy Research Network &raquo; Edit Imaging Data'    
%]

<!-- BEGIN [% template.name %]  -->
    [%  # PROCESS dumper.tt dump = data;
        # PROCESS dumper.tt dump = imaging_opts;
        # PROCESS dumper.tt dump = c.stash.errs;
    %]

	[% addcss =	[
			'validationEngine.jquery.css' # for validationEngine
			'smoothness/jquery-ui-1.8.4.custom.css' # for DatePicker
		]
	%]

    [% BLOCK build_checkbox;
        # PROCESS dumper.tt dump = dataset; # 'dataset' defined locally in calling block
        IF cols; # have left & right nodal sites:
            IdL = imaging_opts.item(field _ '_left');  # table id for left-hand site
            IdR = imaging_opts.item(field _ '_right'); # table id for right-hand site
        ELSE; # single site:
            IdX = imaging_opts.item(field);
        END; %]

        <tr>
            <td class="label" align="right">
                <span title="[% span %]" class="[% span ? 'acronym' : 'normal' %]">
                    [% IF NOT label; field | ucfirst; ELSE; label; END %]</span>:
            </td>
            <td align="center">
				[% IF cols %]
    				<input type="checkbox" name="option_id" value="[% IdL %]"
                        [% 'checked' IF data.options_map.${IdL} %] />
    				<input type="checkbox" name="option_id" value="[% IdR %]"
                        [% 'checked' IF data.options_map.${IdR} %] />
                [% ELSE %]
					<input type="checkbox" name="option_id" value="[% IdX %]"
                        [% 'checked' IF data.options_map.${IdX} %]  />
                [% END %]
            </td>
        </tr>
    [% END %]    

    <h3>Edit [% data.scan_type | upper %] scan dataset #[% data.dataset %]:</h3>    

    [% IF dfv_errors %]
        <p class="error">[% c.cfg('msg').dfv_errors %]</p>
    [% END %]

	<script type="text/javascript" src="/js/jquery-ui-1.8.4.custom.min.js"></script>	
    <script type="text/javascript">
        $(function() {
            $('.datepicker').datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'dd/mm/yy',
            });
        });
	</script>

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

    <div class="indent">
        <form method="post" name="scan" id="scan" action="[% app_url
            %]/hmrn_data/do_edit_imaging/[% data.request_id %]/[% data.id %]">
			[%# scan_type & dataset only needed for history log & to keep same validation profile %]
			<input type="hidden" name="scan_type" value="[% data.scan_type %]" />
			<input type="hidden" name="dataset"   value="[% data.dataset %]" />
			
            <p class="bold indent">Scan:
                <select name="scan_stage">
                    <option value="">-- select --</option>
					[% FOREACH opt IN ['initial' 'follow-up'] %]
						<option value="[% opt %]" [% 'selected=1' IF data.stage.match(opt) %]>
							[% opt %]</option>
					[% END %]
	            </select>
				[% error_scan_stage %]
                date:
                <input type="text" size="8" name="scan_date" id="scan_date"
					value="[% data.date.dmy('/') %]" class="validate[ajax[ajaxDate]]" />
                [% error_scan_date %]
            </p>
    
            [% IF data.scan_type.match('pet') %]
                <p class="bold indent">	
                    SUV<sub>max</sub>: <input type="text" size="4" name="suv_max"
                        value="[% data.suv_max %]" />
                [% IF data.dataset > 1; # ie a follow-up dataset %]
                    Deauville score:
                    <select name="deauville">
                        <option value="">--</option>
                        [% FOREACH i IN [1 .. 5] %]
                            <option value="[% i %]" [% 'selected=1'
                                IF i == data.deauville %]>[% i %]</option>
                        [% END %]
                    </select>
                [% END %]
            [% END %]

            <table class="indent">
                <tr>
                    [% INCLUDE hmrn/data/nodal_sites.tt data_entry = 1 %]
                    [% INCLUDE hmrn/data/extranodal_sites.tt data_entry = 1 %]
                </tr>
                
                <tr class="borderless" align="center">
                    <td colspan="2">[% site.html.submit %] [% site.html.reset %]</td>
                </tr>
            </table>        
        </form>
    </div>
<!-- END [% template.name %]  -->
