view · edit · sidebar · attach · print · history

Index>

20141020-fix-invalid-date-in-TextInfoPlugin

Summary

  • Fix ArgumentError invalid date in ODDB::TextInfoPlugin

Commits

Index

Keep in Mind
  • Fix dojo error http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/#forgot-dom-ready
  • I removed on May-27 tests for ix_registrationss, fix_sequences, fix_compositions, fix_packages from test/test_plugin/swissmedic.rb,as he could not find any references for them in the src code. Did I erroneously remove stuff when cleaning up the swissmedic import earlier?
  • The whole test for older/newer Packages must be adapted to xlsx. One must compare the rows (e.g. by creating csv files) and do the same stuff in xlsx!

---

import import medical doctors from BAG

Continuing work from last week.

As medregom uses Javascript I will have to use watir to scrap the data. Played around interactively till I found the nokogiri css to find the relevant items. Code looks like this

    browser = Watir::Browser.start 'http://www.medregom.admin.ch/de/Suche/Detail/?gln=7601000813282&vorname=Dora+Carmela&name=ABANTO+PAYER'
    doc = Nokogiri::HTML(home.body)
    doc.xpath('//p/text()').text
# => "Nationalität: Schweiz (CH)GLN: 7601000813282"
    doc.css('li[class="address-item active"]').text
#=> "A.\n\t\t\t  zahnarztzentrum.chBahnhofstrasse 415000 AarauTelefon: 062 832 32 01Fax: 062 832 32 01"
  # doc.css('li[class="address-item"]').text
#=> "B.\n\t\t\t  CABINET DENTAIRE VRBICA VESELINAvenue du Bois-De-La-Chapelle 991213 OnexTelefon: 022.793.29.60Fax: 022.793.29.63"
    doc.css('h4').last.text # Addressen
 doc.css('div[id="resultContainer"]').text
#=> "\n\t\t\n\t\t\tlnkDetail\n\t\t\t\n\t\t\t\tTrefferliste\n\t\t\t\t\tMerkliste \n\t\t\t\tDora Carmela ABANTO PAYER\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\tDie Suche ergab 76122  Treffer, aber es werden nur die ersten 100 angezeigt. Bitte grenzen Sie die Suche ein!\n\t\t\t\n\t\t\tABANTO PAYER\n\t\t\tDora Carmela\n\t\t\tAvenue du Bois-De-La-Chapelle 99Bahnhofstrasse 41\n\t\t\t12135000\n\t\t\tOnexAarau\n\t\t\tZahnärztin/Zahnarzt \n\t\t\t\n\t\t\t\n\t\t\t\t \n\t\t\t\n\t\t\t\n\t\t\n\t\t\t\tNachname\n\t\t\t\n\t\t\t\n\t\t\t\tVorname\n\t\t\t\n\t\t\t\n\t\t\t\tStrasse\n\t\t\t\n\t\t\t\n\t\t\t\tPLZ\n\t\t\t\n\t\t\t\n\t\t\t\tOrt\n\t\t\t\n\t\t\t\n\t\t\t\tBeruf\n\t\t\t\n\t\t\t\n\t\t\t\tWeiterbildung(en)\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\t\t\n\t\t\t\t\tTreffer 1 von 100\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\tzurück\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\tweiter\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\t\tDie Suche ergab keine Treffer.\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\tSie haben keine Personen in ihrer Merkliste.\n\t\t\t\n\t\t\n\t\n\n  \n    ABANTO PAYER, Dora Carmela (F)\n     \n    \n      \n    \n    \n      \n        Direktlink\n        \n    \n    \n  \n  Nationalität: Schweiz (CH)GLN: 7601000813282 \n\n\n  \n    \n  \n  Bahnhofstrasse 415000 AarauKartendatenKartendaten © 2014 GoogleKartendatenKartendaten © 2014 GoogleKartendaten © 2014 GoogleNutzungsbedingungenFehler bei Google Maps meldenKarteKarteSatellitGelände45°Beschriftungen\n\n\n  Zahnärztin/Zahnarzt\n  \n    \n      Beruf\n            Jahr\n            Land\n          Zahnärztin/Zahnarzt\n            2004\n            Schweiz\n          Weiterbildungstitel \n            \n            \n          Keine Angaben vorhanden\n          Weitere Qualifikationen (privatrechtliche Weiterbildung)\n            \n            \n          Keine Angaben vorhanden\n          \n    Berufsausübungsbewilligung Bewilligung erteilt für Kanton(e): Aargau \n          (2012)\n        , Genf \n          (2004)\n        Direktabgabe von Arzneimitteln gemäss kant. Bestimmungen (Selbstdispensation) keine SelbstdispensationBezug von Betäubungsmitteln Berechtigung erteilt für Kanton(e): Aargau, GenfAdresse(n)Bewilligungskanton: AargauA.\n\t\t\t  zahnarztzentrum.chBahnhofstrasse 415000 AarauTelefon: 062 832 32 01Fax: 062 832 32 01Bewilligungskanton: GenfB.\n\t\t\t  CABINET DENTAIRE VRBICA VESELINAvenue du Bois-De-La-Chapelle 991213 OnexTelefon: 022.793.29.60Fax: 022.793.29.63\n\n\n\n"
 doc.css('div[id="resultContainer"]').css('h3').text
#=> "ABANTO PAYER, Dora Carmela (F)"
 doc.css('div[id="resultContainer"]').css('div li[class="active"]').text
# => "Zahnärztin/Zahnarzt"

  doc.css('div[id="resultContainer"]').css('div table')[2].text
