  [% META title = 'Admin &raquo; Edit Diagnosis' -%]
<!-- BEGIN [% template.title %] -->

  [% # PROCESS dumper.tt dump = count %]
    [% # PROCESS dumper.tt dump = sub_categories %]

  [% diagnosis_dfv_js %]

	[% PROCESS admin/request_nav.tt page = 'diagnoses' %]

  <h2 align="center">Edit Diagnosis Details</h2>

    [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_name %]
            <dd>Diagnosis [% error_name %]</dd>[% END %]
        [% IF error_icdo3 %]
            <dd>ICDO3 [% error_icdo3 %]</dd>[% END %]
        [% IF error_diagnostic_category_id %]
            <dd>Category [% error_diagnostic_category_id %]</dd>[% END %]
    </dl>
    [% END %]

    [% IF count %]
    <h4 class="warning">WARNING: this diagnostic term has already been used [% count %]
        time[% IF count > 1 %]s[% END %] - make sure you know what you are doing
        if you alter it !!
    </h4>
    [% ELSE %]
    <h4 class="info">INFO: this diagnostic term has never been used - it is
        permissible to alter it.
    </h4>
    [% END %]

    <form method="post" action="[% app_url %]/config/diagnoses/update/[% data.id %]"
        [% diagnosis_onsubmit %] name="_diagnosis" id="_diagnosis">

    <table>
        <tr>
            <th [% IF error_name %]class="error"[% END %]>Diagnosis</th>
            <th [% IF error_icdo3 %]class="error"[% END %]>ICDO3</th>
			<th [% IF error_diagnostic_category_id %]class="error"[% END %]>Category</th>
			<th [% IF error_sub_category_id %]class="error"[% END %]>Sub</th>
			<th [% IF error_active %]class="error"[% END %]>Active</th>
        </tr>

        <tr>
            <td>
                <input type="text" name="name" size="60" value="[% data.name | html %]" />
             </td>
            <td>
                <input type="text" name="icdo3" size="6" value="[% data.icdo3 | html %]" />
             </td>
			<td>
				<select name="diagnostic_category_id">
				[% FOREACH entry IN categories;
                    NEXT UNLESS entry.category_type.match('main') %]
                     <option value="[% entry.id %]" [% 'selected' IF entry.id ==
                             data.diagnostic_category_id %]>
                        [% entry.description %]
                    </option>
			    [% END %]
				</select>
			</td>
			<td>
				<select name="sub_category_id">
                    <option value="">--</option>
				[% FOREACH entry IN categories;
                    NEXT UNLESS entry.category_type.match('sub') %]
                     <option value="[% entry.id %]" [% 'selected' IF entry.description
                            == sub_categories.item(data.icdo3) %]>
                        [% entry.description %]
                    </option>
			    [% END %]
				</select>
			</td>
			<td>
				<select name="active">
				[% FOREACH option IN ['yes', 'no'] %]
                     <option value="[% option %]" [% 'selected' IF option == data.active %]>
                        [% option %]
                    </option>
			    [% END %]
				</select>
                <!-- dont trigger redirect when editing diagnosis terms: -->
                <input type="hidden" name="new_labtests" value="no" />
			</td>
             <td>
                [% site.html.submit %]
            </td>
        </tr>
    </table>

    </form>

    <p>[% site.html.back_button %]</p>
<!-- END [% template.title %] -->
