view · edit · sidebar · attach · print · history

Index>

20150713-update-compositions

Summary

  • Adapt oddb.org to new fields for compositions

Commits

(on branch Wirkstoffe)

Index

Keep in Mind for work to do
  • Fix dojo error http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/#forgot-dom-ready
  • I removed on May-27 tests for ix_registrationss, fix_sequences, fix_compositions, fix_packages from test/test_plugin/swissmedic.rb,as he could not find any references for them in the src code. Did I erroneously remove stuff when cleaning up the swissmedic import earlier?
  • The whole test for older/newer Packages must be adapted to xlsx. One must compare the rows (e.g. by creating csv files) and do the same stuff in xlsx!
  • creat gem: task: input=file with ean-codes, standard output show ean-codes + atc-code. Source is Swissmedic Packungen.xlsx or XML.
  • Import via data/medreg_companies.yaml
  • Fix problem with radioactivatum 99m-technetio when parsing Wirkstoffe
  • Fix galenic_forms when parsing swissmedic.xlsx
  • Cleanup generic_type. Replace it everywhere by sl_generic_type and adapt code accordingly.
  • Get updated ATC-codes from EPha for oddb.org, too.
  • Display new fields (LABEL, MORE_INFO, CORRESP) for compositions in oddb.org.
  • Use refdatabase for oddb.org, too.
  • Fix running rspec for new packungen.xlsx in oddb2xml

Adapt oddb.org to new fields for compositions

Stuff todo:

  • Import updated parslet-parser from oddb2xml into oddb.org
    • Add new fields, eg. excipiens to model
    • more or less copy lib/oddb2xml/compositions_syntax.rb and lib/oddb2xml/parslet_compositions.rb
    • rework src/plugin/swissmedic to use the logic from the methods emit_substance and build_calc in lib/oddb2xml/builder.xlm when import info from Packungen.xlsx
  • Add helper import job for compositions
  • Add new fields, eg. excipiens oddb.org HTML views

