view · edit · sidebar · attach · print · history

20121126-update-swissmedic-updater

<< | Index | >>


Summary

  • Debug & Update swissmedic updater
    • check date-fields of stored data at diff (after swissmedic-diff)

Index


Update swissmedic updater

[0] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> @diff.updates.map{|row| row[0] }.include?('58558')
=> true
[1] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> @diff.updates.map{|row| row[0] }.index('58558')
=> 12756
[2] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> @diff.updates[12756]
=> ["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]

check_date!

Update to check diff from stored data.

  • Registration#registration_date
  • Registration#expiration_date

Re-Check with @diff.newest_rows (all rows in Packungen.xls)

in src/plugin/swissmedic.rb

    # check diff from overwritten stored-objects by admin
    # about data-fields
    def check_date!
      @diff.newest_rows.values.each do |obj|
        obj.values.each do |row|
          iksnr = row[0]
          if reg = @app.registration(iksnr.to_s)
            {   
              :registration_date => 7,
              :expiration_date   => 9
            }.each_pair do |field, i|
              # if future date given
              if row[i].is_a?(Date) and 
                 (!reg.send(filed).is_a?(Date) or row[i] > reg.send(field))
                @diff.updates << row 
              end 
            end 
          end 
        end 
      end 
      @diff.updates.uniq!
    end 
# new data
[0] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> @diff.updates.map{|row| row[0]}.index('58558')
=> 800
[1] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> @diff.updates[800]
=> ["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]

# current value in ch.oddb.org
[3] 1.9.3-p194(#<ODDB::SwissmedicPlugin>)> @app.registration('58558').expiration_date
=> #<Date: 2012-09-20 ((2456191j,0s,0n),+0s,2299161j)>
view · edit · sidebar · attach · print · history
Page last modified on November 27, 2012, at 01:23 AM