swissmedic_diff 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ require "rubygems"
2
+ require "rake"
3
+
4
+ spec = Gem::Specification.new do |s|
5
+ s.name = "swissmedic-diff"
6
+ s.version = "0.1.3"
7
+ s.summary = "Find out what Products have changed on the swiss healthcare market"
8
+ s.description = "Compares two Excel Documents provided by Swissmedic and displays the salient differences"
9
+ s.author = "Hannes Wyss, Masaomi Hatakeyama"
10
+ s.email = "hwyss@ywesee.com, mhatakeyama@ywesee.com"
11
+ s.platform = Gem::Platform::RUBY
12
+ s.files = FileList['lib/*.rb', 'bin/*', '[A-Z]*', 'test/*',
13
+ 'test/data/*.xls'].to_a
14
+ s.test_file = "test/test_swissmedic-diff.rb"
15
+ s.executables << 'swissmedic-diff'
16
+ s.add_dependency('parseexcel')
17
+ s.homepage = "http://scm.ywesee.com/swissmedic-diff/.git"
18
+ end
19
+
20
+ if $0 == __FILE__
21
+ Gem.manage_gems
22
+ Gem::Builder.new(spec).build
23
+ end
Binary file
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ # SwissmedicPluginTest -- oddb.org -- 18.03.2008 -- hwyss@ywesee.com
4
+
5
+ $: << File.expand_path("../lib", File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'swissmedic-diff'
9
+
10
+ module ODDB
11
+ class SwissmedicPluginTest < Test::Unit::TestCase
12
+ def setup
13
+ @diff = SwissmedicDiff.new
14
+ @data = File.expand_path 'data/Packungen.xls',
15
+ File.dirname(__FILE__)
16
+ @older = File.expand_path 'data/Packungen.older.xls',
17
+ File.dirname(__FILE__)
18
+ @data_error_column = File.expand_path 'data/Packungen_error_column.xls',
19
+ File.dirname(__FILE__)
20
+ @data_error_missing_case1 = File.expand_path 'data/Packungen_error_missing1.xls',
21
+ File.dirname(__FILE__)
22
+ @data_error_missing_case2 = File.expand_path 'data/Packungen_error_missing2.xls',
23
+ File.dirname(__FILE__)
24
+ @workbook = Spreadsheet.open(@data)
25
+ end
26
+ def test_diff
27
+ result = @diff.diff(@data, @older)
28
+ assert_equal 3, result.news.size
29
+ assert_equal 'Cardio-Pulmo-Rénal Sérocytol, suppositoire',
30
+ result.news.first.at(2)
31
+ assert_equal 2, result.updates.size
32
+ assert_equal 'Coeur-Vaisseaux Sérocytol, suppositoire(update)',
33
+ result.updates.first.at(2)
34
+ assert_equal 6, result.changes.size
35
+ expected = {
36
+ "00275"=>[:new],
37
+ "00277"=>[:name_base],
38
+ "61338"=>[:company, :atc_class],
39
+ "61367"=>[:sequence, :replaced_package],
40
+ "61416"=>[:new],
41
+ "00274"=>[:delete]
42
+ }
43
+ assert_equal(expected, result.changes)
44
+ assert_equal 3, result.package_deletions.size
45
+ assert_equal 4, result.package_deletions.first.size
46
+ iksnrs = result.package_deletions.collect { |row| row.at(0) }.sort
47
+ ikscds = result.package_deletions.collect { |row| row.at(2) }.sort
48
+ assert_equal ["00274", "61367", "61367"], iksnrs
49
+ assert_equal ["001", "002", "005"], ikscds
50
+ assert_equal 1, result.sequence_deletions.size
51
+ assert_equal ["00274", "01"], result.sequence_deletions.at(0)
52
+ assert_equal 1, result.registration_deletions.size
53
+ assert_equal ["00274"], result.registration_deletions.at(0)
54
+ assert_equal 1, result.replacements.size
55
+ assert_equal '005', result.replacements.values.first
56
+ end
57
+ def test_diff_error_column
58
+ assert_raise(RuntimeError) {
59
+ result = @diff.diff(@data_error_column, @older)
60
+ }
61
+ end
62
+
63
+ # if row.size < COLUMNS.size/2
64
+ def test_diff_error_missing_case1
65
+ assert_raise(RuntimeError) {
66
+ result = @diff.diff(@data_error_missing_case1, @older)
67
+ }
68
+ end
69
+
70
+ # if row.select{|val| val==nil}.size > COLUMNS.size/2
71
+ def test_diff_error_missing_case2
72
+ assert_raise(RuntimeError) {
73
+ result = @diff.diff(@data_error_missing_case2, @older)
74
+ }
75
+ end
76
+ def test_diff__ignore
77
+ ignore = [:company, :atc_class]
78
+ result = @diff.diff(@data, @older, ignore)
79
+ assert_equal 3, result.news.size
80
+ assert_equal 'Cardio-Pulmo-Rénal Sérocytol, suppositoire',
81
+ result.news.first.at(2)
82
+ assert_equal 1, result.updates.size
83
+ assert_equal 'Coeur-Vaisseaux Sérocytol, suppositoire(update)',
84
+ result.updates.first.at(2)
85
+ assert_equal 5, result.changes.size
86
+ expected = {
87
+ "00275"=>[:new],
88
+ "00277"=>[:name_base],
89
+ "61367"=>[:sequence, :replaced_package],
90
+ "61416"=>[:new],
91
+ "00274"=>[:delete]
92
+ }
93
+ assert_equal(expected, result.changes)
94
+ assert_equal 3, result.package_deletions.size
95
+ assert_equal 4, result.package_deletions.first.size
96
+ iksnrs = result.package_deletions.collect { |row| row.at(0) }.sort
97
+ ikscds = result.package_deletions.collect { |row| row.at(2) }.sort
98
+ assert_equal ["00274", "61367", "61367"], iksnrs
99
+ assert_equal ["001", "002", "005"], ikscds
100
+ assert_equal 1, result.sequence_deletions.size
101
+ assert_equal ["00274", "01"], result.sequence_deletions.at(0)
102
+ assert_equal 1, result.registration_deletions.size
103
+ assert_equal ["00274"], result.registration_deletions.at(0)
104
+ assert_equal 1, result.replacements.size
105
+ assert_equal '005', result.replacements.values.first
106
+ end
107
+ def test_to_s
108
+ assert_nothing_raised {
109
+ @diff.to_s
110
+ }
111
+ result = @diff.diff(@data, @older)
112
+ assert_equal <<-EOS.strip, @diff.to_s
113
+ + 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
114
+ + 61416: Otriduo Schnupfen, Nasentropfen
115
+ - 00274: Cardio-Pulmo-Rénal Sérocytol, suppositoire
116
+ > 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
117
+ > 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
118
+ > 61367: Hypericum-Mepha 250, Lactab; Packungs-Nummer (005 -> 006)
119
+ EOS
120
+ assert_equal <<-EOS.strip, @diff.to_s(:name)
121
+ - 00274: Cardio-Pulmo-Rénal Sérocytol, suppositoire
122
+ + 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
123
+ > 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
124
+ > 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
125
+ > 61367: Hypericum-Mepha 250, Lactab; Packungs-Nummer (005 -> 006)
126
+ + 61416: Otriduo Schnupfen, Nasentropfen
127
+ EOS
128
+ assert_equal <<-EOS.strip, @diff.to_s(:registration)
129
+ - 00274: Cardio-Pulmo-Rénal Sérocytol, suppositoire
130
+ + 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
131
+ > 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
132
+ > 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
133
+ > 61367: Hypericum-Mepha 250, Lactab; Packungs-Nummer (005 -> 006)
134
+ + 61416: Otriduo Schnupfen, Nasentropfen
135
+ EOS
136
+ end
137
+ end
138
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swissmedic_diff
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
+ platform: ruby
12
+ authors:
13
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-15 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 47
30
+ segments:
31
+ - 2
32
+ - 8
33
+ - 0
34
+ version: 2.8.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: |-
38
+ * Compares two Excel Documents provided by Swissmedic and displays the
39
+ salient differences. Also: Find out what Products have changed on the
40
+ swiss healthcare market.
41
+
42
+ Up-To-Date file:
43
+
44
+ * http://www.swissmedic.ch//daten/00080/00251/index.html
45
+ email:
46
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
47
+ executables:
48
+ - swissmedic-diff
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - History.txt
53
+ - Manifest.txt
54
+ - README.txt
55
+ files:
56
+ - History.txt
57
+ - InstalledFiles
58
+ - LICENSE
59
+ - Manifest.txt
60
+ - README.txt
61
+ - Rakefile
62
+ - bin/swissmedic-diff
63
+ - lib/swissmedic-diff.rb
64
+ - setup.rb
65
+ - swissmedic-diff.gemspec
66
+ - test/data/Packungen.older.xls
67
+ - test/data/Packungen.xls
68
+ - test/data/Packungen_error_column.xls
69
+ - test/data/Packungen_error_missing1.xls
70
+ - test/data/Packungen_error_missing2.xls
71
+ - test/test_swissmedic-diff.rb
72
+ has_rdoc: true
73
+ homepage: http://scm.ywesee.com/?p=swissmedic-diff/.git;a=summary
74
+ licenses: []
75
+
76
+ post_install_message:
77
+ rdoc_options:
78
+ - --main
79
+ - README.txt
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project: swissmedic_diff
103
+ rubygems_version: 1.3.7
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: "* Compares two Excel Documents provided by Swissmedic and displays the salient differences"
107
+ test_files:
108
+ - test/test_swissmedic-diff.rb