view · edit · sidebar · attach · print · history

20110518-update-active_agent-de_oddb

<< | Index | >>


  1. Error email import_gkv yesterday
  2. Check class structure, Sequence, Package, Active Agent
  3. Delete all the Wrikstoff but the first one

Goal/Estimate/Evaluation
  • Update active agent / 50% /
Milestones
  • Check the structure among sequence, package, active agent
  • Think how to update the active agents
Summary
Commits
Next
  • Add PDF Producer and version in a report mail

Error email import_gkv yesterday

I got an error email from import_gkv with the updated rpdf2txt yesterday

Tue May 17 16:48:52 2011: de.oddb.org ODDB::Import::Gkv#import
NoMethodError
undefined method `value' for nil:NilClass
./lib/oddb/import/gkv.rb:361:in `postprocess'
./lib/oddb/import/gkv.rb:358:in `each'
./lib/oddb/import/gkv.rb:358:in `postprocess'
./lib/oddb/import/gkv.rb:101:in `import'
/usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:96:in `reported_import'
/usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:103:in `call'
/usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:103:in `_reported_import'
/usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:96:in `reported_import'
/usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:58:in `import_gkv'
/usr/lib64/ruby/1.8/open-uri.rb:32:in `open_uri_original_open'
/usr/lib64/ruby/1.8/open-uri.rb:32:in `open'
./lib/oddb/import/gkv.rb:77:in `download_latest'
/usr/lib64/ruby/site_ruby/1.8/oddb/util/updater.rb:57:in `import_gkv'
jobs/import_gkv:16
./lib/oddb/util/job.rb:16:in `call'
./lib/oddb/util/job.rb:16:in `run'
jobs/import_gkv:15
Imported  6510 Zubef-Entries on 17.05.2011:
Visited   6217 existing Zubef-Entries
Visited   6501 existing Companies
Visited   1136 existing Substances
Created    293 new Zubef-Entries
Created      0 new Products
Created      8 new Sequences
Created      9 new Companies
Created      1 new Substances
Assigned     0 Chemical Equivalences
Assigned     0 Companies
Created      5 Incomplete Packages:
http://de.oddb.org/de/drugs/package/pzn/9075301
http://de.oddb.org/de/drugs/package/pzn/9075347
http://de.oddb.org/de/drugs/package/pzn/9075330
http://de.oddb.org/de/drugs/package/pzn/9075324
http://de.oddb.org/de/drugs/package/pzn/7755606
Created      0 Product(s) without a name (missing product name):

Note

  • But the company names were correctly updated
  • I have also done the import_gkv on the server

Check class structure, Sequence, Package, Active Agent

                                   Sequence
                                      1
 ActiveAgent *--1 Composition *-------+-------* Package

Experiment

masa@masa ~/ywesee/de.oddb.org $ bin/admin
de.oddb> ODDB::Drugs::Package.all[0].active_agents[0].to_s
-> Omeprazol 20 mg

Experiment (check 'Zuzahlungsbefreit', which means if it is true the package data is on Zubef PDF file)

de.oddb> ODDB::Drugs::Package.find_by_name('Jodid 500 Tabletten').code(:zuzahlungsbefreit)
-> 
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').code(:zuzahlungsbefreit)
-> true

Note

  • It looks possible to directly access to the active_agent instance from an package instance

Experiment (check all the 'Zuzahlungsbefreit')

de.oddb> open('/home/masa/work/zuzahl_all.dat','w'){|f| i=0; ODDB::Drugs::Package.all.each{|x| f.print i+=1,"\t", x.code(:cid), "\t", x.code(:zuzahlungsbefreit), "\t", x.cascading_name('de'), "\n"}}

Result

1 3799162 nil Jodid 500 Tabletten
2 3799156 nil Jodid 500 Tabletten
3 4169664 false Amisulprid dura 200 mg Tabletten
4 7356935 nil Omnic Ocas Mg
5 5116078 nil Formatris Ug Inhedp
6 1607715 true  Akineton retard Tabletten
7 3816601 nil Antagonil 20 Kapseln
8 6308325 nil Omnic Ocas 0,4 mg Retardtabletten
9 3816624 nil Antagonil 20 Kapseln
...
42886 nil nil Verasal 240 mg retard Tabletten
42887 nil nil Zanipress 10mg/10mg
42888 nil nil Zurcal S Mg
42889 nil nil Zurcal S Mg
42890 nil nil Zurcal S Mg
42891 nil nil Zurcal S Mg
42892 nil nil Zurcal S Mg
42893 nil nil Zurcal S Mg

Check on browser

Delete all the Wrikstoff but the first one

Plan

  • Delete all the Wirkstoff but the first one if the 'Zuzahlungsbefreit' flag of the package is true
  • from bin/admin command

