view · edit · sidebar · attach · print · history






DDD for Dafalgan Kinder is incorrect

See blog for a description of the problem.

Adding unit tests for Tabletten, I.E., U.I. and to_g. Investigation why test/test_plugin/vaccines.rb fails because of unrecognised units '1 Amp' and '10 Dos'. 1 Dos comes from iksnr 00640001 Infanrix hexa, Injektionssuspension, which has a unit1 Spritze. 1 Amp comes from IKSNR 54809 BERININ HS FAKTOR IX.

Will look later on how these vaccines fit in our picture.

Fixed an error in changed order of cleaning up odba stubs in src/util/oddbapp.rb clean_odba_stubs to match expected result in corresponding unit test.

Looking at the unit test failure in test_model for active_agents, package and sequence. I am changing the expected behaviour that '123 mgkKo' from to return 123 mg to raise and ArgumentError. Same for '123 fjdsfjdksah'. But the new test for Dafalgan still return 1.68 instead of 16.8. What is the error here? I made an error in the calculation. The 12 Sachets à 250 mg correspond exactly to the 3 g DD and therefore the correct price is 1.40 and not 1.68 as returned at the moment. Fixed this by saying that the package contains 12 Sachets instead of 10 Tabletten.

Looking at another example IKSR 36830 NITROGLYCERIN+Streuli+Kaukaps which displays at

Tageskosten für Nitroglycerin Streuli
Tagesdosis	5 mg	Publikumspreis	7.40 CHF
Stärke	0.8 mg	Packungsgrösse	30 Kapsel(n)
Berechnung	( 5 mg / 0.8 mg ) x ( 7.40 / 30 Kapsel(n) ) = 1.54 CHF / Tag

WHO shows at

New search    Show text from Guidelines
C01DA Organic nitrates

    ATC code  	Name  	DDD 	 U	 Adm.R	 Note
    C01DA02  	glyceryl trinitrate 	5 	mg 	O 	
    		2.5 	mg 	oral aerosol 	
    		2.5 	mg 	SL 	
    		5 	mg 	TD 	

Mr. Wallimann showed, that the correct value is 0.77 and not 1.54 CHF/day.

Looking via bin/admin which route of administration is linked to this package

ch.oddb> registration('36830').package('018').route_of_administration.class
-> NilClass

Tried to start oddb-ci2 with Quanty replaced by ruby-units. Having problems with IKSNR 32819 loading the parts. Trying to fix it using a patched version of ruby-units.

Patched the size method in model/part to a correct value for @multi by adding @multi = if @multi.is_a?(Dose) && !@multi.qty. Now I can navigate to the home page and view a fachinfo. But searching a registration fails with

error in SBSM::Session#http_headers: /de/gcc/search/zone/drugs/search_query/62186/search_type/st_registration?
undefined method `[]' for nil:NilClass
/var/www/ `to_s'
/var/www/ `join'
/var/www/ `block (2 levels) in galenic_form'
/var/www/ `collect'
/var/www/ `block in galenic_form'

This happens with an unpatched ruby-units.

Now having problem with IKSNR 62186. Patched active_agents to return nil if dose.qty is nil. Now the registrations display, but bin/admin has different outputs

  • on ch.oddb> registration('32819').package('028').active_agents.first.dose returns 0.75 ml
