Skip to content

Commit

Permalink
Added combined search
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Feb 17, 2015
1 parent 3745cc6 commit 9ddf533
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
12 changes: 12 additions & 0 deletions spec/searchbar_spec.rb
Expand Up @@ -244,6 +244,18 @@ def enter_fachinfo_search
false.should == true
end

it "should be possible to find Budenofalk and Budesonid Sandoz via combined search" do
@browser.link(:name, 'drugs').click
@browser.select_list(:name, "search_type").select("Preisvergleich und Inhaltsstoff")
@browser.text_field(:name, "search_query").value = "Budesonid"
@browser.button(:name, 'search').click
text = @browser.text.clone
text.should_not match LeeresResult
text.should match('Budesonid Sandoz') # by price
text.should match('Budenofalk') # by component
end unless ['just-medical'].index(Flavor)


after :all do
@browser.close
end
Expand Down
4 changes: 3 additions & 1 deletion src/custom/lookandfeelbase.rb
Expand Up @@ -1513,6 +1513,7 @@ def google_analytics_token
:square_patent => 'PS',
:square_phytotherapy => 'Ph',
:square_vaccine => 'I/B',
:st_combined => 'Preisvergleich und Inhaltsstoff',
:st_company => 'Zulassungsinhaber',
:st_indication => 'Anwendung',
:st_oddb => 'Preisvergleich',
Expand Down Expand Up @@ -2919,7 +2920,7 @@ def google_analytics_token
:square_patent => 'PP',
:square_phytotherapy => 'Ph',
:square_vaccine => 'V/S',
:st_company => 'Titulaire de l\'Autorisation',
:st_combined => 'Comparaison des prix et Composant',
:st_indication => 'Application',
:st_oddb => 'Comparaison des prix',
:st_unwanted_effect => 'Effet indésirable',
Expand Down Expand Up @@ -4200,6 +4201,7 @@ def google_analytics_token
:square_phytotherapy => 'Ph',
:square_vaccine => 'V/S',
:st_company => 'Registration owner',
:st_combined => 'Price comparison and Component',
:st_indication => 'Indication',
:st_oddb => 'Price comparison',
:st_sequence => 'Brand name',
Expand Down
2 changes: 1 addition & 1 deletion src/custom/lookandfeelwrapper.rb
Expand Up @@ -399,7 +399,7 @@ def result_list_components
}
end
def search_type_selection
['st_oddb']
['st_combined']
end
def zones
[
Expand Down
2 changes: 2 additions & 0 deletions src/state/global.rb
Expand Up @@ -864,6 +864,8 @@ def search
alias :result :search
def _search_drugs(query, stype)
case stype
when 'st_combined'
@session.search_combined(query, @session.language)
when 'st_sequence'
@session.search_exact_sequence(query)
when 'st_substance'
Expand Down
11 changes: 11 additions & 0 deletions src/util/oddbapp.rb
Expand Up @@ -1083,6 +1083,17 @@ def search_exact_sequence(query)
sequences = search_sequences(query)
_search_exact_classified_result(sequences, :sequence)
end
def search_combined(query, lang)
result = search_oddb(query, lang)
result_substances = search_exact_substance(query)
result_substances.atc_classes.each{
|atc|
result.atc_classes << atc unless result.atc_classes.index(atc)
}
result.search_type = :combined
result
end

def search_exact_substance(query)
sequences = ODBA.cache.\
retrieve_from_index('substance_index_sequence', query)
Expand Down
3 changes: 2 additions & 1 deletion src/util/validator.rb
Expand Up @@ -80,7 +80,8 @@ class Validator < SBSM::Validator
:search_type => [
'st_oddb', 'st_sequence', 'st_substance',
'st_company', 'st_indication', 'st_interaction',
'st_unwanted_effect', 'st_registration', 'st_pharmacode'
'st_unwanted_effect', 'st_registration', 'st_pharmacode',
'st_combined'
],
:fachinfo_search_type => [
'fi_usage', 'fi_interactions', 'fi_unwanted_effects'
Expand Down
9 changes: 7 additions & 2 deletions test/test_util/oddbapp.rb
Expand Up @@ -811,14 +811,19 @@ def test_search_exact_sequence
expected = ODDB::SearchResult.new
expected.atc_classes = []
expected.search_type = :sequence
#assert_equal(expected, @app.search_exact_sequence('query'))
assert(same?(expected, @app.search_exact_sequence('query')))
end
def test_search_combined
expected = ODDB::SearchResult.new
expected.atc_classes = []
expected.search_type = :combined
result = @app.search_combined('query', 'lang')
assert(same?(expected, result), "Result #{result.inspect} should match #{expected.inspect}" )
end
def test_search_exact_substance
expected = ODDB::SearchResult.new
expected.atc_classes = []
expected.search_type = :substance
#assert_equal(expected, @app.search_exact_substance('query'))
assert(same?(expected, @app.search_exact_substance('query')))
end
def test_search_pharmacies
Expand Down

0 comments on commit 9ddf533

Please sign in to comment.