Refer to lib/oddb/html/state/drugs/admin/sequence.rb#ajax_delete_active_agent

  def ajax_delete_active_agent
    check_model
    keys = [:uid, :active_agent, :composition]
    input = user_input(keys, keys)
    agents = []
    if(!error? \
       && (composition = @model.compositions.at(input[:composition].to_i)))
      if(agent = composition.active_agents.at(input[:active_agent].to_i))
        agent.delete
        composition.remove_active_agent(agent)
        composition.save
      end
      agents = composition.active_agents
    end
    AjaxActiveAgents.new(@session, agents)
  end

Test (delete an active agent on bin/admin)

de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents.length
-> 8
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').code(:cid)
-> 459810
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[2].delete
-> hpidinolydrochloridiTc 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[2].delete
-> Ticidrohlcorlyhpidinod 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[2].delete
-> clopidindiTidryohlcorh 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[2].delete
-> riTclidohlcoroyhpidind 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[2].delete
-> cTidrohlordyhpidinilco 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[2].delete
-> chlordidrTiclopidinhyo 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents[1].delete
-> dTiidrohlcocyhpidinolr 250 mg
de.oddb> ODDB::Drugs::Package.find_by_name('Ticlopidin- Ct 250 mg Filmtabletten').active_agents.length
-> 1

Note

  • I have checked this is reflected to the database after the rebooting

Just in case (backup database)

 masa@masa ~/ywesee/de.oddb.org $ sudo pg_dump -U postgres oddb > oddb_bak_after_import_gkv.sql

Experiment (lib/oddb/util/server.rb#delete_all_active_agent_but_first)

      def delete_all_active_agent_but_first
        ODDB::Drugs::Package.all.each do |pack|
          if pack.code(:zuzahlungsbefreit)
            while pack.active_agents[1]
              pack.active_agents[1].delete
            end
          end
        end
      end

Run

  • Reboot de.oddb/bin/oddbd
masa@masa ~/ywesee/de.oddb.org $ bin/admin
de.oddb> delete_all_active_agent_but_first
-> Array

Result

  • Before
  • After

Note

  • But some Zuzahlungsbefreit flags are not checked even if it is found in the PDF

Example

  • On the pdf
  • On the web

Commit

Check how the Zuzahlungsbefreit flag is set in import_gkv

Refer to

lib/oddb/import/gkv.rb#postprocess

  def postprocess
    Drugs::Package.search_by_code(:type => 'zuzahlungsbefreit',
                                  :value => 'true',
                                  :country => 'DE').each { |package|
      pzn = package.code(:cid).value
      unless(@confirmed_pzns.include?(pzn))
        @deleted += 1
        package.code(:zuzahlungsbefreit).value = false
        save package
      end
...

lib/oddb/import/gkv.rb#import_row

  def import_row(row)
    if row == :doubtful
      @doubtful_pzns.push @created_pzn if @created_pzn
      @created_pzn = nil
      return
    end
    @count += 1
    package = import_package(row)
    return if package.nil?
    @confirmed_pzns.store(package.code(:cid).value, true)
    if(code = package.code(:zuzahlungsbefreit))
      if(code.value)
        @existing += 1
      else
        @created += 1
      end
      code.value = true
    else
      @created += 1
      code = Util::Code.new(:zuzahlungsbefreit, true, 'DE')
      package.add_code(code)
    end
...

Note

  • This code says, the package.code(:zuzahlungsbefreit) definitely becomes true when the importing of a package

Experiment (lib/oddb/import/gkv.rb#import_row)

  def import_row(row)
    if row == :doubtful
      @doubtful_pzns.push @created_pzn if @created_pzn
      @created_pzn = nil
      return
    end
    @count += 1
    package = import_package(row)
    return if package.nil?
    @confirmed_pzns.store(package.code(:cid).value, true)
if row.to_s =~ /3867225/
  p "import_row"
  p package.code(:zuzahlungsbefreit)
end
    if(code = package.code(:zuzahlungsbefreit))
      if(code.value)
        @existing += 1
      else
        @created += 1
      end
      code.value = true
    else
      @created += 1
      code = Util::Code.new(:zuzahlungsbefreit, true, 'DE')
      package.add_code(code)
    end
if row.to_s =~ /3867225/
  p "import_row"
  p package.code(:zuzahlungsbefreit)
end

Result

"import_row"
#<ODDB::Util::Code:0x7f24096f1358 @country="DE", @values={Thu, 13 Dec 2007=>false, Thu, 20 Dec 2007=>true, Tue, 03 Jul 2007=>true}, @type="zuzahlungsbefreit">
"import_row"
#<ODDB::Util::Code:0x7f24096f1358 @country="DE", @values={Thu, 13 Dec 2007=>false, Thu, 20 Dec 2007=>true, Tue, 03 Jul 2007=>true}, @type="zuzahlungsbefreit">

Note

  • The package.code(:zuzahlungsbefreit) is not false
  • It looks true, and it should be shown on the browser, but the Zubef flag check box is not checked on the web interface
view · edit · sidebar · attach · print · history
Page last modified on May 18, 2011, at 04:39 PM