view · edit · sidebar · attach · print · history

Index>

20140514-fix-swissmedic-nil-error-2

Summary

  • Fix Message: can't dup NilClass. in jobs/import_swissmedic
  • Emit XSD for oddb2xml

Commits

Index

Keep in Mind

---

Fix Message: can't dup NilClass. in jobs/import_swissmedic

Analysing the info presented by last import (where deleting 33481 worked, but not with 35342) with much more debug, which is

2014-05-13 21:51:52 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 178: delete iksnr '33481' seqnr 01 pack 
2014-05-13 21:51:52 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 180: delete iksnr '33481' ptr :!registration,33481!sequence,01!package,012. row ["33481", "01", "012", 0]
2014-05-13 21:51:52 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 184: delete object #<ODDB::Package:0x007fa9c9641bd8 @swissmedic_source={:import_date=>#<Date: 2013-11-05 ((2456602j,0s,0n),+0s,2299161j)>, :iksnr=>"33481", :seqnr=>"01", :name_base=>"Vitamin D3 Streuli, Tropfen", :company=>"Streuli Pharma AG", :index_therapeuticus=>"07.02.3.", :atc_class=>"A11CC05", :production_science=>"Synthetika human", :registration_date=>#<Date: 1967-07-21 ((2439693j,0s,0n),+0s,2299161j)>, :sequence_date=>#<Date: 1967-07-21 ((2439693j,0s,0n),+0s,2299161j)>, :expiry_date=>#<Date: 2017-09-12 ((2458009j,0s,0n),+0s,2299161j)>, :ikscd=>"012", :size=>"10", :unit=>"ml", :ikscat=>"D", :substances=>"cholecalciferolum", :composition=>"cholecalciferolum 4000 U.I., excipiens ad solutionem pro 1 ml corresp. 40 guttae corresp. ethanolum 49 % V/V.", :indication_registration=>"Vitamin D-Präparat", :indication_sequence=>nil}, @oid=2738, @data_origins={"size"=>:swissmedic, "descr"=>:swissmedic, "commercial_form"=>:swissmedic, "swissmedic_source"=>:swissmedic, "out_of_trade"=>:refdata, "pharmacode"=>:bag, "refdata_override"=>:refdata}, @odba_persistent=true, @ikscat="D", @revision=2014-01-01 14:13:32 +0100, @sequence=#<ODBA::Stub:70183602500320#70343 @odba_class=ODDB::Sequence @odba_container=70183602490860#210811>, @odba_id=210811, @parts=nil, @odba_observers=[], @pointer=:!registration,33481!sequence,01!package,012., @ikscd="012", @feedbacks=nil, @refdata_override=false, @out_of_trade=false, @narcotics=nil, @odba_target_ids=nil, @odba_prefetch=false, @prices={:public=>#<ODBA::Stub:70183602499000#28084704 @odba_class=Array @odba_container=70183602499040#28084703>, :exfactory=>#<ODBA::Stub:70183602498720#28084705 @odba_class=Array @odba_container=70183602499040#28084703>}, @comparable_size=Quanty(10.0,'ml'), @comform=nil, @price_exfactory=nil, @descr=nil, @pharmacode="1538492", @mail_order_prices=nil, @price_public=nil>
2014-05-13 21:51:52 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 186: delete object.oid 2738
ensure_object_connections: ensure 2 target_ids [689832, 26257256, 10, 6, 934654, 795431, 9, 11, 868627, 3, 20, 18, 8, 724033, 1252741, 726317, 17, 16, 13, 393389, 780360, 19, 1211301, 15, 5, 12, 7, 724030, 14, 1067430, 9587859, 4, 22, 21, 810961, 954379, 28724410, 28834017, 28850745, 31673883, 31208308] sql         SELECT target_id FROM object_connection
        WHERE origin_id = ?
ensure_object_connections: ensure 31687567 target_ids [] sql         SELECT target_id FROM object_connection
        WHERE origin_id = ?
ensure_object_connections: ensure 210811 target_ids [70343, 31687567] sql         SELECT target_id FROM object_connection
        WHERE origin_id = ?
