[% META title = 'Patient &raquo; Merge Patients' -%]

<!-- BEGIN admin/patient/merge/default.tt -->
    [% # PROCESS admin/user_nav.tt page = 'user_list' %]
	[% # PROCESS dumper.tt dump = records %]
	[% # PROCESS dumper.tt dump = report_map %]
	[% # PROCESS dumper.tt dump = patients %]
	
	<h2 class="header">Merge Patient Records</h2>
	
    [% IF dfv_errors %]
        <p class="error">[% c.config('msg').dfv_errors %]
		require at least one entry from last name, unit number or dob</p>
    [% END %]

	[% INCLUDE site/snippets/help.tt file = 'patientmerge' %]

   <form method="post" action="[% app_url %]/admin/patient_merge/search"
		name="select" id="select">
		<table class="indent">
			<tr>
				<td class="label"> Last Name:</td>
				<td class="content">
					<input type="text" name="last_name" tabindex="1"
						value="[% c.query.param('last_name') %]" />
					[% error_last_name %]
				</td>
				<td rowspan="4" class="borderless">
					<input type="submit" name=".submit" value="Find" />
					<a href="[% app_url %]/admin/patient_merge">RESET</a>
				</td>
			</tr>
			<tr>
				<td class="label">First Name:</td>
				<td class="content">
					<input type="text" name="first_name" tabindex="2"
					value="[% c.query.param('first_name') %]" />
			   [% error_first_name %]
				</td>
			</tr>
			<tr>
				<td class="label">Unit number:</td>
				<td class="content">
					<input type="text" name="unit_number" tabindex="3"
					value="[% c.query.param('unit_number') %]" />
			   [% error_unit_number %]
				</td>
			</tr>
			
        [% BLOCK validate_date; IF c.cfg('use_cgi_ajax') %]
            onChange="do_ajax(
				['is_valid_date_day','is_valid_date_month','is_valid_date_year'],
                ['bad_date']
			); return true;"
        [% END; END %]

		<tr>
            [% SET class = error_year || error_day ? 'input_error' : 'field' %]
			<td class="label">DoB:</td>
            <td class="content">
                <input type="text" name="dob_day" size="2" id="is_valid_date_day"
					[% PROCESS validate_date %] maxlength="2" class="[% class %]"
					   value="[% c.query.param('dob_day') %]" [% site.html.on_focus %]
                        tabindex="4" />

				<input type="text" name="dob_month" size="2" id="is_valid_date_month"
					[% PROCESS validate_date %] maxlength="2" class="[% class %]"
					   value="[% c.query.param('dob_month') %]" [% site.html.on_focus %]
                        tabindex="5" />

				<input type="text" name="dob_year" size="4" id="is_valid_date_year"
					[% PROCESS validate_date %] maxlength="4" class="[% class %]"
					   value="[% c.query.param('dob_year') %]" [% site.html.on_focus %]
                        tabindex="6" />
				[% UNLESS error_day || error_year # set if date invalid %]
					<span class="ajax_error"><em id="bad_date">dd-mm-yyyy</em></span>
				[% END %]
                [% error_day || error_year # set if date invalid %]
			</td>
		</tr>
		</table>
	</form>
   
   [% IF records.size || orphans.size; INCLUDE admin/patient/merge/list.tt; END %]
   
   [% INCLUDE site/field_focus.tt form_name = 'select' field_name = 'last_name' %]
<!-- END admin/patient/merge/default.tt -->

