  [% META title = 'Admin &raquo; Clinician &raquo; Edit' -%]

  [% # PROCESS dumper.tt dump = data %]

  [% edit_referrer_dfv_js %]

	[% PROCESS admin/referral_nav.tt page = 'clinicians' %]
	
	<h2 align="center">Edit Clinician Details</h2>

    [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_national_code %]
            <dd>National code [% error_national_code %]</dd>[% END %]
        [% IF error_name %]
            <dd>Name [% error_name %]</dd>[% END %]
        [% IF error_referral_type_id %]
            <dd>Referral type [% error_referral_type_id %]</dd>[% END %]
        [% IF error_active %]
            <dd>Active [% error_active %]</dd>[% END %]
    </dl>
    [% END %]

    <form method="post" action="[% app_url %]/config/clinicians/update/[% data.id %]"
		[% edit_referrer_onsubmit %] name="edit_clinician" id="edit_clinician">

    <table>
        <tr>
            <th [% IF error_national_code %]class="error"[% END %]>National Code</th>
            <th [% IF error_name %]class="error"[% END %]>Surname, Initial(s)</th>
			<th [% IF error_referral_type_id %]class="error"[% END %]>Referral Type</th>
			<th [% IF error_active %]class="error"[% END %]>Active</th>
        </tr>

        <tr>
            <td>
                <input type="text" name="national_code" size="8"
                    value="[% data.national_code %]" />
             </td>
            <td>
                <input type="text" name="name" size="20" value="[% data.name %]" />
             </td>
            <td>
				<select name="referral_type_id">
				[% FOREACH type IN types %]
				  [% NEXT UNLESS type.prefix %]
                     <option value="[% type.id %]" [% 'selected' IF
                            type.id == data.referral_type_id %]>
                        [% type.description %]
                    </option>
			    [% END %]
				</select>
             </td>
            <td>
				<select name="active">
				[% FOREACH option IN ['yes', 'no'] %]
                     <option value="[% option %]" [% 'selected' IF option == ref.active %]>
                        [% option %]
                    </option>
			    [% END %]
				</select>
             </td>
            <td>
                [% site.html.submit %]
            </td>
        </tr>
    </table>
    </form>

    [% IF data.referrer_department.size %]
		<p class="bold indent">Belongs to:</p>
		
		<table class="indent">
			<tr>
				<td class="borderless">
				<th>Parent Organisation</th>
				<th>Org Code</th>
				<th>Department</th>
				<th>Active</th>
			</tr>
			[% FOREACH entry IN data.referrer_department; # PROCESS dumper.tt dump = entry.as_tree; %]
				<tr>
					<td>[% loop.count %]</td>
					<td>[% entry.parent_organisation.description %]</td>
					<td align="center">[% entry.parent_organisation.parent_code %]</td>
					<td>[% entry.hospital_department.display_name %]</td>
					<td>[% entry.is_active %]</td>
					<td>
						<a href="[% app_url %]/config/clinicians/location_edit/[% entry.id %]">edit</a>
					</td>
			[% END %]
		</table>
    [% END %]
    
    <p>[% site.html.back_button %]</p>


