Permalink
Browse files

Initial commit for searching human events before creating assessment …

…event
  • Loading branch information...
1 parent be6a168 commit 39538de44a9b3b9ae68f228dd16710cd17757b09 @bbuchalter bbuchalter committed May 7, 2012
@@ -23,6 +23,7 @@ en:
search_normal_case: "Search"
welcome_message: "Welcome to TriSano"
new_cmr: "NEW CMR"
+ new_ae: "NEW AE"
people: "PEOPLE"
places: "PLACES"
settings: "SETTINGS"
@@ -74,7 +75,7 @@ en:
copyright: "Copyright © 2011 Collaborative Software Foundation"
save_button_help: "Click here to enable the save buttons if they are grayed out when they shouldn't be."
- before_create: "Before creating a new morbidity event, please search for the person in question."
+ before_create: "Before creating a new {{type}}, please search for the person in question."
use_starts_with: "Use starts with search"
no_results: "No results"
start_a_cmr: "Start a CMR with the criteria you searched on"
@@ -774,6 +775,7 @@ en:
encounter_events: "Encounter Events"
same_as_above: "Same as above"
new_cmr_normal_case: "New CMR"
+ new_ae_normal_case: "New AE"
new_morbidity_event: "New Morbidity Event"
view_morbidity_event_of: "View Morbidity Event: {{name}}"
view_morbidity_event: "View Morbidity Event"
@@ -62,7 +62,7 @@ test:
collaborate: "xCollaborate"
copyright: "xCopyright © 2011 Collaborative Software Foundation"
- before_create: "xBefore creating a new morbidity event, please search for the person in question."
+ before_create: "xBefore creating a new {{type}}, please search for the person in question."
use_starts_with: "xUse starts with search"
no_results: "xNo results"
start_a_cmr: "xStart a CMR with the criteria you searched on"
@@ -0,0 +1,37 @@
+# Copyright (C) 2007, 2008, 2009, 2010, 2011 The Collaborative Software Foundation
+#
+# This file is part of TriSano.
+#
+# TriSano is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License,
+# or (at your option) any later version.
+#
+# TriSano is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with TriSano. If not, see http://www.gnu.org/licenses/agpl-3.0.txt.
+
+class AssessmentEventsController < EventsController
+ include EventsHelper
+
+ def event_search
+ unless User.current_user.is_entitled_to?(:view_event)
+ render :partial => 'events/permission_denied', :layout => true, :locals => { :reason => t("no_event_view_privs") }, :status => 403 and return
+ end
+
+ @search_form = NameAndBirthdateSearchForm.new(params)
+
+ if @search_form.valid?
+ if @search_form.has_search_criteria?
+ logger.debug "S@search_form.to_hash = #{@search_form.to_hash.inspect}"
+ @results = HumanEvent.find_by_name_and_bdate(@search_form.to_hash).paginate(:page => params[:page], :per_page => params[:per_page] || 25)
+ end
+ else
+ render :action => :event_search, :status => :unprocessable_entity
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module AssessmentEventsHelper
+end
@@ -126,6 +126,7 @@ def main_menu_items
returning MenuArray.new do |items|
if user.is_entitled_to? :create_event
items << {:link => event_search_cmrs_path, :t => :new_cmr}
+ items << {:link => event_search_ae_path, :t => :new_ae}
end
if user.is_entitled_to? :manage_staged_message, :write_staged_message
items << {
@@ -0,0 +1,72 @@
+=error_messages_for(:search_form, :header_message => t(:invalid_search_criteria))
+
+%h3=t('before_create', :type => "assessment event")
+- form_tag event_search_cmrs_path, :method => :get do
+
+ %span.horiz
+ = label_tag :last_name, t('last_name')
+ = text_field_tag(:last_name, @search_form.last_name)
+
+ %span.horiz
+ = label_tag :first_name, t('first_name')
+ = text_field_tag(:first_name, @search_form.first_name)
+
+ %span.horiz
+ = label_tag :birth_date, t('birth_date')
+ = birthdate_select_tag(:birth_date, @search_form.birth_date)
+
+ %span.horiz
+ %label=t "items_per_page"
+ - page_options = %w(25 50 75 100).collect {|c| "<option#{c == params[:per_page] ? ' selected="selected" ' : ''}>#{c}</option>"}.join
+ =select_tag('per_page', page_options)
+
+ %span.horiz
+ = label_tag "&nbsp;"
+ = submit_tag t('search_normal_case')
+
+ %span.vert
+ = label_tag "&nbsp;"
+ = labeled_check_box_tag(:use_starts_with_search, t('use_starts_with'))
+
+ %span.vert-break
+
+%br
+
+- if (defined? @people or defined? @results) and User.current_user.is_entitled_to?(:create_event)
+ %div
+ = link_to(t("start_a_cmr"), new_cmr_path(:from_search => "1", :first_name => params[:first_name], :last_name => params[:last_name], :birth_date => params[:birth_date]), {:id => "start_cmr"})
+
+- if defined? @results
+ -if @results.empty?
+ %b=t('no_results')
+ -else
+
+
+ -if @results.length >= 500
+ %p{'style' => 'color: #C00'} Only first 500 results will be shown
+
+
+ %p
+ =page_entries_info @results, :entry_name => "result"
+ =will_paginate @results
+
+ %table.list
+ %tr
+ %th=t('name')
+ %th=t('birth_date')
+ %th=t('gender')
+ %th=t('event_type')
+ %th=t('jurisdiction')
+ %th=t('created_date')
+ %th=t('disease')
+ %th=t('cmr_actions')
+ %th=t('entity_actions')
+ =new_cmr_search_results(@results)
+
+ %p
+ =page_entries_info @results, :entry_name => "result"
+ =will_paginate @results
+
+
+ - if (defined? @people or defined? @results) and User.current_user.is_entitled_to?(:create_event)
+ = link_to(t("start_a_cmr"), new_cmr_path(:from_search => "1", :first_name => params[:first_name], :last_name => params[:last_name], :birth_date => params[:birth_date]), {:id => "start_cmr"})
@@ -1,6 +1,6 @@
=error_messages_for(:search_form, :header_message => t(:invalid_search_criteria))
-%h3=t('before_create')
+%h3=t('before_create', :type => "morbidity event")
- form_tag event_search_cmrs_path, :method => :get do
%span.horiz
View
@@ -137,6 +137,13 @@
map.resources :people
+ map.resources :ae,
+ :controller => :assessment_events,
+ :collection => {
+ :event_search => :get
+ }
+
+
map.resources :cmrs,
:controller => :morbidity_events,
:collection => {
@@ -0,0 +1,12 @@
+Feature: Searching for existing people or events before adding a AE
+
+ So that I can avoid duplicate data entry
+ As an investigator
+ I want to search for existing people or events before adding a new AE
+
+ Scenario: Clicking 'NEW AE' link brings up a search form
+ Given I am logged in as a super user
+ When I click the "NEW AE" link
+ Then I should see an assessment event search form
+ And I should not see a link to enter a new AE
+
@@ -4,10 +4,10 @@ Feature: Searching for existing people or events before adding a CMR
As an investigator
I want to search for existing people or events before adding a new CMR
- Scenario: Clicking 'NEW CMR' link brings up a search form
+ Scenario: Clicking 'NEW CMR' link brings up a morbidity event search form
Given I am logged in as a super user
When I click the "NEW CMR" link
- Then I should see a search form
+ Then I should see a morbidity event search form
And I should not see a link to enter a new CMR
Scenario: Searching for a person uses soundex
@@ -0,0 +1,25 @@
+# Copyright (C) 2007, 2008, 2009, 2010, 2011 The Collaborative Software Foundation
+#
+# This file is part of TriSano.
+#
+# TriSano is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License,
+# or (at your option) any later version.
+#
+# TriSano is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with TriSano. If not, see http://www.gnu.org/licenses/agpl-3.0.txt.
+
+Then /^I should see an assessment event search form$/ do
+ response.should have_selector("form[method='get'][action='#{event_search_ae_path}']")
+ field_labeled("Last name").value.should be_nil
+end
+
+Then /^I should not see a link to enter a new AE$/ do
+ response.should_not have_selector("a[href='#{new_ae_path}']")
+end
@@ -129,7 +129,7 @@
click_button "Search"
end
-Then /^I should see a search form$/ do
+Then /^I should see a morbidity event search form$/ do
response.should have_selector("form[method='get'][action='#{event_search_cmrs_path}']")
field_labeled("Last name").value.should be_nil
end

0 comments on commit 39538de

Please sign in to comment.