Skip to content

Commit

Permalink
Sort results by ATC-Code
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Dec 14, 2015
1 parent 8991ac5 commit bacdc16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions spec/evidentia_spec.rb
Expand Up @@ -45,6 +45,16 @@ def get_drugs_as_arra_of_strings
@browser.trs.find_all{|x| x.elements[1].title.eql?('Fachinformation') }.collect{|x| x.text.clone}
end

it "should list C09DB02 before C09DX03 when looking for Sevikar" do
select_product_by_trademark('Sevikar')
drugs = get_drugs_as_arra_of_strings
text = @browser.text.clone
expected_order = [ 'C09DB02', 'C09DX03']
res = expected_order.collect{|x| text.index(x)}
expect(res.sort).to eql res
end


# Reasoning: Levetiracetam is the active substance, not the trademark name
it "should list Keppra at the top when searching for Levetiracetam" do
select_product_by_trademark('Levetiracetam')
Expand Down
4 changes: 2 additions & 2 deletions src/view/drugs/resultlist.rb
Expand Up @@ -312,10 +312,10 @@ def compose_list(model=@model, offset=[0,0])
model = @session.state.pages[page]
end
end

code = @session.persistent_user_input(:code)
if model
model.each { |atc|
model.sort{|x,y| x.code <=> y.code}.each { |atc|
compose_subheader(atc, offset)
offset = resolve_offset(offset, self::class::OFFSET_STEP)
if(show_packages? || code == atc.code)
Expand Down

0 comments on commit bacdc16

Please sign in to comment.