<< | Index | >>
Memo
Words
Email ch.ODDB.org Report - Error: Fach- und Patienteninfo News - 01/2011
Check message
src/plugin/text_info.rb#fachinfo_news
def fachinfo_news agent=init_agent url = ODDB.config.text_info_newssource \ or raise 'please configure ODDB.config.text_info_newssource to proceed' ids = [] page = agent.get url ...
Check oddb.yml
...
text_info_searchform: same
text_info_newssource: different
@]
Next
src/plugin/text_info.rb#fachinfo_news
def fachinfo_news agent=init_agent url = ODDB.config.text_info_newssource \ or raise 'please configure ODDB.config.text_info_newssource to proceed' ids = [] page = agent.get url page.links.each do |link| if id = extract_fachinfo_id(link.href) ids.push [id, link.text.gsub(/;$/, '')] end end ids end
Notes
Next
src/plugin/text_info.rb#extract_fachinfo_id
def extract_fachinfo_id href fi_ptrn = /Monographie.aspx\?Id=([0-9A-Fa-f\-]{36}).*MonType=fi/u if match = fi_ptrn.match(href.to_s) match[1] end end
Notes
Memo
Memo
Experiment (test fachinfo_news method test.rb)
Result
masa@masa ~/work $ ruby test.rb [["0f23f0bd-7762-40e9-ac8e-39b2e04ca3dc", "Abilify\302\256 Injektionsl\303\266sung"], ["6a80a9c3-d194-405f-a8c4-0fdc21a72062", "Amavita ASS 500"], ["ab817525-5754-4118-8bc4-67ff30be4881", "Amavita Bisacodyl"], ["edcf285c-68f3-4113-9c37-717d3a70838a", "Amavita Cetirizin"], ["093cdd8b-593e-473a-8005-69481e56ba87", "Amavita Sport- und Rheumabalsam w\303\244rmend"], ...
Next
8. src/plugin/text_info.rb#fachinfo_news
7. src/plugin/text_info.rb#import_news
6. src/util/updater.rb#update_textinfo_news
5. src/util/updater.rb#update_fachinfo
4. src/util/updater.rb#run_random
3. src/util/oddbapp.rb#run_random_updater
2. src/util/oddbapp.rb#reset
1. src/util/oddbapp.rb#initialize
Notes
Algorithm
Check the current update process (fachinfo_news, etc.)
Experiment (get new Fachinformation list (get_fach.rb))
Check the source HTML
<div id="blockContentInner"><!--CONTENT:START--><p>Abilify® <br/>Abilify® Injektionslösung ...
Result
masa@masa ~/work $ ruby get_fachinfo.rb| "Abilify\302\256" "Abilify\302\256 Injektionsl\303\266sung" "Abseamed\302\256" "Aceril\302\256- mite" "AcetaPhos\302\256 750 mg" "Acimethin\302\256" ...
References
src/plugin/text_info#import_news
def import_news agent=init_agent old_news = old_fachinfo_news updates = true_news fachinfo_news(agent), old_news updates.reverse! indices, names = updates.transpose if names import_name names, agent log_news updates + old_news postprocess end !updates.empty? end
Next
src/plugin/text_info.rb#import_name
def import_name terms, agent=init_agent @search_term = terms.to_a.join ', ' terms.to_a.each do |term| @current_search = [:search_product, term] page = search_product term, agent import_products page, agent end end
Note
Next
src/plugin/text_info.txt#search_product
def search_product name, agent search 'rbPraeparat', name, agent end
Note
Next
src/plugin/text_info.rb#search
def search type, term, agent page = init_searchform agent form = page.form_with :name => 'frmSearchForm' unless type == 'rbPraeparat' ## default value, clicking leads to an error form.radiobutton_with(:value => type).click end form['txtSearch'] = term agent.submit form end
Note
Next
Memo
old_news = old_fachinfo_news updates = true_news fachinfo_news(agent), old_news
src/plugin/text_info.rb#init_searchform
def init_searchform agent url = ODDB.config.text_info_searchform \ or raise 'please configure ODDB.config.text_info_searchform to proceed' page = agent.get(url) form, = page.form_with :name => 'frmNutzungsbedingungen' if form if btn = form.button_with(:name => 'btnAkzeptieren') page = agent.submit form, btn end end page end
Note
Next
src/plugin/text_info.rb#import_products
def import_products page, agent fi_sources = identify_eventtargets page, /dtgFachinfo/ pi_sources = identify_eventtargets page, /dtgPatienteninfo/ form = page.form_with :name => /frmResult(Produkte|hForm)/ fi_sources.sort.each do |name, eventtarget| import_product name, agent, form, eventtarget, pi_sources[name] end end
Note
Next
src/plugin/text_info.rb#identify_eventtargets
def identify_eventtargets page, ptrn eventtargets = {} page.links_with(:href => ptrn).each do |link| eventtargets.store link.text, eventtarget(link.href) end eventtargets end
Note
Next
src/plugin/text_info.rb#eventtarget
def eventtarget string if match = /doPostBack\('([^']+)'.*\)/.match(string.to_s) match[1] end end
Note
Check the source html
Note
Next
src/plugin/text_info.rb#import_product
def import_product name, agent, form, fi_target, pi_target fi_paths, fi_flags = download_info :fachinfo, name, agent, form, fi_target if pi_target pi_paths, pi_flags = download_info :patinfo, name, agent, form, pi_target end update_product name, fi_paths, pi_paths || {}, fi_flags, pi_flags || {} end
Note
Next
src/plugin/text_info.rb#download_info
Experiment
src/plugin/text_info.rb#import_product
def import_product name, agent, form, fi_target, pi_target p "getin import_product" fi_paths, fi_flags = download_info :fachinfo, name, agent, form, fi_target print "fi_paths=" p fi_paths print "fi_flags=" p fi_flags exit if pi_target pi_paths, pi_flags = download_info :patinfo, name, agent, form, pi_target end update_product name, fi_paths, pi_paths || {}, fi_flags, pi_flags || {} end
Run
Run update_textinfo_news
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Updater.new(self).update_textinfo_news -> connection closed
Result
fi_paths={:de=>"/home/masa/ywesee/oddb.org/data/html/fachinfo/de/Abilify\302\256.html", :fr=>"/home/masa/ywesee/oddb.org/data/html/fachinfo/fr/Abilify\302\256.html"} fi_flags={:de=>:up_to_date, :fr=>:up_to_date}
Note
Next
src/plugin/text_info.rb#update_product
Note
Consideration
Experiment
src/plugin/text_info.rb#import_news
def import_news agent=init_agent
old_news = old_fachinfo_news
updates = true_news fachinfo_news(agent), old_news
updates.reverse!
indices, names = updates.transpose
names = ['Abilify']
if names
import_name names, agent
log_news updates + old_news
postprocess
end
!updates.empty?
end
Run
Run update_textinfo_news
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Updater.new(self).update_textinfo_news -> connection closed
Result
Searched for Abilify Stored 0 Fachinfos Ignored 0 Pseudo-Fachinfos Ignored 0 up-to-date Fachinfo-Texts Stored 0 Patinfos Ignored 0 up-to-date Patinfo-Texts Checked 0 companies Unknown Iks-Numbers: 0 Fachinfos without iksnrs: 0 Session failures: 0 Download errors: 0 Parse Errors: 2 druby://localhost:10002 - #<Errno::ECONNREFUSED: Connection refused - connect(2)> druby://localhost:10002 - #<Errno::ECONNREFUSED: Connection refused - connect(2)>
Note
masa@masa ~/ywesee/oddb.org $ grep -r 10002 src src/util/oddbconfig.rb: FIPARSE_URI = "druby://localhost:10002"