view · edit · sidebar · attach · print · history

20111115-memory-check-debug-missing-active_agent-oddb_org

<< | Index | >>


  1. Memory test
  2. Debug missing active agents

Goal/Estimate/Evaluation
  • Debug missing active agents / 50% / 50%
Milestones
  1. Memory check
  2. Debug missing active agenqts

Memory test

Result

  • No error (test#1 - test#8)

Reference

Debug missing active agents

Email

Problem

Note

  • despite the fact that the active agents are saved in the sequence view

Note

  • As for 'Donepezil Actavis', the Package@compositions become [] (empty array)

Experiment

ch.oddb> registration('61815').sequence('02').package('016').name
-> Donepezil Actavis 10 mg, Filmtabletten
ch.oddb> registration('61815').sequence('02').package('016').compositions.inspect
-> []

ch.oddb> registration('61815').sequence('02').compositions
-> Tabletten: Donepezili Hydrochloridum 10 mg


ch.oddb> registration('62044').sequence('01').package('001').name
-> Atorvastatin Axapharm 10 mg, Filmtabletten
ch.oddb> registration('62044').sequence('01').package('001').compositions
-> Filmtabletten: Atorvastatinum 10 mg

Note

  • Sequence@compositions has a value
  • 'speichern' in a package view show the active agents in a drug search view
    • -> 'speichern' process maybe creates Package@part@composition instance
  • These data was imported on 11.11.2011 by update_swissmedic (src/plugin/swissmedic.rb) from Packungen.xls
  • It looks like as follows
    • If there is Package@compositions (Part@composition != nil), then Sequence@compositinos are reflected to Package@compositions
    • But if Package@compositions has nothing (Part@composition == nil), then Sequence@compositions are not reflected to Package@compositions

Experiment

  • src/state/admin/sequence.rb
 def update_compositions(input)
    saved = nil
    if(substances = input[:substance])
      substances.each { |cmp_idx, substances|
        doses = input[:dose][cmp_idx]
        galform = input[:galenic_form][cmp_idx]
        cmp_idx = cmp_idx.to_i
        comp = @model.compositions.at(cmp_idx)
        ptr = comp ? comp.pointer : (@model.pointer + :composition).creator
        comp = @session.app.update ptr, { :galenic_form => galform },
                                   unique_email
        substances.each { |sub_idx, sub|
          ## create missing substance on the fly
          unless @session.app.substance(sub)
            sptr = Persistence::Pointer.new(:substance)
            @session.app.update(sptr.creator, 'lt' => sub)
          end
          parts = doses[sub_idx]
          sub_idx = sub_idx.to_i
          agent = comp.active_agents.at(sub_idx)
          ptr = agent ? agent.pointer                       : (comp.pointer + [:active_agent, sub]).creator

 pac = @model.packages.values[0]
 p "A"
 p pac.compositions.first.to_s
          agent = @session.app.update ptr, { :dose => parts, :substance => sub },
                                      unique_email
 p "B"
 p pac.compositions.first.to_s

          unless agent.substance
            key = :"substance[#{cmp_idx}][#{sub_idx}]"
            @errors.store key, create_error(:e_unknown_substance, key, sub)
          end
        }
      }
    end
    saved
 end

Run

  • oddbd
  • update active agent in Admin Sequence view

Result

  • case: Atorvastatin Axapharm 10 mg
"A"
"Filmtabletten: Atorvastatinum 10 mg"
"B"
"Filmtabletten: Atorvastatinum 120 mg"
  • case: Donepezil Actavis 10 mg
"A"
""
"B"
""

Note

  • active_agent, substance, composition are related complicatedly with each other
  • State::Admin::Sequence#update_composition method updates the compositions of both Sequence and Package
  • But if the Package@compositions variable == nil, this does not work

Question

  • Sequence@compositions == Package@compositions?

Note

  • Sequence@compositinos: Array of ODDB::Composition instances
  • Composition@active_agents: Array of ODDB::ActiveAgent instances
  • Package@parts: Array of ODDB::Part instances
  • Part@composition: ODDB::Composition instance
  • Package#compositions: Array of Part@composition (ODDB::Composition instances)

Experiment

ch.oddb> registration('61815').sequence('02').package('026').parts.first.composition = registration('61815').sequence('02').compositions.first
-> Tabletten: Donepezili Hydrochloridum 120 mg

Reload

Result

Note

  • This result will be gone after rebooting, because the package instance is not saved in the database
  • Maybe updater (update_swissmedic) does not create a Package#parts@composition instance

Check update_swissmedic

Experiment

  • src/plugin/swissmedic.rb
    def update_package(reg, seq, row, replacements={},
                       opts={:create_only => false})
 ...
        if !part.composition           && (comp = seq.compositions[pidx] || seq.compositions.last)
          args.store :composition, comp.pointer
        end
        @app.update(part.pointer, args, :swissmedic)
      end
    end
view · edit · sidebar · attach · print · history
Page last modified on November 16, 2011, at 07:26 AM