view · edit · sidebar · attach · print · history

20121115-debug-swisswedic-diff-debug-vetoquinol-bbmb

<< | Index | >>


Summary

Commits

Index


Debug swissmedic diff

src/plugin/swissmedic.rb

Check about expiration_date of update_registration

  def update_registration(row, opts = {}) 
      first_day = Date.new(@@today.year, @@today.month, 1)
      ...
      opts[:date] ||= first_day
      ...
        expiration = date_cell(row, column(:expiry_date))
        if expiration.nil?
          @skipped_packages << row 
          return
        end 
        ...
        args = { 
          ...
          :expiration_date     => expiration,
          ...
        }   
        if(expiration < opts[:date])
          args.store :renewal_flag, true
          args.store :renewal_flag_swissmedic, true
        end
        ...
        ...
        @app.update ptr, args, :swissmedic
      end
  end

Swissmedic-Diff

    COLUMNS = [ :iksnr, :seqnr, :name_base, :company, 
                :index_therapeuticus, :atc_class, :production_science,
                :registration_date, :sequence_date, :expiry_date, :ikscd,
                :size, :unit, :ikscat, :substances, :composition,
                :indication_registration, :indication_sequence ]

    def cell(row, pos)
      if(cell = row[pos])
        cell.to_s
      end
    end

    def column(key)
      COLUMNS.index(key)
    end

expiry_date is index 9 (J) of Packungen-latest.xls (correct).
But does not contain 58558 product in following update target.

  • \@diff.changes
  • \@diff.news
  • \@diff.updates
  • \@diff.replacements

And,

  • Only \@diff.newest_rows has 58558

Debug SwissmedicDiff with binding.pry.

# target is "58558"

# "row" is new data.
# "other" is data in previous Packungen-latest.xls.

[6] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> row
=> ["58558",
 1.0,
 "Rotpunkt Apotheke neue Formel, Halsweh-Lutschtabletten",
 "Parcopharm AG",
 "12.03.3.",
 "R02AB02",
 "Synthetika human",
 #<DateTime: 2007-09-21T00:00:00+00:00 ((2454365j,0s,0n),+0s,2299161j)>,
 #<DateTime: 2007-09-21T00:00:00+00:00 ((2454365j,0s,0n),+0s,2299161j)>,
 #<DateTime: 2017-09-20T00:00:00+00:00 ((2458017j,0s,0n),+0s,2299161j)>,
 "003",
 "24",
 "Tablette(n)",
 "D",
 "tyrothricinum, cetylpyridinii chloridum, lidocaini hydrochloridum",
 "tyrothricinum 4 mg, cetylpyridinii chloridum 1 mg, lidocaini hydrochloridum 1 mg, aromatica, excipiens pro compresso.",
 "Infektionen im Mund- und Rachenraum",
 nil,
 0]
[7] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> other
=> ["58558",
 1.0,
 "Rotpunkt Apotheke neue Formel, Halsweh-Lutschtabletten",
 "Parcopharm AG",
 "12.03.3.",
 "R02AB02",
 "Synthetika human",
 #<DateTime: 2007-09-21T00:00:00+00:00 ((2454365j,0s,0n),+0s,2299161j)>,
 #<DateTime: 2007-09-21T00:00:00+00:00 ((2454365j,0s,0n),+0s,2299161j)>,
 #<DateTime: 2017-09-20T00:00:00+00:00 ((2458017j,0s,0n),+0s,2299161j)>,
 "003",
 "24",
 "Tablette(n)",
 "D",
 "tyrothricinum, cetylpyridinii chloridum, lidocaini hydrochloridum",
 "tyrothricinum 4 mg, cetylpyridinii chloridum 1 mg, lidocaini hydrochloridum 1 mg, aromatica, excipiens pro compresso.",
 "Infektionen im Mund- und Rachenraum",
 nil,
 0]
 0]
[8] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> ignore
=> [:atc_class, :sequence_date]

row and other is same.

flags = rows_diff(row, other, ignore) #=> []

SwissmedicDiff does not compare imported Objects.
SwissmedicDiff compares previous XLS and current swissmedic Data .

diff target, @latest, [:atc_class, :sequence_date]
  • target new data.
  • \@latest is previous swissmedic xls (as Packungen-latest.xls).

view · edit · sidebar · attach · print · history
Page last modified on November 15, 2012, at 06:22 AM