view · edit · sidebar · attach · print · history

Index>

20170118-oddb-org-ruby-240

Summary

Commits

Index

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 http://ch.oddb.org/de/gcc/ddd_price/reg/36830/seq/01/pack/018/

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 https://www.whocc.no/atc_ddd_index/?code=C01DA02

New search    Show text from Guidelines
C CARDIOVASCULAR SYSTEM
C01 CARDIAC THERAPY
C01D VASODILATORS USED IN CARDIAC DISEASES
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 = Dose.new(1) 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?
NoMethodError
undefined method `[]' for nil:NilClass
/var/www/oddb.org/vendor/ruby/2.4.0/gems/ruby-units-2.1.0/lib/ruby_units/unit.rb:636:in `to_s'
/var/www/oddb.org/src/view/admin/registration.rb:59:in `join'
/var/www/oddb.org/src/view/admin/registration.rb:59:in `block (2 levels) in galenic_form'
/var/www/oddb.org/src/view/admin/registration.rb:55:in `collect'
/var/www/oddb.org/src/view/admin/registration.rb:55:in `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.org: 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.org

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 => Drugs::Dose.new(dose, unit)
src/plugin/swissmedic.rb:      dose = ODDB::Dose.new(parsed_substance.qty, parsed_substance.unit)
src/plugin/swissmedic.rb:        dose = Dose.new(0)
src/plugin/swissmedic.rb:        chemical_dose = ODDB::Dose.new(parsed_substance.chemical_substance.qty, parsed_substance.chemical_substance.unit)
src/plugin/swissmedic.rb:              # TODO::howto handle this ?excipiens.dose = Dose.new(parsed_composition.excipiens.qty, parsed_composition.excipiens.unit)
src/plugin/vaccines.rb:                                 Dose.new(match[1], match[2])
src/plugin/vaccines.rb:                                 pack.size = Dose.new(qty, unit)
src/plugin/vaccines.rb:                                 pack.size = Dose.new(1)
src/plugin/vaccines.rb:                                 pack.dose = Dose.new(*dstring.split(/\s+/u, 2))
src/plugin/bsv_xml.rb:          [data[:lt], ODDB::Dose.new(data[:dose], data[:unit])]
src/util/resultsort.rb:      dose || Dose.new(0)
src/util/resultsort.rb:        dosis =  Dose.new(package.registration.name_base.downcase.sub(trademark.downcase, ''))
src/util/resultsort.rb:        dosis = Dose.new(0)
src/model/sequence.rb:                                                  Dose.new(*value)
src/model/package.rb:                                           Dose.new(*value)
src/model/activeagent.rb:                values[key] = Dose.new(*value) unless(value.is_a? Dose)
src/model/part.rb:    UNIT = ODDB::Dose.new(1)
src/model/part.rb:      Dose.new(*values)
src/model/part.rb:      Dose.new(*values)
src/model/part.rb:          dose = ODDB::Dose.new(node[0], unit)
src/model/part.rb:      @multi = Dose.new(1) if @multi.is_a?(Dose) && !@multi.qty
src/model/part.rb:            values[key] = Dose.new(*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').packages.values.first.parts.first.size
-> undefined method `>' for nil:NilClass
ch.oddb> registration('62186').packages.each{|x| x.fix_doses}
-> Array
ch.oddb> registration('62186').packages.values.first.parts.first.size
-> 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 http://oddb-ci2.dyndns.org/de/gcc/search/zone/drugs/search_query/65044/search_type/st_registration?#best_result

undefined method `compact' for nil:NilClass
/var/www/oddb.org/vendor/ruby/2.4.0/gems/ruby-units-2.1.0/lib/ruby_units/unit.rb:1161:in `units'
/var/www/oddb.org/src/model/dose.rb:87:in `rescue in to_s'
/var/www/oddb.org/src/model/dose.rb:84:in `to_s'
/var/www/oddb.org/src/view/admin/sequence.rb:61:in `dose'
/var/www/oddb.org/vendor/ruby/2.4.0/gems/htmlgrid-1.1.3/lib/htmlgrid/composite.rb:83:in `create'

In bin/admin of ch.oddb.org 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