view · edit · sidebar · attach · print · history

20101102-debug-oddb-csv_export

<< Masa.20101103-decorators-for-ebooks | 2010 | Masa.20101101-update-update_bsv >>


  1. Check error report
  2. Confirm the same error locally
  3. Check data
  4. Test export_oddb_csv with older data
  5. Check data again
  6. Create a process to catch the error data and report it
  7. Re-validate limitation text data

Goal
  • Debug oddb csv_export.rb / 70%
Milestones
  1. Check error report
  2. Look at and trace back souce code
  3. Confirm the same error locally 9:45
  4. Trace data 10:20
  5. Test export_oddb_csv with older data
  6. Check data again
  7. Catching the error data and report it suspend
  8. Think about re-validating limitation text data
Summary
Commits
ToDo Tomorrow
  • Re-validate limitation text data
Keep in Mind
Attached Files

Check error report

ch.ODDB.org Report - Error: oddb.csv - 11/2010

Plugin: ODDB::CsvExportPlugin
Error: NoMethodError
Message: undefined method `de' for #<ODDB::Text::Chapter:0x7f1a3caa1b00>
Backtrace:
(eval):2:in `send'
(eval):2:in `send'
/var/www/oddb.org/src/view/drugs/csv_result.rb:195:in `limitation_text'
/var/www/oddb.org/src/view/drugs/csv_result.rb:315:in `send'
/var/www/oddb.org/src/view/drugs/csv_result.rb:315:in `to_csv'
/var/www/oddb.org/src/view/drugs/csv_result.rb:313:in `collect'
/var/www/oddb.org/src/view/drugs/csv_result.rb:313:in `to_csv'
/var/www/oddb.org/src/view/drugs/csv_result.rb:311:in `each'
/var/www/oddb.org/src/view/drugs/csv_result.rb:311:in `to_csv'
/var/www/oddb.org/src/view/drugs/csv_result.rb:309:in `each'
/var/www/oddb.org/src/view/drugs/csv_result.rb:309:in `to_csv'
/var/www/oddb.org/src/view/drugs/csv_result.rb:330:in `to_csv_file'
/var/www/oddb.org/src/view/drugs/csv_result.rb:330:in `open'
/var/www/oddb.org/src/view/drugs/csv_result.rb:330:in `to_csv_file'
/var/www/oddb.org/src/plugin/csv_export.rb:54:in `_export_drugs'
/var/www/oddb.org/src/plugin/csv_export.rb:24:in `export_drugs'
/var/www/oddb.org/src/util/updater.rb:81:in `export_oddb_csv'
/var/www/oddb.org/src/util/updater.rb:448:in `call'
/var/www/oddb.org/src/util/updater.rb:448:in `wrap_update'
/var/www/oddb.org/src/util/updater.rb:79:in `export_oddb_csv'
/var/www/oddb.org/src/util/updater.rb:264:in `update_bsv_followers'
jobs/import_bsv:15
/var/www/oddb.org/src/util/job.rb:17:in `call'
/var/www/oddb.org/src/util/job.rb:17:in `run'
jobs/import_bsv:12

Backtrace the error message

src/util/updater.rb:264

    def update_bsv_followers

      LogFile.append('oddb/debug', " getin update_bsv_followers", Time.now)

      update_trade_status
      update_medwin_packages
      update_lppv
      update_price_feeds
      export_oddb_csv                           #<= here
      # export_oddb2_csv # Disabled 4.1.2010
      export_ouwerkerk
      export_generics_xls
      export_competition_xlss
    end

Notes

  • This comes in update_bsv_followers after update_price_feeds

src/util/updater.rb:79

    def export_oddb_csv(date = @@today)
      subj = 'oddb.csv'
      wrap_update(CsvExportPlugin, subj) {
        plug = CsvExportPlugin.new(@app)
        plug.export_drugs                         #<= here
        log = Log.new(date)
        log.update_values(log_info(plug))
        log.notify(subj)
      }
    end

