Some IKSNR, eg. 00500 sequence 01 show up after the import under http://oddb-ci2.dyndns.org/de/gcc/drug/reg/00500/seq/04 having an empty substance. In the import I find 2015-03-30 23:22:11 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:590 update_active_agent update 00500/04 from creator 2 substances '' ptr :!create,:!registration,00500!sequence,04!composition,25004884!active_agent,Natrii Chloridi Solutio 9 G/l.. label nil 2 args {:dose=>Quanty(33,'ml'), :substance=>33020339} chemical_dose
Using pry to debug the problem.
Displaying 00615/seq/01 leads still to NoMethodError undefined method `resolve' for nil:NilClass
. May be I must exclude lines starting with "Solvens" too.
Also I see superfluos updates like this
2015-03-31 08:35:18 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:590 update_active_agent update 38471/01 from active_agent 9 substances 'Calcii Chloridum' ptr :!registration,38471!sequence,01!composition,9468552!active_agent,219761. label nil 1 args {:substance=>531} chemical_dose
bin/admin show
ch.oddb> substance(513).oid -> 513 ch.oddb> substance(513) -> Quinaprilatum Monohydricum ch.oddb> substance('Calciumchlorid') -> Calcii Chloridum ch.oddb> substance('Calciumchlorid').oid -> 531 ch.oddb> substance('Calciumchlorid').names -> ["Calciumchlorid", "Calcium Chloride", "Calcium Chlorure", "Calcii Chloridum", "Chlorure de Calcium", "Calcii Chloridum Dihydr.", "Calcii Chloridum Dihydricum", "Calcium", "Kalzium", "Kalcium"]
Which means, that I must check all possible names of a substance before doing an update. Changes seem to work for IKSNR 38471.
Now looking at the lines 2015-03-31 10:44:46 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:582 update_active_agent 15322/01 chemical_dose 3.5-4.2 == chemical_substance sennosidum b == nil
and 2015-03-31 10:44:46 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:590 update_active_agent update 15322/01 from creator 3 substances ptr :!create,:!registration,15322!sequence,01!composition,9458026!active_agent,Sennae Folii Pulvis.. label nil 4 args {:dose=>Quanty(145,'mg'), :substance=>4821, :chemical_dose=>Quanty(3.85,), :chemical_substance=>4056} chemical_dose 3.5-4.2 mg
The http://oddb-ci2.dyndns.org/de/gcc/drug/reg/15322/seq/01 has Resolve nil errors. Some as IKNSR 00500. Looking via bin/admin at 00500.
-> Redimune 1 g, Trockensubstanz mit Solvens ch.oddb> registration('00500').sequence('04').compositions.size -> 1 ch.oddb> registration('00500').sequence('04').compositions.first -> Trockensubstanz mit Solvens: Immunoglobulinum Humanum Normale 1 g, ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.size -> 2 ch.oddb> registration('00500').sequence('04').compositions.first.substances.size -> 2 ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.first.oid -> 25004887 ch.oddb> registration('00500').sequence('04').compositions.first.substances.first.oid -> 24362289 ch.oddb> registration('00500').sequence('04').compositions.first.substances.first -> Immunoglobulinum Humanum Normale ch.oddb> registration('00500').sequence('04').compositions.first.substances.first -> Immunoglobulinum Humanum Normale ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.first.substance.oid -> 24362289 ch.oddb> registration('00500').sequence('04').compositions.first.substances.last -> ch.oddb> registration('00500').sequence('04').compositions.first.substances.last.class -> NilClass ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.last.class -> ODDB::ActiveAgent ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.last.oid -> 33037805 ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.last.pointer -> :!create,:!registration,00500!sequence,04!composition,25004884!active_agent,Natrii Chloridi Solutio 9 G/l.. ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.last.dose.class -> NilClass ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.last.to_a -> [nil, nil]
Here active_agents.last does not have a substance. This seems to happen a few times. Trying to resolve the problem via bin/admin
ch.oddb> delete registration('00500').sequence('04').compositions.first.active_agents.find { |x| x.substance == nil}.pointer -> ch.oddb> registration('00500').sequence('04').compositions.first.active_agents.find { |x| x.substance == nil}.pointer -> :!create,:!registration,00500!sequence,04!composition,25004884!active_agent,Natrii Chloridi Solutio 9 G/l.. ch.oddb> registration('00500').sequence('04').compositions.first.delete_active_agent(33037805) -> ch.oddb> registration('00500').sequence('04').compositions.first.active_agents -> [#<ODBA::Stub:83292400#25004887 @odba_class= @odba_container=83762120#25004886>]
And now http://oddb-ci2.dyndns.org/de/gcc/drug/reg/00500/seq/04 works without problems. Adding a check to delete all such occurrences in plugin/swissmedic.rb.
Trying to find out why I have problems displaying http://oddb-ci2.dyndns.org/de/gcc/drug/reg/57875/seq/01. Using bin/admin shows
ch.oddb> registration('57875').sequence('01').compositions.first.source -> dextromethorphani hydrobromidum 8.5 mg corresp. dextromethorphanum 6.25 mg, arom.: natrii cyclamas, vanillinum et alia, color.: E 150, conserv.: E 218, E 216, excipiens ad solutionem pro 5 ml. ch.oddb> registration('57875').sequence('01').compositions.first.active_agents[0].substance -> Dextromethorphani Hydrobromidum ch.oddb> registration('57875').sequence('01').compositions.first.active_agents[0].chemical_substance -> Dextromethorphanum ch.oddb> registration('57875').sequence('01').compositions.first.active_agents[0].chemical_dose -> 6.25 ch.oddb> registration('57875').sequence('01').compositions.first.active_agents[0].chemical_substance.oid -> 5929 ch.oddb> registration('57875').sequence('01').compositions.first.active_agents[0].substance.oid -> 5250 ch.oddb> registration('57875').sequence('01').compositions.first.active_agents[0].dose -> 8.5mg / 5ml
In the import log I find the lines
2015-03-31 11:46:49 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:582 update_active_agent 57875/01 chemical_dose 6.25 == chemical_substance dextromethorphanum == nil 2015-03-31 11:46:49 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:590 update_active_agent update 57875/01 from creator 6 substances '' ptr :!create,:!registration,57875!sequence,01!composition,12791603!active_agent,Dextromethorphani Hydrobromidum.. label nil 4 args {:dose=>Quanty(1.7,'mg/ml'), :substance=>5250, :chemical_dose=>Quanty(6.25,''), :chemical_substance=>5929} chemical_dose 6.25 mg
Here it does not find the correct active agent. Don't understand why the args contain :dose => "1.7 mg/ml". Also substance.oid and chemical_substance.oid match.
After a discussion with Zeno we decided to use in oddb_calc.xml also the concept of active_agents and trying to make it similar to the datastructure in ch.oddb.org. But we do drop the requirement, that all substances are listed. After looking at the code in ch.oddb.org (and de.oddb.org) I resume the situation
http://ch.oddb.org/de/gcc/drug/reg/55491/seq/01 we take sennae folii extractum methanolicum siccum 78-104 mg corresp. sennosidum B 12.5 mg, DER: 18:1, excipiens pro compresso.
and set the name to sennae folii extractum methanolicum siccum
which a chemical substance sennosidum B
Whereas for Ecodurec http://ch.oddb.org/de/gcc/drug/reg/47837/seq/01 Zeno would like to interpret the Zusammensetzung of amiloridi hydrochloridum dihydricum 5.67 mg corresp. amiloridi hydrochloridum anhydricum 5 mg, hydrochlorothiazidum 50 mg, excipiens pro compresso.
as
It looks like I must discover at run time whether the active_agent is on the left or the right side of the corresp.