ch.oddb> registration('32819').package('028').active_agents.first.dose.facts
-> undefined method `facts' for Quanty(0.75,'ml'):ODDB::Dose
Did you mean?  fact
ch.oddb> registration('32819').package('028').active_agents.first.dose.fact
-> 1.0000000000000002e-06 m3
ch.oddb> registration('32819').package('028').active_agents.first.dose.qty
-> 0.75
ch.oddb> registration('32819').package('028').active_agents.first.dose.unit
-> ml
  • on oddb-ci2: ch.oddb> registration('32819').package('028').active_agents.first.dose.class returns NilClass

Added attr_reader :value, :facts and :qty to Dose. Added a breakpoint when the dose of an active_agent is used. Here I see in the pry session that @dose.valueis 80, which coresponds to the bin/admin/ of

ch.oddb> registration('32819').package('028').active_agents[1].dose.value
-> 80
ch.oddb> registration('32819').package('028').active_agents[1].dose.qty
-> 80
ch.oddb> registration('32819').package('028').active_agents[1].dose.unit
-> µl/ml

The substance_name in the pry session is "EUCALYPTI AETHEROLEUM". @dose.fact is {}. Added also an alias :qty :val. Now I can display a sequence but getting an error while displaying a search_list, as the methods parts.size throws also a exception.

My task is therefore to find a way to migrate all Doses from the old way to the new one. Dose. new is called in the following files

src/plugin/who.rb:                                       :dose =>, unit)
src/plugin/swissmedic.rb:      dose =, parsed_substance.unit)
src/plugin/swissmedic.rb:        dose =
src/plugin/swissmedic.rb:        chemical_dose =, parsed_substance.chemical_substance.unit)
src/plugin/swissmedic.rb:              # TODO::howto handle this ?excipiens.dose =, parsed_composition.excipiens.unit)
src/plugin/vaccines.rb:                       [1], match[2])
src/plugin/vaccines.rb:                                 pack.size =, unit)
src/plugin/vaccines.rb:                                 pack.size =
src/plugin/vaccines.rb:                                 pack.dose =*dstring.split(/\s+/u, 2))
src/plugin/bsv_xml.rb:          [data[:lt],[:dose], data[:unit])]
src/util/resultsort.rb:      dose ||
src/util/resultsort.rb:        dosis =, ''))
src/util/resultsort.rb:        dosis =
src/model/sequence.rb:                                        *value)
src/model/package.rb:                                 *value)
src/model/activeagent.rb:                values[key] =*value) unless(value.is_a? Dose)
src/model/part.rb:    UNIT =
src/model/part.rb:          dose =[0], unit)
src/model/part.rb:      @multi = if @multi.is_a?(Dose) && !@multi.qty
src/model/part.rb:            values[key] =*value) if value

Therefore we must to iterate over all sequences, packages, active_agents and part and transform the old form into a new. Adding a helper function for it in dose.rb and adding a new test for it.

Added methods fix_doses for package and part. Tested them via bin/admin

-> #<ODDB::Part:0x00557de199f368>
ch.oddb> registration('62186')
-> undefined method `>' for nil:NilClass
ch.oddb> registration('62186').packages.each{|x| x.fix_doses}
-> Array
ch.oddb> registration('62186')
-> 4 Tablette(n)

Waiting for packages.each{|x| x.fix_doses} to finish. Started. Took about 10 minutes. This fixed some problems. Also verified that calling it a second time or after a restart now changes are done.

Still having problem when trying

undefined method `compact' for nil:NilClass
/var/www/ `units'
/var/www/ `rescue in to_s'
/var/www/ `to_s'
/var/www/ `dose'
/var/www/ `create'

In bin/admin of I see

ch.oddb> registration('65044').sequences.values.first
-> Perindopril-Amlodipin-Mepha 5mg/5mg, Tabletten
ch.oddb> registration('65044').sequences.values.first.doses
-> [Quanty(5,'mg'), Quanty(5,'mg')

which is different from oddb-ci2

ch.oddb> registration('65044').sequences.values.first
-> Perindopril-Amlodipin-Mepha 5mg/5mg, Tabletten
ch.oddb> registration('65044').sequences.values.first.doses
-> [nil, 5 mg, 5 mg]
ch.oddb> registration('65044').sequences.values.first.doses.first.class
-> NilClass

Somehow I get now a nil value. Why?

Pushed my changes into branch ruby2x with Replace Quanty by ruby-units

Must drop and reload the database to see whether fix_doses create the problem with the additional active_agent or not.

view · edit · sidebar · attach · print · history
Page last modified on January 18, 2017, at 05:42 PM