src/plugin/csv_export.rb:24

    def export_drugs
      @options = { :iconv => 'ISO-8859-1//TRANSLIT//IGNORE' }
      recipients.concat self.class::ODDB_RECIPIENTS
      _export_drugs 'oddb', [ :rectype, :iksnr, :ikscd, :ikskey, :barcode,            #<= here
        :bsv_dossier, :pharmacode, :name_base, :galenic_form,
        :most_precise_dose, :size, :numerical_size, :price_exfactory,
        :price_public, :company_name, :ikscat, :sl_entry, :introduction_date,
        :limitation, :limitation_points, :limitation_text, :lppv,
        :registration_date, :expiration_date, :inactive_date, :export_flag,
        :casrn, :generic_type, :has_generic, :deductible, :out_of_trade,
        :c_type, :index_therapeuticus, :ith_swissmedic, :narcotic, :vaccine ]
    end

Notes

  • In export_drugs, main process is delegated to _export_drugs method

    def _export_drugs(export_name, keys)
      session = SessionStub.new(@app)
      session.language = 'de'
      session.lookandfeel = LookandfeelBase.new(session)
      model = @app.atc_classes.values.sort_by { |atc| atc.code }
      name = "#{export_name}.csv"
      @file_path = path = File.join(EXPORT_DIR, name)
      exporter = View::Drugs::CsvResult.new(model, session)
      exporter.to_csv_file(keys, path, :packages)                  #<= here
      dups = exporter.duplicates
      @counts = exporter.counts
      @counts['duplicates'] = dups.size
      unless(dups.empty?)
        log = Log.new(@@today)
        log.report = sprintf "CSV-Export includes %i duplicates:\n%s",
                             dups.size, dups.join("\n")
        log.notify("CSV-Export includes %i duplicates" % dups.size)
      end
      EXPORT_SERVER.compress(EXPORT_DIR, name)
      backup = @app.log_group(:bsv_sl).newest_date.strftime("#{export_name}.%Y-%m-%d.csv")
      backup_dir = File.expand_path('../../data/csv', File.dirname(__FILE__))
      backup_path = File.join(backup_dir, backup)
      unless(File.exist? backup_path)
        FileUtils.mkdir_p(backup_dir)
        FileUtils.cp(path, backup_path)
      end
    rescue
      puts $!.message
      puts $!.backtrace
      raise
    end

src/view/drugs/csv_result.rb:330

  def to_csv_file(keys, path, symbol=:active_packages)
    File.open(path, 'w') { |fh| fh.puts to_csv(keys, symbol) }     #<= here
  end

Check arguments

  def to_csv_file(keys, path, symbol=:active_packages)
print "keys="
p keys
print "path="
p path
print "symbol="
p symbol
exit
    File.open(path, 'w') { |fh| fh.puts to_csv(keys, symbol) }
  end

Result

keys=[:rectype, :iksnr, :ikscd, :ikskey, :barcode, :bsv_dossier, :pharmacode, :name_base, :galenic_form, :most_precise_dose, :size, :numerical_size, :price_exfactory, :price_public, :company_name, :ikscat, :sl_entry, :introduction_date, :limitation, :limitation_points, :limitation_text, :lppv, :registration_date, :expiration_date, :inactive_date, :export_flag, :casrn, :generic_type, :has_generic, :deductible, :out_of_trade, :c_type, :index_therapeuticus, :ith_swissmedic, :narcotic, :vaccine]
path="/home/masa/ywesee/oddb.org/data/downloads/oddb.csv"
symbol=:packages

src/view/drugs/csv_result.rb:309

  def to_csv(keys, symbol=:active_packages)
    eans = {}
    result = []
    lang = @lookandfeel.language
    header = keys.collect { |key|
      @lookandfeel.lookup("th_#{key}") || key.to_s
    }
    result.push(header)
    @model.each { |atc|                        #<= here
      result.push(['#MGrp', atc.code.to_s, atc.description(lang).to_s])
      atc.send(symbol).each { |pack|
        eans[pack.ikskey] = eans[pack.ikskey].to_i + 1
        line = keys.collect { |key|
          if(self.respond_to?(key))
            self.send(key, pack)
          else
            pack.send(key)
          end
        }
        result.push(line)
      }
    }
    @duplicates = eans.collect { |ikskey, count|
      ikskey if count > 1 }.compact.sort
    result.collect { |line|
      CSV.generate_line(line, ';')
    }.join("\n")
  end

