<< Masa.20110513-debug-import-process-de_oddb-debug-rpdf2txt | 2011 | Masa.20110511-swissindex_plugin-ch_oddb-debug-atc-zuweisen-de_oddb >>
:Commits
Problem
Example
To find the bug company name
To correct the company name
Check the result
Hint
Note
Experiment (lib/oddb/html/state/drugs/admin/product.rb#update)
def update p "getin ODDB::Html::State::Drugs::Admin::Product#update" value = user_input :company print "value = " p value error_check_and_store(:company, value, [:company]) unless error? set = if(company = ODDB::Business::Company.find_by_name(value)) @model.company = company else @errors.store :company, create_error(:e_unknown_company, :company, value) nil end unless(set.nil?) @model.data_origins.store :company, @session.user.email @model.save print "@model.class = " p @model.class end end self end
Restart
Result (the console of bin/oddbd)
"getin ODDB::Html::State::Drugs::Admin::Product#update" value = "Actavis Dtl. GmbH & Co KG" ODBA::Stub was unable to replace Hash#4267068 from ODDB::Drugs::Product:#53926 @model.class = ODDB::Drugs::Product D, [2011-05-12T09:52:53.369549 #6713] DEBUG -- User: mhatakeyama@ywesee.com: allowed?(login, org.oddb.de.Admin) -> true D, [2011-05-12T09:52:59.114444 #6713] DEBUG -- User: mhatakeyama@ywesee.com: allowed?(login, org.oddb.de.Admin) -> true D, [2011-05-12T09:53:01.003531 #6713] DEBUG -- User: mhatakeyama@ywesee.com: allowed?(login, org.oddb.de.Admin) -> true
Note
if company = ODDB::Business::Company.find_by_name(value)
Question
Experiment (lib/oddb/html/state/drugs/admin/package.rb#update)
def update p "getin ODDB::Html::State::Drugs::Admin::Package#update" print "@model.class = " p @model.class print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name ... end def _update input ... p "after update" print "@model.class = " p @model.class print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name self end
Restart
Register a different company name
Result
"getin ODDB::Html::State::Drugs::Admin::Product#update" value = "Sandz O" ODBA::Stub was unable to replace Hash#4267103 from ODDB::Drugs::Product:#58154 @model.class = ODDB::Drugs::Product @model.company.odba_id = 3851493 @model.company.name = #<ODDB::Util::Multilingual:0x7f0e8ca65dc8 @synonyms=[], @canonical={:de=>u"Sandz O"}>
"getin ODDB::Html::State::Drugs::Admin::Package#update" @model.class = ODDB::Drugs::Package @model.company.odba_id = 3523958 @model.company.name = #<ODDB::Util::Multilingual:0x7f0e8ca6a0a8 @synonyms=[], @canonical={:de=>u"Heumann Pharma"}> ODBA::Stub was unable to replace Hash#4267171 from ODDB::Drugs::Package:#58167 ODBA::Stub was unable to replace Array#4267172 from ODDB::Drugs::Package:#58167 ODBA::Stub was unable to replace Array#4267170 from ODDB::Drugs::Package:#58167 ODBA::Stub was unable to replace Hash#4267174 from ODDB::Drugs::Package:#58170 ODBA::Stub was unable to replace Array#4267175 from ODDB::Drugs::Package:#58170 ODBA::Stub was unable to replace Array#4267173 from ODDB::Drugs::Package:#58170 ODBA::Stub was unable to replace Hash#4267179 from ODDB::Util::M10lDocument:#4267177 ODBA::Stub was unable to replace Hash#4267181 from ODDB::Util::M10lDocument:#4267176 ODBA::Stub was unable to replace Hash#4267171 from ODDB::Drugs::Package:#58167 ODBA::Stub was unable to replace Hash#4267174 from ODDB::Drugs::Package:#58170 ODBA::Stub was unable to replace Hash#4267184 from ODDB::Drugs::Package:#58164 ODBA::Stub was unable to replace Array#4267185 from ODDB::Drugs::Package:#58164 ODBA::Stub was unable to replace Array#4267183 from ODDB::Drugs::Package:#58164 ODBA::Stub was unable to replace Hash#4267188 from ODDB::Util::M10lDocument:#4267187 ODBA::Stub was unable to replace Hash#4267184 from ODDB::Drugs::Package:#58164 "after update" @model.class = ODDB::Drugs::Package @model.company.odba_id = 3851493 @model.company.name = #<ODDB::Util::Multilingual:0x7f0e8ca65dc8 @synonyms=[], @canonical={:de=>u"Sandz O"}>
Plan
Experiment (lib/oddb/html/state/drugs/admin/package.rb#_update)
def _update input email = @session.user.email input.each { |key, value| unless(@errors[key]) set = case key when :name @model.name.de = value unless(@model.name.de == value) when :price_public, :price_festbetrag, :price_exfactory update_price(/price_(.*)/.match(key.to_s)[1].to_sym, value.to_f) when :code_cid, :code_festbetragsgruppe, :code_festbetragsstufe update_code(/code_(.*)/.match(key.to_s)[1].to_sym, value) when :code_zuzahlungsbefreit, :code_prescription update_code(/code_(.*)/.match(key.to_s)[1].to_sym, !!value) when :size update_parts(input) end unless(set.nil?) @model.data_origins.store key, email end end } if((uid = input[:sequence]) \ && (seq = ODDB::Drugs::Sequence.find_by_uid(uid)) \ && @model.sequence != seq) p "A" print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name p "B" @model.sequence = seq print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name @model.parts.each_with_index { |part, idx| part.composition = seq.compositions[idx] part.save } p "C" print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name elsif((seq = @model.sequence) && seq.is_a?(Util::UnsavedHelper)) @model.sequence = seq.delegate end @model.save p "After update" print "@model.class = " p @model.class print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name self end
Result
"getin ODDB::Html::State::Drugs::Admin::Package#update" @model.class = ODDB::Drugs::Package @model.company.odba_id = 3851493 @model.company.name = #<ODDB::Util::Multilingual:0x7f46ae7f2c58 @synonyms=[], @canonical={:de=>u"Sandz O"}> "A" @model.company.odba_id = 3851493 @model.company.name = #<ODDB::Util::Multilingual:0x7f46ae7f2c58 @synonyms=[], @canonical={:de=>u"Sandz O"}> "B" ODBA::Stub was unable to replace Hash#4267260 from ODDB::Drugs::Package:#58170 ODBA::Stub was unable to replace Array#4267263 from ODDB::Drugs::Sequence:#58160 ODBA::Stub was unable to replace Hash#4267265 from ODDB::Util::M10lDocument:#4267262 ODBA::Stub was unable to replace Hash#4267267 from ODDB::Util::M10lDocument:#4267264 ODBA::Stub was unable to replace Hash#4267260 from ODDB::Drugs::Package:#58170 ODBA::Stub was unable to replace Hash#4267269 from ODDB::Drugs::Package:#58164 ODBA::Stub was unable to replace Hash#4267272 from ODDB::Util::M10lDocument:#4267271 @model.company.odba_id = 213712 @model.company.name = #<ODDB::Util::Multilingual:0x7f46aed71e68 @synonyms=[], @canonical={:de=>u"Actavis Dtl. GmbH & Co KG"}> "C" @model.company.odba_id = 213712 @model.company.name = #<ODDB::Util::Multilingual:0x7f46aed71e68 @synonyms=[], @canonical={:de=>u"Actavis Dtl. GmbH & Co KG"}> ODBA::Stub was unable to replace Hash#4267269 from ODDB::Drugs::Package:#58164 "After update" @model.class = ODDB::Drugs::Package @model.company.odba_id = 213712 @model.company.name = #<ODDB::Util::Multilingual:0x7f46aed71e68 @synonyms=[], @canonical={:de=>u"Actavis Dtl. GmbH & Co KG"}>
Note
@model.sequence = ODDB::Drugs::Sequence.find_by_uid(@model.sequence.uid)
Experiment (lib/oddb/html/state/drugs/admin/product.rb#update)
def update p "getin ODDB::Html::State::Drugs::Admin::Product#update" value = user_input :company error_check_and_store(:company, value, [:company]) unless error? set = if(company = ODDB::Business::Company.find_by_name(value)) @model.company = company else @errors.store :company, create_error(:e_unknown_company, :company, value) nil end unless(set.nil?) @model.data_origins.store :company, @session.user.email @model.save print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name new_seq = ODDB::Drugs::Sequence.find_by_uid(@model.sequences[0].uid) p (new_seq == @model.sequences[0]) @model.packages.each do |pac| print "package name: " p pac.cascading_name('de') print "company odba_id: " p pac.company.odba_id print "company name: " p pac.company.name end end end self end
Result
"getin ODDB::Html::State::Drugs::Admin::Product#update" ODBA::Stub was unable to replace Hash#4267318 from ODDB::Drugs::Product:#58154 @model.company.odba_id = 3851493 @model.company.name = #<ODDB::Util::Multilingual:0x7fb9d0ab2db8 @synonyms=[], @canonical={:de=>u"Sandz O"}> true package name: "Ticlopidin 250 Heumann Filmtabletten" company odba_id: 213712 company name: #<ODDB::Util::Multilingual:0x7fb9d09f4908 @synonyms=[], @canonical={:de=>u"Actavis Dtl. GmbH & Co KG"}> package name: "Ticlopidin 250 Heumann Filmtabletten" company odba_id: 213712 company name: #<ODDB::Util::Multilingual:0x7fb9d09f4908 @synonyms=[], @canonical={:de=>u"Actavis Dtl. GmbH & Co KG"}> package name: "Ticlopidin 250 Heumann Filmtabletten" company odba_id: 213712 company name: #<ODDB::Util::Multilingual:0x7fb9d09f4908 @synonyms=[], @canonical={:de=>u"Actavis Dtl. GmbH & Co KG"}>
Note
failed
Note (new hint)
The 'Speichern' of 'Sequence' also update the company data of 'Package' (also search result)
Consideration
Experiment (lib/oddb/html/state/drugs/admin/product.rb#update)
def update p "getin ODDB::Html::State::Drugs::Admin::Product#update" value = user_input :company error_check_and_store(:company, value, [:company]) unless error? set = if(company = ODDB::Business::Company.find_by_name(value)) @model.company = company else @errors.store :company, create_error(:e_unknown_company, :company, value) nil end unless(set.nil?) @model.data_origins.store :company, @session.user.email @model.save print "@model.company.odba_id = " p @model.company.odba_id print "@model.company.name = " p @model.company.name @model.sequences[0].product = @model @model.packages.each do |pac| print "package name: " p pac.cascading_name('de') print "company odba_id: " p pac.company.odba_id print "company name: " p pac.company.name end end end self end
Result
"getin ODDB::Html::State::Drugs::Admin::Product#update" ODBA::Stub was unable to replace Hash#4267344 from ODDB::Drugs::Product:#58154 @model.company.odba_id = 3851493 @model.company.name = #<ODDB::Util::Multilingual:0x7f0bcbe217c8 @synonyms=[], @canonical={:de=>u"Sandz O"}> ODBA::Stub was unable to replace Hash#4267345 from ODDB::Drugs::Product:#58154 ODBA::Stub was unable to replace Hash#4267344 from ODDB::Drugs::Product:#58154 package name: "Ticlopidin 250 Heumann Filmtabletten" company odba_id: 3851493 company name: #<ODDB::Util::Multilingual:0x7f0bcbe217c8 @synonyms=[], @canonical={:de=>u"Sandz O"}> package name: "Ticlopidin 250 Heumann Filmtabletten" company odba_id: 3851493 company name: #<ODDB::Util::Multilingual:0x7f0bcbe217c8 @synonyms=[], @canonical={:de=>u"Sandz O"}> package name: "Ticlopidin 250 Heumann Filmtabletten" company odba_id: 3851493 company name: #<ODDB::Util::Multilingual:0x7f0bcbe217c8 @synonyms=[], @canonical={:de=>u"Sandz O"}>
Note
Success
@model.sequences[0].product = @model
Example
1. search result
2. Click 'Wirkstoffe'
3. Click 'Produkt' and update the company name (Zulassungsinhaber) and click 'Speichern'
4. Click 'Suchresultat' (Search result)
Product *--1 Sequence *--1 Package
Sequence#product, Pakcage#sequence
lib/oddb/html/state/drugs/admin/product.rb#update
def update value = user_input :company error_check_and_store(:company, value, [:company]) unless error? set = if(company = ODDB::Business::Company.find_by_name(value)) @model.company = company else @errors.store :company, create_error(:e_unknown_company, :company, value) nil end unless(set.nil?) @model.data_origins.store :company, @session.user.email @model.save@model.sequences.each do |seq|
seq.product = @model
end
end end self end
Commit
Look for the import part (focus only on 'company' first. 'Wirkstoff' looks also strange, though)
Test run
Error
Thu May 12 16:32:16 2011: de.oddb.org ODDB::Import::Gkv#import NoMethodError undefined method `type=' for #<ODDB::Util::Money:0x7f39ed49deb8> ./lib/oddb/drugs/package.rb:68:in `_price_exfactory' ./lib/oddb/import/gkv.rb:266:in `import_package' ./lib/oddb/import/gkv.rb:111:in `import_row' ./lib/oddb/import/gkv.rb:459:in `process_page' ./lib/oddb/import/gkv.rb:458:in `each' ./lib/oddb/import/gkv.rb:458:in `process_page' ./lib/oddb/import/gkv.rb:40:in `call' ./lib/oddb/import/gkv.rb:40:in `send_page' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/parser.rb:43:in `extract_text' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/object.rb:493:in `each' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/object.rb:452:in `each' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/object.rb:493:in `each' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/object.rb:492:in `each' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/object.rb:477:in `each' /usr/lib64/ruby/site_ruby/1.8/rpdf2txt/parser.rb:41:in `extract_text' ./lib/oddb/import/gkv.rb:100:in `import' /usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:96:in `reported_import' /usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:103:in `call' /usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:103:in `_reported_import' /usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:96:in `reported_import' /usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:58:in `import_gkv' /usr/lib64/ruby/1.8/open-uri.rb:32:in `open_uri_original_open' /usr/lib64/ruby/1.8/open-uri.rb:32:in `open' ./lib/oddb/import/gkv.rb:77:in `download_latest' /usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:57:in `import_gkv' jobs/import_gkv:16 ./lib/oddb/util/job.rb:16:in `call' ./lib/oddb/util/job.rb:16:in `run' jobs/import_gkv:15 Imported 1 Zubef-Entries on 12.05.2011: Visited 0 existing Zubef-Entries Visited 0 existing Companies Visited 0 existing Substances Created 0 new Zubef-Entries Created 0 new Products Created 0 new Sequences Created 0 new Companies Created 0 new Substances Assigned 0 Chemical Equivalences Assigned 0 Companies Created 0 Incomplete Packages: Created 0 Product(s) without a name (missing product name):
Note
def type=(type) @type = type.to_s.downcase end