What and how to add

  • excipiens
    • In oddb2xml each composition has zero or one excipiens which is a substance (often only a name, but can have a dose, e.g 7680004500015, FSME-Immun CC, Suspension zur intramuskulären Injektion
    • in oddb2xml a substance can have a more_info field (like conserv)

Continuing work of last week. Add new fields to swissmedic plugin.

When trying to make the test defined in test_exporter to pass, I remarked when sending the result of the CSV files, we use an uninitialized variable @recipients in src/util/exporter.rb in an unused method mail_notification_stats. Removing mail_notification_stats and its accompanying test. Done with commit Remove unused method mail_notification_stats

Comparing the datastructures of oddb2xml and oddb.org: oddb_calc.xml generates somethin like

  <ARTICLE>
    <GTIN>7680002770014</GTIN>
    <NAME>Coeur-Vaisseaux Sérocytol, suppositoire</NAME>
    <PKG_SIZE>3</PKG_SIZE>
    <SELLING_UNITS>3</SELLING_UNITS>
    <MEASURE>Suppositorien</MEASURE>
    <GALENIC_FORM>suppositoire</GALENIC_FORM>
    <GALENIC_GROUP>unbekannt</GALENIC_GROUP>
    <COMPOSITIONS>
      <COMPOSITION>
        <EXCIPIENS>
          <SUBSTANCE_NAME>Excipiens pro Suppositorio</SUBSTANCE_NAME>
        </EXCIPIENS>
        <SUBSTANCES>
          <SUBSTANCE>
            <SUBSTANCE_NAME>Globulina Equina (immunisé Avec Coeur, Endothélium Vasculaire Porcins)</SUBSTANCE_NAME>
            <IS_ACTIVE_AGENT>false</IS_ACTIVE_AGENT>
            <QTY>8</QTY>
            <UNIT>mg</UNIT>
          </SUBSTANCE>
<..>

Therefore we have hierarchy in oddb2xml

  • ARTICLE
    • GTIN-field
    • COMPOSITIONS-array
      • COMPOSITION
      • EXCIPIENS-field (a substance, implies IS_ACTIVE_AGENT=false)
      • SUBSTANCES-arry
        • SUBSTANCE
        • SUBSTANCE_NAME
        • IS_ACTIVE_AGENT

The composition is derived from a row in the Swissmedic-Packungen.xlsx using the columns A (Zulassungsnummer), B (Dosisstärkenummer, aka sequence-number), C (Präparatebezeichnung), K (Packungscode), Q (Wirkstoff(e)), R (Zusammensetzung)

In oddb.org we have at the moment only substance which describe active agents. A package corresponds to an ARTICLE in oddb_calc which are both identified by a unit GTIN.

  • package
    • swissmedic_source (Column R Zusammensetzung from Swissmedic)
    • active_agents (via @parts.inject([]))
    • compositions (via @parts.inject([]))

Each part has (among others) the following fields

  • @composition.active_agents or

Each part has (among others) the following fields

  • label
  • source

Each active_agent has (among others) the following fields

  • substance
  • chemical_substance
  • equivalent_substance
  • more_info (new)
  • is_active_agent (new, defaults to true if not initialized to be compatible with the old data structure)

There is also a Composition which is attached to each sequence.

Running now jobs/import_swissmedic_only update_compositions to see, whether my changes work. This seems to be running fine. Verifying via bin/admin.

ch.oddb> registration('00334').sequence('01').compositions.first.active_agents.each.collect{ |x| x.more_info}
-> [nil, nil, nil, "conserv.", nil, "conserv.", nil]

But I got the following error

Error: NoMethodError
Message: undefined method `strip!' for #<ParseSubstance:0x00000054589fb8>
Backtrace:
/var/www/oddb.org/src/plugin/swissmedic.rb:1068:in `update_substance'
/var/www/oddb.org/src/plugin/swissmedic.rb:629:in `update_active_agent'
/var/www/oddb.org/src/plugin/swissmedic.rb:739:in `block (2 levels) in update_compositions'
/var/www/oddb.org/src/plugin/swissmedic.rb:726:in `each'
/var/www/oddb.org/src/plugin/swissmedic.rb:726:in `each_with_index'
/var/www/oddb.org/src/plugin/swissmedic.rb:726:in `block in update_compositions'
/var/www/oddb.org/src/plugin/swissmedic.rb:723:in `each'
/var/www/oddb.org/src/plugin/swissmedic.rb:723:in `each_with_index'
/var/www/oddb.org/src/plugin/swissmedic.rb:723:in `update_compositions'
/var/www/oddb.org/src/plugin/swissmedic.rb:136:in `block in update'
/usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-3.3.1/lib/rubyXL/worksheet.rb:23:in `block in each'
/usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-3.3.1/lib/rubyXL/worksheet.rb:23:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-3.3.1/lib/rubyXL/worksheet.rb:23:in `each'
/var/www/oddb.org/src/plugin/swissmedic.rb:118:in `update'
/var/www/oddb.org/src/util/updater.rb:444:in `block in update_swissmedic'
/var/www/oddb.org/src/util/updater.rb:549:in `call'
/var/www/oddb.org/src/util/updater.rb:549:in `wrap_update'
/var/www/oddb.org/src/util/updater.rb:442:in `update_swissmedic'
jobs/import_swissmedic_only:29: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_only:12:in `<module:Util>'
jobs/import_swissmedic_only:11:in `<module:ODDB>'
jobs/import_swissmedic_only:10:in `<main>'

Trying to fix it. Was easy. Restarted import stopped suddenly. Last lines seen were

2015-07-13 20:55:26 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb:637 update_active_agent update 00488/02 active_agent ptr :!registration,00488!sequence,02!composition,24362297!active_agent,Hepatitidis B Virus Antigenum. 4 agent.oid 24362301 substances 'Hepatitidis b Virus Antigenum' ptr :!registration,00488!sequence,02!composition,24362297!active_agent,Hepatitidis B Virus Antigenum.  2 args {:more_info=>nil, :is_active_agent=>false} substance #<ParseSubstance:0x000000468ee400>
2015-07-13 20:55:27 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 1083: update_substance Glycinum

Will continue tomorrow.

view · edit · sidebar · attach · print · history
Page last modified on July 14, 2015, at 09:37 AM