#!/usr/bin/env ruby Pharmacodes_with_problems = { 5769834 => 2.69, 4939228 => 2.33, 1800487 => 29.06, 2764434 => 34.47, 2117031 => 3.55, 2164852 => 0.78, 692771 => 0.69, 1337003 => 0.58, 1337026 => 0.53, 1239424 => 0.58, 1239430 => 0.53, 1539250 => 0.58, 1539267 => 0.53, 3105886 => 0.63, 3105892 => 0.69, 1191143 => 0.50, 1191166 => 0.46, 1589236 => 0.50, 1589242 => 0.46, 5798675 => 0.95, 5798681 => 0.75, 5798698 => 0.95, 1851160 => 17.15, 5304489 => 5.11, 5416113 => 4.62, 5304503 => 3.75, 5416136 => 3.39, 1709479 => 0.66, 1709025 => 0.55, 823902 => 0.77, 1997550 => 0.60, 1997596 => 0.46, 5804766 => 0.55, 5804772 => 0.41, 3980832 => 0.96, 3980861 => 0.60, 5644877 => 0.38, 1459640 => 13.15, 1599157 => 4.78, 2635412 => 1.33, 2635429 => 1.03, 2519114 => 0.89, 2519120 => 0.69, 2519137 => 0.67, 2519143 => 0.52, 2519166 => 0.44, 2519172 => 0.34, 2519189 => 0.33, 2519195 => 0.26, 1611622 => 0.76, 2013337 => 1.20, 2013343 => 0.92, 1719555 => 0.66, 1576647 => 0.51, 2013372 => 0.37, 3585366 => 2.35, 1592391 => 1.88, 726234 => 0.98, 3030622 => 1.95, 1480829 => 5.21, 853406 => 5.84, 3037883 => 3.31, 3037908 => 2.75, 4859127 => 184.46, 2117019 => 15.80, 2583626 => 16.13, 2583632 => 14.31, 4474189 => 1.97, 1518029 => 1.25, 5499458 => 2.94, 959889 => 0.37, 2734976 => 1.18, 5862999 => 2.13, 5863007 => 1.20, 353514 => 3.48, 2155267 => 3.83, 2208992 => 9.36, 1237402 => 1.84, 5885658 => 2.84, 3107951 => 6.50, 2381420 => 4.46, 1041774 => 1.91, 1909072 => 1.37, 1909089 => 1.43, 6195186 => 1.93, 5030951 => 0.99, 5030968 => 1.03, 1906665 => 13.23, 909549 => 1.29, 1312440 => 1.16, 984539 => 1.29, 2569508 => 20.52, 2569514 => 18.53, 2569520 => 16.82, 1514132 => 0.77, 53396 => 2.07, 6132139 => 1.38, 2970352 => 0.93, 6443649 => 0.98, 6443655 => 0.76, 4665185 => 5.11, 4960731 => 3.70, 4960748 => 3.20, 4960754 => 2.27, 1726288 => 43.43, 4951761 => 2.25, 1962899 => 2.85, 365635 => 13.13, 1580749 => 1.38, 2767817 => 5.13, 5566947 => 1.38, 3694109 => 1.88, 746314 => 1.30, 816983 => 4.20, 1800406 => 4.20, 2518899 => 1.92, 534635 => 7.46, } nr_fixed = 0 not_found = [] Pharmacodes_with_problems.each do |pcode, expected_price| begin #lines = ["Expected price for #{pcode} is #{expected_price}", old_info = `grep #{pcode} ddd_thinpower.csv`.chomp new_info = `grep #{pcode} ddd_oddb_ci2.csv`.chomp if old_info.length == 0 || new_info.length == 0 # puts "Did not find pharmacode #{pcode} in the generated CSV" not_found << pcode next end old_ddd_price = old_info.split(';').last new_ddd_price = new_info.split(';').last.to_f name = new_info.split(';')[3] if (new_ddd_price - expected_price).abs < 0.01 nr_fixed += 1 result = "Corrected price for #{pcode} is now #{new_ddd_price} #{name}" result = nil else result = "Still incorrect price #{sprintf('%10.2f',new_ddd_price)} " + " #{sprintf('%10.2f', expected_price)} old_price #{sprintf('%10.2f', old_ddd_price)}" + " for #{sprintf('%7d', pcode)} #{name}" # require 'pry'; binding.pry if pcode == 1611622 end puts result if result rescue => e puts e require 'pry'; binding.pry end end puts "Fixed #{nr_fixed} of #{Pharmacodes_with_problems.size} problems reported by Mr. Wallimann. Did not find #{not_found.size} pharmacodes" puts not_found.join(',')