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

	[% PROCESS site/autosuggest.tt varname = 'hospital' %]

	[% new_clinician_dfv_js %]

  [% PROCESS admin/referral_nav.tt page = 'clinicians' %]

	<h2 align="center">Clinicians</h2>

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

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

    <p class="title">
		[% div_name = 'new'; INCLUDE site/snippets/toggleview.tt %]
		Add new entry
	</p>

	<div class="[% dfv_errors ? 'visible' : 'itemhidden' %]" id="[% div_name %]">
	<div class="indent">			
    <form method="get" action="[% app_url %]/config/clinicians/add_new"
		name="new_clinicians" id="new_clinicians" [% new_clinician_onsubmit %]>

	[% PROCESS site/lookup.tt type = 'clinician', fname = 'popup2' %]

	<table>
		<tr>
			<td class="label">Designation:</td>
			<td>
				<select name="prefix">
					<option value="">-- select one --</option>
				[%- FOREACH entry IN referral_types -%]
					[%- NEXT UNLESS entry.prefix -%]
					<option value="[% entry.prefix -%]"
						[%- 'selected' IF entry.prefix == c.query.param('prefix') -%]>
						[%- entry.description | html -%]
					</option>
				[% END %]
				</select>
				[% error_prefix %]
			</td>
		</tr>

		<tr>
			<td class="label">Code:</td>
			<td>
			  [% PROCESS site/ajax_input.tt field = 'national_code' %]
				[% error_national_code %]
			</td>
		</tr>

		<tr>
			<td class="label">Surname:</td>
			<td>
				<input type="text" name="surname" value="[% c.query.param('surname') %]" />
				[% error_surname %]
			</td>
		</tr>

		<tr>
			<td class="label">Initials:</td>
			<td>
				[% FOREACH i IN [1..4]; inits = 'initials_' _ i %]
					<input type="text" name="[% inits %]" size="1" maxlength="1"
						value="[% c.query.param(inits) %]" />
				[% END %]
				[% IF error_initials_1; error_initials_1; # can only list 1st one %]
				[% ELSE %]enter up to 4 initials[% END %]
			</td>
		</tr>

		<tr>
			<td class="label">Hospital:</td>
			<td class="search_bar">
				<input style="width: 300px" type="text" id="location_name" name="_display_name"
					value="[% c.query.param('_display_name') %]"/>
				<input type="hidden" id="source_id" name="referral_source_id"
					value="[% c.query.param('referral_source_id') %]" />
                [% IF error_referral_source_id %]
                    [% error_referral_source_id %]
                [% ELSE %]
                    [ <a href="[% app_url %]/config/referral-sources">new</a> ]
                [% END %]
            </td>
		</tr>

		<tr>
			<td class="label">Department:</td>
			<td>
				<select name="hospital_department_code">
					<option value="">-- select one --</option>
				[% FOREACH department IN departments %]
					<option value="[% department.id %]"
							[% 'selected' IF department.id == c.query.param('hospital_department_code') %]>
						[% department.display_name | html %]
					</option>
				[% END %]
				</select>
				[% error_hospital_department_code %]
			</td>
		</tr>

        <tr>
            <td class="borderless" colspan="2" align="center">[% site.html.submit %]</td>
        </tr>
	</table>
	</form>
	</div>
	</div>

	<hr />
	
	<p class="title">Search for an existing clinician:</p>
	<div class="indent">
		[% PROCESS search/referrer_search.tt referrer_type = 'clinicians' %]		
	</div>
  