Check variables

  def to_csv(keys, symbol=:active_packages)
p "getin to_csv"
print "keys="
p keys
print "symbol="
p symbol

    eans = {}
    result = []
    lang = @lookandfeel.language
print "lang="
p lang
    header = keys.collect { |key|
      @lookandfeel.lookup("th_#{key}") || key.to_s
    }
print "header="
p header
    result.push(header)
print "@model.class="
p @model.class
print "@model.size="
p @model.size
exit

Result

keys=[:rectype, :iksnr, :ikscd, :ikskey, :barcode, :bsv_dossier, :pharmacode, :name_base, :galenic_form, :most_precise_dose, :size, :numerical_size, :price_exfactory, :price_public, :company_name, :ikscat, :sl_entry, :introduction_date, :limitation, :limitation_points, :limitation_text, :lppv, :registration_date, :expiration_date, :inactive_date, :export_flag, :casrn, :generic_type, :has_generic, :deductible, :out_of_trade, :c_type, :index_therapeuticus, :ith_swissmedic, :narcotic, :vaccine]
symbol=:packages
lang="de"
header=["rectype", "Reg.-Nr.", "Packungsnummer", "Swissmedic-Nr.", "EAN-Code", "BSV-Dossier", "Pharmacode", "Pr\303\244parat", "Galenische Form", "St\303\244rke", "Packungsgr\303\266sse", "Numerisch", "EFP", "PP", "Zulassungsinh.", "Kat.", "SL", "Aufnahme in SL", "Limitation", "Limitationspunkte", "Limitationstext", "LPPV", "Reg.Dat.", "G\303\274ltig bis", "Deaktiviert", "Exportprodukt", "CAS Reg.Nr.", "generic_type", "Hat ein Generikum", "SB", "Ausser Handel (MedRef)", "Komplement\303\244rprodukt", "Index Therapeuticus (BAG)", "Index Therapeuticus (Swissmedic)", "Bet\303\244ubungsmittel", "Impfstoff/Blutprodukt"]
@model.class=Array
@model.size=7303

Confirm the same error locally

src/util/updater.rb#run

    def run
      logfile_stats
=begin
      if(update_swissmedic)
        update_swissmedic_followers
      end
      update_swissmedicjournal
      update_vaccines

      return_value_update_bsv = update_bsv
      LogFile.append('oddb/debug', " return_value_update_bsv=" + return_value_update_bsv.inspect.to_s, Time.now)

      #if(update_bsv)
      if(return_value_update_bsv)
=end
        update_bsv_followers
=begin
      end
      update_narcotics
      run_on_monthday(1) {
        update_interactions 
      }
=end
    end

src/util/updater.rb#update_bsv_followers

    def update_bsv_followers

      LogFile.append('oddb/debug', " getin update_bsv_followers", Time.now)
=begin
      update_trade_status
      update_medwin_packages
      update_lppv
      update_price_feeds
=end
      export_oddb_csv
      # export_oddb2_csv # Disabled 4.1.2010
=begin
      export_ouwerkerk
      export_generics_xls
      export_competition_xlss
=end
    end

Run jobs/import_daily

Result

