Skip to content

Commit

Permalink
Conservative programming to avoid errors in update_swissindex_pharma
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Oct 29, 2013
1 parent 4d44d64 commit 5c54944
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugin/swissindex.rb
Expand Up @@ -172,11 +172,13 @@ def update_out_of_trade
# Process 1
activated = []
@out_of_trade_false_list.each do |pack|
next unless pack and pack.pointer
activated << @app.update(pack.pointer, {:out_of_trade => false, :refdata_override => false}, :refdata)
end
# Process 3
inactivated = []
@out_of_trade_true_list.each do |pack|
next unless pack and pack.pointer
inactivated << @app.update(pack.pointer, {:out_of_trade => true}, :refdata)
end
# for debug
Expand Down Expand Up @@ -223,30 +225,30 @@ def report
lines.push "Check swissindex by eancode and then check if the package is out of trade (true) in ch.oddb,"
lines.push "if so the package becomes in trade (false)"
@out_of_trade_false_list.each do |pack|
lines.push sprintf("%13i: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
lines.push sprintf("%13s: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
end
lines.push nil

lines.push "Updated out of trade (out_of_trade:true) : #{@out_of_trade_true_list.size} packages"
lines.push "If there is no eancode in swissindex and the package is in trade in ch.oddb,"
lines.push "then the package becomes out of trade (true) in ch.oddb"
@out_of_trade_true_list.each do |pack|
lines.push sprintf("%13i: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
lines.push sprintf("%13s: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
end
lines.push nil

lines.push "Updated pharmacode: #{@update_pharmacode_list.size} packages"
lines.push "If the package does not have a pharmacode and there is a pharmacode found in swissindex,"
lines.push "then put the pharmacode into ch.oddb"
@update_pharmacode_list.each do |pack, pharmacode|
lines.push sprintf("%13i: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
lines.push sprintf("%13s: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
end
lines.push nil

lines.push "Deleted pharmacode: #{@delete_pharmacode_list.size} packages"
lines.push "If there is no eancode in swissindex then delete the according pharmacode in ch.oddb"
@delete_pharmacode_list.each do |pack, pharmacode|
lines.push sprintf("%13i: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
lines.push sprintf("%13s: http://ch.oddb.org/de/gcc/drug/reg/%s/seq/%s/pack/%s", pack.barcode, pack.iksnr, pack.seqnr, pack.ikscd)
end
lines.join("\n")
end
Expand Down

0 comments on commit 5c54944

Please sign in to comment.