2014-05-13 21:51:52 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 178: delete iksnr '35342' seqnr 01 pack 
2014-05-13 21:51:52 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 180: delete iksnr '35342' ptr :!registration,35342!sequence,01!package,028. row ["35342", "01", "028", 0]
2014-05-13 21:51:53 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 184: delete object #<ODDB::Package:0x007fa9c99e9790 @swissmedic_source={:import_date=>#<Date: 2013-11-05 ((2456602j,0s,0n),+0s,2299161j)>, :iksnr=>"35342", :seqnr=>"01", :name_base=>"Primpéran, suppositoires pour adultes", :company=>"Sanofi-Aventis (Suisse) SA", :index_therapeuticus=>"04.06.0.", :atc_class=>"A03FA01", :production_science=>"Synthetika human", :registration_date=>#<Date: 1970-06-19 ((2440757j,0s,0n),+0s,2299161j)>, :sequence_date=>#<Date: 1970-06-19 ((2440757j,0s,0n),+0s,2299161j)>, :expiry_date=>#<Date: 2016-02-07 ((2457426j,0s,0n),+0s,2299161j)>, :ikscd=>"028", :size=>"6", :unit=>"Suppositorien", :ikscat=>"B", :substances=>"metoclopramidum", :composition=>"metoclopramidum 20 mg, excipiens pro suppositorio.", :indication_registration=>"Troubles digestifs", :indication_sequence=>nil}, @oid=4726, @data_origins={"size"=>:swissmedic, "deductible"=>:bag, "pharmacode"=>:refdata, "price_public"=>:bag, "price_exfactory"=>:sl, "sl_generic_type"=>:bag, "swissmedic_source"=>:swissmedic, "refdata_override"=>:swissmedic}, @odba_persistent=true, @ikscat="B", @revision=2014-05-03 01:02:31 +0200, @sequence=#<ODBA::Stub:70183604411560#73025 @odba_class= @odba_container=70183604407240#220866>, @odba_id=220866, @parts=#<ODBA::Stub:70183604427120#28868651 @odba_class=Array @odba_container=70183604407240#220866>, @odba_observers=[], @pointer=:!registration,35342!sequence,01!package,028., @ikscd="028", @feedbacks=nil, @refdata_override=true, @narcotics=nil, @odba_target_ids=nil, @odba_prefetch=false, @prices={:public=>#<ODBA::Stub:70183604434920#27852065 @odba_class=Array @odba_container=70183604419200#27852064>, :exfactory=>#<ODBA::Stub:70183604429980#27852066 @odba_class=Array @odba_container=70183604419200#27852064>}, @comparable_size=Quanty(6.0,''), @price_exfactory=148, @descr="", @pharmacode="137816", @deductible=:deductible_g, @sl_entry=#<ODBA::Stub:70183604442040#706979 @odba_class= @odba_container=70183604407240#220866>, @sl_generic_type=nil, @mail_order_prices=#<ODBA::Stub:70183604420920#31672915 @odba_class=Array @odba_container=70183604407240#220866>>
2014-05-13 21:51:53 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 186: delete object.oid 4726
ensure_object_connections: ensure 2 target_ids [689832, 26257256, 10, 6, 934654, 795431, 9, 11, 868627, 3, 20, 18, 8, 724033, 1252741, 726317, 17, 16, 13, 393389, 780360, 19, 1211301, 15, 5, 12, 7, 724030, 14, 1067430, 9587859, 4, 22, 21, 810961, 954379, 28724410, 28834017, 28850745, 31673883, 31208308] sql         SELECT target_id FROM object_connection
        WHERE origin_id = ?
173: parts #<ODBA::Stub:70183604427120#28868651 @odba_class=Array @odba_container=70183604407240#220866>
ODBA::Stub was unable to replace Array#28868651 from ODDB::Package:#220866
-> "220 mx.google.com ESMTP a45sm36073723eez.2 - gsmtp\r\n"

Banging my head because I cannot delete the package. As with the last error I got a lot of information about the object to delete, I will reimport the old database and try to delete it manually in bin/admin and check the outcome.

The problem seems to lay that @parts 28868651 could not be replaced. Must analyse its content with old DB. Exploring with bin/admin

ch.oddb> registration('33481').packages.size
-> 2
ch.oddb> registration('35342').packages.size
-> 0

Okay. We fail when the registration has no package. Maybe we should look at this fact when calling _sanitize_deletions and remove these object.

Okay. Now I am quite confident that my work-around is correct. It is however not very elegant and may be should introduce similar checks for deleting sequences and registrations.

Okay I am over the old error but got a new one:

Plugin: ODDB::SwissmedicPlugin
Error: NoMethodError
Message: undefined method `[]' for nil:NilClass
Backtrace:
/usr/local/lib64/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:57:in `cell'
/var/www/oddb.org/src/plugin/swissmedic.rb:142:in `cell'
/var/www/oddb.org/src/plugin/swissmedic.rb:364:in `pointer_from_row'
/var/www/oddb.org/src/plugin/swissmedic.rb:419:in `resolve_link'
/var/www/oddb.org/src/plugin/swissmedic.rb:371:in `block in report'
/var/www/oddb.org/src/plugin/swissmedic.rb:370:in `collect'
/var/www/oddb.org/src/plugin/swissmedic.rb:370:in `report'
/var/www/oddb.org/src/plugin/plugin.rb:54:in `block in log_info'
/var/www/oddb.org/src/plugin/plugin.rb:53:in `each'
/var/www/oddb.org/src/plugin/plugin.rb:53:in `inject'
/var/www/oddb.org/src/plugin/plugin.rb:53:in `log_info'
/var/www/oddb.org/src/util/updater.rb:146:in `log_info'
/var/www/oddb.org/src/util/updater.rb:401:in `block in update_swissmedic'
/var/www/oddb.org/src/util/updater.rb:500:in `call'
/var/www/oddb.org/src/util/updater.rb:500:in `wrap_update'
/var/www/oddb.org/src/util/updater.rb:396:in `update_swissmedic'
jobs/import_swissmedic:14:in `block in <module:Util>'
/var/www/oddb.org/src/util/job.rb:40:in `call'
/var/www/oddb.org/src/util/job.rb:40:in `run'
jobs/import_swissmedic:12:in `<module:Util>'
jobs/import_swissmedic:11:in `<module:ODDB>'
jobs/import_swissmedic:10:in `<main>'

Therefore I have again an error when reporting the swissmedic results. Found that swissmedic-diff.rb does not check whether the row is valid or not.

But correction should be made in plugin/swissmedic.rb. Added another line. Reverted changes for model/package.rb and eimporting the database again (12.20).

Now import-swissmedic finished without problem. I see in the report one line with no pointer for nil. Therefore pushed commit Fix import swissmedic when package is already deleted

Emit XSD for oddb2xml

Also running it over all XML files generated with rake test returns a quite different and longer (1134 lines, 320 names) XSD.

  • Merged manually xsd files generated using nst2xsd and trang.
  • Added comments to oddb2xml.xsd.
  • Modified rspec to verify generated XML-files using Nokogiri XSD-Schema validator.

Pushed commit Added commented oddb2xml.xsd. Include rspec tests

view · edit · sidebar · attach · print · history
Page last modified on May 20, 2014, at 03:36 PM