Plugin: ODDB::CsvExportPlugin
Error: NoMethodError
Message: undefined method `de' for #<ODDB::Text::Chapter:0x7fcb75d2c218>
Backtrace:
(eval):2:in `send'
(eval):2:in `send'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:195:in `limitation_text'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:315:in `send'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:315:in `to_csv'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:313:in `collect'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:313:in `to_csv'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:311:in `each'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:311:in `to_csv'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:309:in `each'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:309:in `to_csv'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:330:in `to_csv_file'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:330:in `open'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:330:in `to_csv_file'
/home/masa/ywesee/oddb.org/src/plugin/csv_export.rb:54:in `_export_drugs'
/home/masa/ywesee/oddb.org/src/plugin/csv_export.rb:24:in `export_drugs'
/home/masa/ywesee/oddb.org/src/util/updater.rb:82:in `export_oddb_csv'
/home/masa/ywesee/oddb.org/src/util/updater.rb:456:in `call'
/home/masa/ywesee/oddb.org/src/util/updater.rb:456:in `wrap_update'
/home/masa/ywesee/oddb.org/src/util/updater.rb:80:in `export_oddb_csv'
/home/masa/ywesee/oddb.org/src/util/updater.rb:270:in `update_bsv_followers'
/home/masa/ywesee/oddb.org/src/util/updater.rb:217:in `run'
jobs/import_daily:13
/home/masa/ywesee/oddb.org/src/util/job.rb:17:in `call'
/home/masa/ywesee/oddb.org/src/util/job.rb:17:in `run'
jobs/import_daily:12

Check data

Experiment

src/view/drugs/csv_result.rb

  def to_csv(keys, symbol=:active_packages)
    eans = {}
    result = []
    lang = @lookandfeel.language
    header = keys.collect { |key|
      @lookandfeel.lookup("th_#{key}") || key.to_s
    }
    result.push(header)
print "@model.length=", @model.length, "\n"
#   @model.each { |atc|
    @model.each_with_index { |atc, i|
puts i
      result.push(['#MGrp', atc.code.to_s, atc.description(lang).to_s])
      atc.send(symbol).each { |pack|
        eans[pack.ikskey] = eans[pack.ikskey].to_i + 1
        line = keys.collect { |key|
          if(self.respond_to?(key))
            self.send(key, pack)
          else
            pack.send(key)
          end
        }
        result.push(line)
      }
    }
    @duplicates = eans.collect { |ikskey, count|
      ikskey if count > 1 }.compact.sort
    result.collect { |line|
      CSV.generate_line(line, ';')
    }.join("\n")
  end

Result

...
1048
1049
1050
1051
1052
1053
1054
undefined method `de' for #<ODDB::Text::Chapter:0x7f275241ce60>
(eval):2:in `send'
(eval):2:in `send'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:195:in `limitation_text'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:318:in `send'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:318:in `to_csv'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:316:in `collect'
...

Experiment

  def to_csv(keys, symbol=:active_packages)
    eans = {}
    result = []
    lang = @lookandfeel.language
    header = keys.collect { |key|
      @lookandfeel.lookup("th_#{key}") || key.to_s
    }
    result.push(header)
print "@model.length=", @model.length, "\n"
#   @model.each { |atc|
    @model.each_with_index { |atc, i|
if i >= 1054
puts i
print "atc.send(#{symbol}).length=", atc.send(symbol).length, "\n"
print "atc.packages.length=", atc.packages.length, "\n"
print "atc.class=", atc.class, "\n"
#print "atc.methods=" 
#p atc.methods
print "atc.packages[0].class="
p atc.packages[0].class
      result.push(['#MGrp', atc.code.to_s, atc.description(lang).to_s])
      atc.send(symbol).each { |pack|
        eans[pack.ikskey] = eans[pack.ikskey].to_i + 1
        line = keys.collect { |key|
          if(self.respond_to?(key))
print "call #{self.class}.#{key}(#{pack.class})\n"
            self.send(key, pack)
          else
            pack.send(key)
          end
        }
        result.push(line)
      }
end
    }
    @duplicates = eans.collect { |ikskey, count|
      ikskey if count > 1 }.compact.sort
    result.collect { |line|
      CSV.generate_line(line, ';')
    }.join("\n")
  end

Result

