<!-- BEGIN [% component.name %] -->

	[% PROCESS site/autosuggest.tt %]
    <script type="text/javascript">
        jQuery( function() {    
            $("#is_valid_date_dob_day").Watermark("dd");
            $("#is_valid_date_dob_month").Watermark("mm");
            $("#is_valid_date_dob_year").Watermark("yyyy");
            $("#is_valid_date_req_day").Watermark("dd");
            $("#is_valid_date_req_month").Watermark("mm");
            $("#is_valid_date_req_year").Watermark("yyyy");
        } );
    </script>
  <div class="indent">
  <table>
  	<tr>
		<td class="label">Last Name:</td>
		<td class="content">
            <input class="field" type="text" name="last_name" size="40"
                [% site.html.on_focus %] /> [% error_last_name %]
			</td>
		</tr>

		<tr>
			<td class="label">First Name:</td>
            <td class="content">
                <input class="field" type="text" name="first_name" size="40"
                [% site.html.on_focus %] /> [% error_first_name %]
			</td>
		</tr>

		<tr>
			<td class="label">NHS Number:</td>
			<td class="content">
				<input class="field" type="text" name="nhs_number" size="12"
                    id="is_valid_nhsno"
                    [% IF c.cfg('use_cgi_ajax') %]
                    onChange="do_ajax(['is_valid_nhsno'], ['bad_nhsno']); return true;"
                    [% END %] [% site.html.on_focus %] />
                [% error_nhs_number %]
                <span class="ajax_error"><em id="bad_nhsno"></em></span>

                <span class="box">Patient No:</span>
				<input class="field" type="text" name="unit_number" size="12"
                    [% site.html.on_focus %] /> [% error_unit_number %]
			</td>
		</tr>

        [% BLOCK validate_dob; IF c.cfg('use_cgi_ajax') %]
            onChange="do_ajax(
				[
                    'is_valid_date_dob_day',
                    'is_valid_date_dob_month',
                    'is_valid_date_dob_year'
                ],
                ['bad_dob']
			); return true;"
        [% END; END %]

		<tr>
            [% SET class = error_dob_year || error_dob_day
                ? 'input_error' : 'field' %]
			<td class="label">DoB:</td>
            <td class="content">
                <input type="text" name="dob_day" size="2" maxlength="2"
                    id="is_valid_date_dob_day" [% PROCESS validate_dob %]
                    class="[% class %]" [% site.html.on_focus %] />

				<input type="text" name="dob_month" size="2" maxlength="2" 
                    id="is_valid_date_dob_month" [% PROCESS validate_dob %]
                    class="[% class %]" [% site.html.on_focus %] />

				<input type="text" name="dob_year" size="4" maxlength="4"
                    id="is_valid_date_dob_year" [% PROCESS validate_dob %]
                    class="[% class %]" [% site.html.on_focus %] />
                
				[% UNLESS error_dob_day || error_dob_year # set if date invalid %]
					<span class="ajax_error"><em id="bad_dob"></em></span>
				[% END %]
                
                [% error_dob_day || error_dob_year # set if date invalid %]
			</td>
		</tr>

        <tr>
            <td colspan="2" class="borderless">&nbsp;</td>
        </tr>

		<tr>
    	<td class="label">Lab No:</td>
            <td class="content">
				<input class="field" type="text" name="lab_number" size="12"
                    [% site.html.on_focus %] />[% error_lab_number %]

				<span class="box">Specimen:</span>
                <input class="field" type="text" name="specimen_code" size="5"
					id="is_valid_specimen"
                [% IF c.cfg('use_cgi_ajax') %]
                    onChange="do_ajax(['is_valid_specimen'], ['bad_specimen']); return true;"
                [% END %] [% site.html.on_focus %] />[% error_specimen_code %]
                <span class="ajax_error"><em id="bad_specimen"></em></span>
			</td>
		</tr>

        [% BLOCK validate_date; IF c.cfg('use_cgi_ajax') %]
            onChange="do_ajax(
				[
                    'is_valid_date_req_day',
                    'is_valid_date_req_month',
                    'is_valid_date_req_year'
                ],
                ['bad_date']
			); return true;"
        [% END; END %]
		<tr>
            [% SET class = error_request_year || error_request_day
                ? 'input_error' : 'field' %]
			<td class="label">Request date:</td>
            <td class="content">
                <input type="text" name="request_day" size="2" maxlength="2"
                    id="is_valid_date_req_day" [% PROCESS validate_date %] 
                    class="[% class %]" [% site.html.on_focus %] />

				<input type="text" name="request_month" size="2" maxlength="2"
                    id="is_valid_date_req_month" [% PROCESS validate_date %]
                    class="[% class %]" [% site.html.on_focus %] />

				<input type="text" name="request_year" size="4" maxlength="4"
                    id="is_valid_date_req_year"	[% PROCESS validate_date %] 
                    class="[% class %]" [% site.html.on_focus %] />
                
				[% UNLESS error_request_day || error_request_year # set if date invalid %]
					<span class="ajax_error"><em id="bad_date"></em></span>
				[% END %]
                
                [% error_request_day || error_request_year # set if date invalid %]
                
                <div style="display: inline; float: right; margin: 0 30px">
                    <input type="radio" name="date_extend" value="all_before" />
                        <span class="acronym" title="and all before">&le;</span>
                        <b>OR</b>
                    <input type="radio" name="date_extend" value="all_after" />
                        <span class="acronym" title="and all after">&ge;</span>
                </div>
			</td>
		</tr>

		<tr>
			<td class="label">Source:</td>
			<td class="content">
				<input style="width: 300px" type="text" id="location_name" />
				<input type="hidden" id="source_id" name="referral_source_id" />
			</td>
		</tr>

		<tr>
            <td class="label">Referrer:</td>
            <td class="content">
            <input class="field" type="text" name="referrer_name" size="30"
                [% site.html.on_focus %] />[% error_referrer_name %]
			</td>
		</tr>
        
        <tr>
            <td colspan="2" class="borderless">&nbsp;</td>
        </tr>

      [% IF trials.size %]
		<tr>
            <td class="label">Trial/study:</td>
            <td class="content">
				<select name="trial_id" id="trial_id" [% site.html.on_focus %]>
					<option value="">&nbsp;</option>
					[% FOREACH trial IN trials %]
					<option value="[% trial.id %]">
						[% trial.trial_name | html %]
					</option>
					[% END %]
				</select>

				<span class="box">Trial No:</span>
                <input class="field" type="text" name="trial_number" size="12"
                    [% site.html.on_focus %] />[% error_trial_number %]
			</td>
		</tr>
      [% END %]

        <tr>
            <td class="label">Urgent:</td>
            <td class="content">
                <input type="checkbox" name="urgent" value="1" />
                <span class="box">Copy required:</span>
                <input type="checkbox" name="copy_to" value="1" />
                <span class="box">Private:</span>
                <input type="checkbox" name="private" value="1" />
                <span class="info" style="font-size: smaller">
                    &#171; select 1 only
                </span>
            </td>
        </tr>

		<tr>
            <td class="label">External Ref:</td>
            <td class="content">
                <input class="field" type="text" name="external_reference" size="30"
                    [% site.html.on_focus %] />[% error_block_ref %]
			</td>
		</tr>

	</table>

	</div>
<!-- END [% component.name %] -->
