<!-- BEGIN simple_sql.tt -->
[% # requires corresponding entry in M::Roles::Query::_build_search_fields_map()
  options = { 
	'Clinical details'	=>	'clinical_details',
	 Comment 			=> 	'comment',
	 Diagnosis	        => 	'diagnoses.name',
	'First name' 		=> 	'first_name',
	'Gender'            =>  'gender',
	'Gross description'	=>	'detail',
	'Last name'			=>	'last_name',
	 Location			=>	'display_name',
	'NHS number'        =>  'nhs_number',
	'Presentation'		=>	'screens.description', 
	 Referrer   		=> 	'referrers.name',
	'Results summary'   =>	'results_summary',
	 Specimen			=>	'sample_code',
	'Trial/study'       =>  'trial_name',
	'Unit number'		=> 	'unit_number', 
	 
#	 Reporter			=> 	'report_by', # more complex - needs a 2-col search
#	 Screener			=>	'screener', # - " -
#	'New diagnosis'		=> 	'new_diagnosis', # need to know ENUM opts
#	'Molecular result'	=> 	'molecular_result', # combined into 'results summary'
#   'Flow result'		=> 	'flow_result', # - " -
#	'FISH result' 		=>  'fish_result', # - " - 
#	'Genetics result' 	=> 	'genetics_result', # - " -
  }

  admin_options = {
	'Patient ID'		=> 	'patients.id',
	'Request ID'        =>  'requests.id',  
  }
%]

	[% PROCESS site/popup.tt height=800, width=650, top=50 # defines onclick_event %]
	<p><i>Simple SQL Query</i>
		<span>
			[ <a href="/docs/help/simplesql.html" [% onclick_event %]>Help</a> ]
		</span>
		[% div_name = 'simple_sql'; INCLUDE site/snippets/toggleview.tt %]
    </p>

    [% class = c.query.param('sql_simple_search') ? 'visible' : 'itemhidden' %]
     <div id="[% div_name %]" class="[% class %]">		
        [% IF dfv_errors; # PROCESS dumper.tt dump = c.stash.errs %]
            <p class="error">Error - one or more fields missing:</p>
        [% END %]
      <table class="indent">
        <tr>
          <td>
            Field:
            <select name="sql_simple_search" [% on_focus %]>
              <option value="">--</option>
				[% FOREACH option IN options %]
              	<option value="[% option.value %]">[% option.key %]</option>
				[% END %]
				[% IF c.user_can('do_admin') %]
                    <option disabled>--</option>
					[% FOREACH option IN admin_options %]
                    <option value="[% option.value %]">[% option.key %]</option>
				[% END; END %]
            </select>
          </td>

          <td>
            Logic:
            <select name="logic" [% on_focus %]>
              <option value="">-- </option>
              <option value="BEGINS">
                Begins with
              </option>
              <option value="CONTAINS">
                Contains
              </option>
			  [% IF any_point_having_it # always returns > max_no_of_hits %]
              <option value="LACKS">
                Lacks
              </option>
			  [% END %]
              <option value="ENDS">
                Ends with
              </option>
              <option value="MATCHES">
                Matches
              </option>
            </select>
          </td>

          <td>
            Term(s):
              <input class="field" type="text" name="kwd" size="30"
                    [% site.html.on_focus %] />
          </td>
        </tr>
      </table>
    </div>
<!-- END simple_sql.tt -->