...
call ODDB::View::Drugs::CsvResult.price_public(ODDB::Package)
call ODDB::View::Drugs::CsvResult.sl_entry(ODDB::Package)
call ODDB::View::Drugs::CsvResult.introduction_date(ODDB::Package)
call ODDB::View::Drugs::CsvResult.limitation(ODDB::Package)
call ODDB::View::Drugs::CsvResult.limitation_points(ODDB::Package)
call ODDB::View::Drugs::CsvResult.limitation_text(ODDB::Package)
undefined method `de' for #<ODDB::Text::Chapter:0x7f1e9f61d6a8>
(eval):2:in `send'
(eval):2:in `send'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:195:in `limitation_text'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:327:in `send'
...

src/view/drugs/csv_result.rb

  def limitation_text(pack)
    if((sl = pack.sl_entry) && (txt = sl.limitation_text))
      @counts['limitation_texts'] += 1
      txt.send(@lookandfeel.language).to_s.gsub(/\n/u, '|')
    end
  end

Experiment

  def limitation_text(pack)
    if((sl = pack.sl_entry) && (txt = sl.limitation_text))
print "sl.class=", sl.class, "\n"
print "txt.class=",txt.class, "\n"
print "@lookandfee.language=", @lookandfeel.language, "\n"
      @counts['limitation_texts'] += 1
      txt.send(@lookandfeel.language).to_s.gsub(/\n/u, '|')
    end
  end

Result

