<!-- BEGIN [% component.name %] -->
	<form class="printHide" action="[% c.query.url(path_info=1) %]" method="get">
	  <input type="hidden" name="status_query" value="[% status_query %]" />
      <input type="hidden" name="duration" value="[% duration %]" />

	  <div class="bold">Referral source filter: [% site.html.go_btn %]</div>
        <div style="height: 3px">&nbsp;</div>
        [% # get all referral locations in worklist:
            locations = {};
            FOREACH r IN requests; # INCLUDE dumper.tt dump = r.as_tree;
                location = r.patient_case.referral_source.display_name;
                DEFAULT locations.${location} = 0; # initialise on 1st occurence
                locations.${location} = locations.${location} + 1;
            END; # INCLUDE dumper.tt dump = locations;
        %]

	  <div class="indent">
        [% FOREACH l IN locations;
            location = l.key; n = l.value;
            class = c.query.param('location_filter').match("^${location}$")
                ? 'highlight' : 'normal';
        %]
		<div>
            <input type="radio" name="location_filter" value="[% location %]"
                id="[% location.remove('\W+') %]" [% 'checked' IF class.match('highlight') %] />
            <label for="[% location.remove('\W+') %]" class="[% class %]">
                [% location %] [[% n %]]
            </label>
		 </div>
        [% END %]

	  [% IF c.query.param('location_filter'); # no point allowing 'all' if not already filtered
		  class = c.query.param('location_filter').match('all')
                ? 'highlight' : 'normal';
       %]
		<div>
			<input type="radio" name="location_filter" value="all"
			  id="all_locations" [% 'checked' IF class.match('highlight') %] />
            <label for="all_locations" class="[% class %]">
                All locations [[% requests.size %]]
            </label>
		</div>
	  [% END %]

      </div>
	</form>

   	<div style="height: 10px">&nbsp;</div>
<!-- END [% component.name %] -->