# => "Beruf\n            Jahr\n            Land\n          Zahnärztin/Zahnarzt\n            2004\n            Schweiz\n          Weiterbildungstitel \n            \n            \n          Keine Angaben vorhanden\n          Weitere Qualifikationen (privatrechtliche Weiterbildung)\n            \n            \n          Keine Angaben vorhanden\n          "
  doc.css('div[id="resultContainer"]').css('p').text
#   => "Nationalität: Schweiz (CH)GLN: 7601000813282 "
  doc.css('div[id="resultContainer"]').css('div[class="ac-detail-data"]').text
#=> "\n    \n      Beruf\n            Jahr\n            Land\n          Zahnärztin/Zahnarzt\n            2004\n            Schweiz\n          Weiterbildungstitel \n            \n            \n          Keine Angaben vorhanden\n          Weitere Qualifikationen (privatrechtliche Weiterbildung)\n            \n            \n          Keine Angaben vorhanden\n          \n    Berufsausübungsbewilligung Bewilligung erteilt für Kanton(e): Aargau \n          (2012)\n        , Genf \n          (2004)\n        Direktabgabe von Arzneimitteln gemäss kant. Bestimmungen (Selbstdispensation) keine SelbstdispensationBezug von Betäubungsmitteln Berechtigung erteilt für Kanton(e): Aargau, GenfAdresse(n)Bewilligungskanton: AargauA.\n\t\t\t  zahnarztzentrum.chBahnhofstrasse 415000 AarauTelefon: 062 832 32 01Fax: 062 832 32 01Bewilligungskanton: GenfB.\n\t\t\t  CABINET DENTAIRE VRBICA VESELINAvenue du Bois-De-La-Chapelle 991213 OnexTelefon: 022.793.29.60Fax: 022.793.29.63"
doc.css('div[id="resultContainer"]').css('div[class="ac-detail-data"] thead').text
# => "Beruf\n            Jahr\n            Land\n          "
[127] pry(#<RSpec::ExampleGroups::ChOddbOrg>)> doc.css('div[id="resultContainer"]').css('div[class="ac-detail-data"] tbody').text
# => "Zahnärztin/Zahnarzt\n            2004\n            Schweiz\n          Weiterbildungstitel \n            \n            \n          Keine Angaben vorhanden\n          Weitere Qualifikationen (privatrechtliche Weiterbildung)\n            \n            \n          Keine Angaben vorhanden\n         

Will continue tomorrow to use this make getting the values. Scraping the data will take much time, as getting the values for each of the GLN take several seconds.

Fix ArgumentError invalid date in ODDB::TextInfoPlugin

When running import_daily we got the following error mail

Plugin: ODDB::TextInfoPlugin
Error: ArgumentError
Message: invalid date
Backtrace:
/var/www/oddb.org/src/plugin/text_info.rb:892:in `strptime'
/var/www/oddb.org/src/plugin/text_info.rb:892:in `block (3 levels) in swissmedicinfo_index'
/var/www/oddb.org/src/plugin/text_info.rb:891:in `each'
/var/www/oddb.org/src/plugin/text_info.rb:891:in `sort_by'
/var/www/oddb.org/src/plugin/text_info.rb:891:in `block (2 levels) in swissmedicinfo_index'
/var/www/oddb.org/src/plugin/text_info.rb:882:in `each_pair'
/var/www/oddb.org/src/plugin/text_info.rb:882:in `block in swissmedicinfo_index'
/var/www/oddb.org/src/plugin/text_info.rb:870:in `each'
/var/www/oddb.org/src/plugin/text_info.rb:870:in `swissmedicinfo_index'
/var/www/oddb.org/src/plugin/text_info.rb:923:in `block in textinfo_swissmedicinfo_index'
/var/www/oddb.org/src/plugin/text_info.rb:922:in `each'
/var/www/oddb.org/src/plugin/text_info.rb:922:in `textinfo_swissmedicinfo_index'
/var/www/oddb.org/src/plugin/text_info.rb:1393:in `block in import_swissmedicinfo'

Added some debug out and got the line swissmedicinfo_index: 18F-Fluoroethyltyrosine ZRP date Jun 2014 lang DE type FI i [1, 3]. Strptime parses a string and returns a date. But I do not see how it implements the sort_by functionality. Will look whether we have unit tests and when this functionality was added to better understand the meaning.

Adding a rescue clause to handle this error and restarting import_daily.

Analysing the history we see that in 2013 Yasuhiro reworked src/plugin/text_info.rb quite extensively (about 15 commit between 21.03.2013 and 22.05.13) but did not update any of the corresponding unit-tests. Therefore adding a unit test which covers the function swissmedicinfo_index. This is not so easy and running takes too long (about a minute). Therefore looking for another way.

Added a unit test. This found an error in src/plugin/text_info.rb when corresponding fi/pi is not present in the XML file. Rerunning import_daily. Here I see a curios error

2014-10-20 14:45:35 +0200: update_fachinfo COLIQUIFILM® iksnr 46440 store_fachinfo {}
message type 0x5a arrived from server while idle

Then the whole import seems to be blocked, as I don't see anyghing about the CELLUVISC® (the next fi to fimport). Seems like this a known problem see thread https://www.ruby-forum.com/topic/127814. Did shut down all oddb-services, restarted postgres and running import_daily again. Import-Daily finished without problems now. Pushed commit Fix daily-import of text_info

view · edit · sidebar · attach · print · history
Page last modified on October 20, 2014, at 05:54 PM