...
sl.class=ODDB::SlEntry
txt.class=ODDB::LimitationText
@lookandfee.language=de
undefined method `de' for #<ODDB::Text::Chapter:0x7f4e66f93fd8>
(eval):2:in `send'
(eval):2:in `send'
...

Consider

  • I guess it means that there is no data corresponding to 'de' (deutch) of the limitation text data
  • Let's see

Test export_oddb_csv with older data

Run export_oddb_csv method with data on 20101026

$ sudo -u postgres dropdb oddb.org
$ sudo -u postgres createdb -E UTF8 -T template0 oddb.org
$ zcat oddb.org.20101026.sql.gz | psql -U postgres oddb.org

Result

anthroposophy                      294
bsv_dossiers                      3253
complementary                      283
deductible_g                      8343
deductible_o                        72
duplicates                           0
expiration_date                  20889
export_registrations               573
galenic_forms                      298
generics                          4384
has_generic                          0
homeopathy                         809
inactive_date                     4073
limitation_both                    141
limitation_points                  141
limitation_texts                  1293
limitations                       1295
lppv                               607
missing_size                        27
originals                         2074
out_of_trade                      3209
phytotherapy                      1332
price_exfactory                   9520
price_public                     12099
registration_date                22522
routes_of_administration             0
sl_entries                        8415

Consider

  • The updating yesterday 20101101 (update_bsv, XMLPublications.zip) must cause the error (I am sure of it 80%)

Check data again

Experiment

src/view/drugs/csv_result.rb

  def limitation_text(pack)
    if((sl = pack.sl_entry) && (txt = sl.limitation_text))
print "txt.to_s="
p txt.to_s
      @counts['limitation_texts'] += 1
      txt.send(@lookandfeel.language).to_s.gsub(/\n/u, '|')
    end
  end

Run export_oddb_csv using the latest data

Result

....
txt.to_s="Zavesca\n\nZur Behandlung von erwachsenen Patienten mit leichter bis mittelschwerer Form des Morbus Gaucher Typ 1, f\303\274r welche eine Enzymsubstitutionstherapie nicht m\303\266glich ist."
@lookandfee.language=de
txt.to_s="Zulassungsnummer\n57054 (Swissmedic)."
undefined method `de' for #<ODDB::Text::Chapter:0x7ffbec69d0d0>
(eval):2:in `send'
(eval):2:in `send'
/home/masa/ywesee/oddb.org/src/view/drugs/csv_result.rb:204:in `limitation_text'
....

Experiment

  def limitation_text(pack)
    if((sl = pack.sl_entry) && (txt = sl.limitation_text))
print "sl.class=", sl.class, "\n"
print "txt.class=",txt.class, "\n"
print "txt.to_s="
p txt.to_s
      @counts['limitation_texts'] += 1
print "txt.methods.sort="
pp txt.methods.sort
      txt.send(@lookandfeel.language).to_s.gsub(/\n/u, '|')
    end
  end

Result

masa@masa ~/ywesee/oddb.org $ diff methods1.dat methods2.dat 
3c3
< txt.to_s="Zavesca\n\nZur Behandlung von erwachsenen Patienten mit leichter bis mittelschwerer Form des Morbus Gaucher Typ 1, f\303\274r welche eine Enzymsubstitutionstherapie nicht m\303\266glich ist."
---
> txt.to_s="Zulassungsnummer\n57054 (Swissmedic)."
20a21
>  "clean!",
22,23d22
<  "code",
<  "code=",
33,34d31
<  "description",
<  "descriptions",
39a37
>  "empty?",
50c48
<  "has_description?",
---
>  "gsub!",
51a50,51
>  "heading",
>  "heading=",
53a54
>  "include?",
74d74
<  "method_missing",
76d75
<  "name",
78a78
>  "next_section",
81,82d80
<  "niveau",
<  "niveau=",
122a121
>  "paragraphs",
148c147,148
<  "search_text",
---
>  "sections",
>  "sections=",
169a170
>  "to_search",
178d178
<  "type=",
185,188d184
<  "valid_from",
<  "valid_from=",
<  "value",
<  "value=",

Notes

  • The kinds of methods are different from the other data case
  • Only this data case cannot call 'description' method
  • In other words, only this data does not call method_missing method

Consider

  • txt.send(@ookandfeel.language) means txt(LimitationText).description('de')
  • And the description is called from method_missing method in src/util/language.rb (ODDB::SimpleLanguage)
  • But only in this data case, this send method does not call the method_missing method.
  • I do not know why. The class is the same as the others, ODDB::LimitationText.

Create a process to catch the error data and report it

Reference

Experiment

src/view/drugs/csv_result.rb#to_csv

  def to_csv(keys, symbol=:active_packages)
    eans = {}
    result = []
    lang = @lookandfeel.language
    header = keys.collect { |key|
      @lookandfeel.lookup("th_#{key}") || key.to_s
    }
    result.push(header)
print "@model(#{@model.class}).length=", @model.length, "\n"
#   @model.each { |atc|
    @model.each_with_index { |atc, i|
      result.push(['#MGrp', atc.code.to_s, atc.description(lang).to_s])
      atc.send(symbol).each { |pack|
        eans[pack.ikskey] = eans[pack.ikskey].to_i + 1
        line = keys.collect { |key|
          if(self.respond_to?(key))
begin
            self.send(key, pack)
rescue NoMethodError
  sl = pack.sl_entry
  txt = sl.limitation_text
  print i, ": "
  p txt
  p txt.to_s
end
          else
            pack.send(key)
          end
        }
        result.push(line)
      }
    }

Result

"getin export_oddb_csv"
@model(Array).length=7303
1054: "Zulassungsnummer\n57054 (Swissmedic)."
#<ODDB::Text::Chapter:0x7f713079a3d0 @sections=[#<ODDB::Text::Section:0x7f713079a178 @paragraphs=[#<ODDB::Text::Paragraph:0x7f713079a038 @preformatted=false, @formats=
[#<ODDB::Text::Format:0x7f7130799ea8 @end=-1, @values=[], @start=0>], @text="57054 (Swissmedic).", @raw_txt=nil, @format=#<ODDB::Text::Format:0x7f7130799ea8 @end=-1, @values=[], @start=0>>], 
@subheading="">], @odba_persistent=true, @heading="Zulassungsnummer", @odba_id=25419791, @odba_observers=[]>

1054: "Zulassungsinhaberin\nMerz Pharma (Schweiz) AG, 4123 Allschwil."
#<ODDB::Text::Chapter:0x7f71307594e8 @sections=[#<ODDB::Text::Section:0x7f71307591c8 @paragraphs=[#<ODDB::Text::Paragraph:0x7f7130759060 @preformatted=false, @formats=
[#<ODDB::Text::Format:0x7f7130758e80 @end=-1, @values=[], @start=0>], @text="Merz Pharma (Schweiz) AG, 4123 Allschwil.", @raw_txt=nil, @format=#<ODDB::Text::Format:0x7f7130758e80 @end=-1, @values=[],
 @start=0>>], @subheading="">], @odba_persistent=true, @heading="Zulassungsinhaberin", @odba_id=25419804, @odba_observers=[]>

3806: "AMZV"
#<ODDB::Text::Chapter:0x7f7129aeddb8 @sections=[], @odba_persistent=true, @heading="AMZV", @odba_id=25419754, @odba_observers=[]>

4057: "#<ODDB::FachinfoDocument2001:0x7f7127e8d2e0>"
#<ODDB::FachinfoDocument2001:0x7f7127e8d2e0 @driving_ability=#<ODBA::Stub:70061988799940#25419749 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @kinetic=#
<ODBA::Stub:70061988800000#25419750 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @date=#<ODBA::Stub:70061988800160#25419747 @odba_class=ODDB::Text::Chapter 
@odba_container=70061988800880#25419720>, @distribution=nil, @unwanted_effects=#<ODBA::Stub:70061988799680#25419753 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @amzv=#
<ODBA::Stub:70061988799740#25419754 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @pregnancy=#<ODBA::Stub:70061988799560#25419755 @odba_class=ODDB::Text::Chapter 
@odba_container=70061988800880#25419720>, @effects=#<ODBA::Stub:70061988799620#25419756 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @composition=#
<ODBA::Stub:70061988799880#25419752 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @interactions=#<ODBA::Stub:70061988800800#25419742 @odba_class=ODDB::Text::Chapter 
@odba_container=70061988800880#25419720>, @odba_persistent=true, @delivery=nil, @name="Contractubex\302\256", @reference=nil, @registration_owner=#<ODBA::Stub:70061988799400#25419757 
@odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @restrictions=#<ODBA::Stub:70061988799460#25419758 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, 
@packages=nil, @galenic_form=#<ODBA::Stub:70061988800560#25419740 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @contra_indications=#<ODBA::Stub:70061988800620#25419741 
@odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @indications=#<ODBA::Stub:70061988799800#25419751 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, 
@other_advice=#<ODBA::Stub:70061988800420#25419743 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @usage=#<ODBA::Stub:70061988800240#25419745 @odba_class=ODDB::Text::Chapter 
@odba_container=70061988800880#25419720>, @preclinic=#<ODBA::Stub:70061988800300#25419746 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @fabrication=nil, @odba_id=25419720, 
@overdose=#<ODBA::Stub:70061988800060#25419748 @odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>, @odba_observers=[], @iksnrs=#<ODBA::Stub:70061988800500#25419744 
@odba_class=ODDB::Text::Chapter @odba_container=70061988800880#25419720>>

4057: "Effet sur l\342\200\231aptitude \303\240 la conduite et l\342\200\231utilisation de machines\nAucune \303\251tude correspondante n\342\200\231a \303\251t\303\251 effectu\303\251e. La 
probabilit\303\251 que le principe actif, l\342\200\231h\303\251parine sodique, soit disponible syst\303\251miquement \303\251tant tr\303\250s faible, aucune entrave \303\240 l\342\200\231aptitude 
\303\240 la conduite ou \303\240 l\342\200\231utilisation de machines n\342\200\231est \303\240 craindre."
#<ODDB::Text::Chapter:0x7f7127e72058 @sections=[#<ODDB::Text::Section:0x7f7127e71f40 @paragraphs=[#<ODDB::Text::Paragraph:0x7f7127e71e50 @preformatted=false, @formats=
[#<ODDB::Text::Format:0x7f7127e71d88 @end=-1, @values=[], @start=0>], @text="Aucune \303\251tude correspondante n\342\200\231a \303\251t\303\251 effectu\303\251e. La probabilit\303\251 que le principe 
actif, l\342\200\231h\303\251parine sodique, soit disponible syst\303\251miquement \303\251tant tr\303\250s faible, aucune entrave \303\240 l\342\200\231aptitude \303\240 la conduite ou \303\240 
l\342\200\231utilisation de machines n\342\200\231est \303\240 craindre.", @raw_txt=nil, @format=#<ODDB::Text::Format:0x7f7127e71d88 @end=-1, @values=[], @start=0>>], @subheading="">], 
@odba_persistent=true, @heading="Effet sur l\342\200\231aptitude \303\240 la conduite et l\342\200\231utilisation de machines", @odba_id=25419730, @odba_observers=[]>

Notes

  • The number of error data is 5

src/view/drugs/csv_result.rb#to_csv

  def to_csv(keys, symbol=:active_packages)
    eans = {}
    result = []
    lang = @lookandfeel.language
    header = keys.collect { |key|
      @lookandfeel.lookup("th_#{key}") || key.to_s
    }
    result.push(header)
print "@model(#{@model.class}).length=", @model.length, "\n"
#   @model.each { |atc|
    @model.each_with_index { |atc, i|
      result.push(['#MGrp', atc.code.to_s, atc.description(lang).to_s])
      atc.send(symbol).each { |pack|
        eans[pack.ikskey] = eans[pack.ikskey].to_i + 1
        line = keys.collect { |key|
          if(self.respond_to?(key))
begin
            self.send(key, pack)
rescue NoMethodError
  sl = pack.sl_entry
  txt = sl.limitation_text
  print i, ": "
  p txt.to_s
  print "package.barcode=", pack.barcode, "\n"
  print "url= http://ch.oddb.org/de/gcc/compare/ean13/", pack.barcode, "\n"
  print "\n"
end
          else
            pack.send(key)
          end
        }
        result.push(line)
      }
    }

Result

"getin export_oddb_csv"
@model(Array).length=7303

1054: "Zulassungsnummer\n57054 (Swissmedic)."
package.barcode=7680469280163
url= http://ch.oddb.org/de/gcc/compare/ean13/7680469280163 '''Kybernin'''

1054: "Zulassungsinhaberin\nMerz Pharma (Schweiz) AG, 4123 Allschwil."
package.barcode=7680469280248 '''Kybernin'''
url= http://ch.oddb.org/de/gcc/compare/ean13/7680469280248

3806: "AMZV"
package.barcode=7680517590282 '''Klacid'''
url= http://ch.oddb.org/de/gcc/compare/ean13/7680517590282

4057: "#<ODDB::FachinfoDocument2001:0x7f5c132d3c48>"
package.barcode=7680574690048 '''Kiovig'''
url= http://ch.oddb.org/de/gcc/compare/ean13/7680574690048

4057: "Effet sur l\342\200\231aptitude \303\240 la conduite et l\342\200\231utilisation de machines\nAucune \303\251tude correspondante n\342\200\231a \303\251t\303\251 effectu\303\251e. La probabilit\303\251 que le principe actif, l\342\200\231h\303\251parine sodique, soit disponible syst\303\251miquement \303\251tant tr\303\250s faible, aucune entrave \303\240 l\342\200\231aptitude \303\240 la conduite ou \303\240 l\342\200\231utilisation de machines n\342\200\231est \303\240 craindre."
package.barcode=7680574690055 '''Kiovig'''
url= http://ch.oddb.org/de/gcc/compare/ean13/7680574690055

Notes

Re-validate limitation text data

Idea

  • How about running update_bsv again?

Run update_bsv again locally

...
Created Limitation-Texts                                      4
Updated Limitation-Texts                                   1301
Deleted Limitation-Texts                                      0
...

Result (run export_csv again, the same script as above)

"getin export_oddb_csv"
@model(Array).length=7303

Notes

view · edit · sidebar · attach · print · history
Page last modified on July 13, 2011, at 11:57 AM