swissmedic-diff 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +2 -0
- data/.travis.yml +18 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +37 -0
- data/History.txt +18 -0
- data/LICENSE +339 -0
- data/Manifest.txt +20 -0
- data/README.txt +68 -0
- data/Rakefile +24 -0
- data/bin/swissmedic-diff +45 -0
- data/lib/swissmedic-diff.rb +317 -0
- data/setup.rb +1345 -0
- data/swissmedic-diff.gemspec +22 -0
- data/test/data/Packungen-2013.10.14.xls +0 -0
- data/test/data/Packungen.older.xls +0 -0
- data/test/data/Packungen.xls +0 -0
- data/test/data/Packungen_error_column.xls +0 -0
- data/test/data/Packungen_error_missing1.xls +0 -0
- data/test/data/Packungen_error_missing2.xls +0 -0
- data/test/test_swissmedic-diff.rb +195 -0
- metadata +117 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
spec = Gem::Specification.new do |s|
|
2
|
+
s.name = "swissmedic-diff"
|
3
|
+
s.version = "0.1.4"
|
4
|
+
s.summary = "Find out what Products have changed on the swiss healthcare market"
|
5
|
+
s.description = "Compares two Excel Documents provided by Swissmedic and displays the salient differences"
|
6
|
+
s.author = "Hannes Wyss, Masaomi Hatakeyama"
|
7
|
+
s.email = "hwyss@ywesee.com, mhatakeyama@ywesee.com"
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.files = Dir.glob('lib/*.rb') +
|
10
|
+
Dir.glob('bin/*') +
|
11
|
+
Dir.glob('[A-Z]*') +
|
12
|
+
Dir.glob('test/*') +
|
13
|
+
Dir.glob('test/data/*.xls')
|
14
|
+
s.test_file = "test/test_swissmedic-diff.rb"
|
15
|
+
s.executables << 'swissmedic-diff'
|
16
|
+
s.add_dependency('spreadsheet')
|
17
|
+
s.add_development_dependency "hoe"
|
18
|
+
s.add_development_dependency "minitest"
|
19
|
+
s.add_development_dependency "minitest-reporters"
|
20
|
+
|
21
|
+
s.homepage = "https://github.com/zdavatz/swissmedic-diff"
|
22
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,195 @@
|
|
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
|
+
@data_2013 = File.expand_path 'data/Packungen-2013.10.14.xls',
|
25
|
+
File.dirname(__FILE__)
|
26
|
+
@workbook = Spreadsheet.open(@data)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_iterate
|
30
|
+
diff = SwissmedicDiff.new
|
31
|
+
strings = []
|
32
|
+
diff.each_valid_row(Spreadsheet.open(@data_2013)) { |x| strings << "iksnr #{x[0]} packungs id #{x[diff.column(:ikscd)]}" }
|
33
|
+
expected = [
|
34
|
+
"iksnr 00277 packungs id 001",
|
35
|
+
"iksnr 00277 packungs id 002",
|
36
|
+
"iksnr 61338 packungs id 001",
|
37
|
+
"iksnr 61338 packungs id 002",
|
38
|
+
"iksnr 61367 packungs id 001",
|
39
|
+
"iksnr 61367 packungs id 002",
|
40
|
+
"iksnr 61367 packungs id 003",
|
41
|
+
"iksnr 61367 packungs id 004",
|
42
|
+
"iksnr 61367 packungs id 005",
|
43
|
+
"iksnr 61416 packungs id 001",
|
44
|
+
"iksnr 63164 packungs id 001",
|
45
|
+
"iksnr 63164 packungs id 002",
|
46
|
+
"iksnr 63164 packungs id 003",
|
47
|
+
"iksnr 65040 packungs id 001"
|
48
|
+
]
|
49
|
+
assert_equal(expected, strings)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_diff_pre_2013_to_2013
|
53
|
+
result = @diff.diff(@data_2013, @data)
|
54
|
+
assert(result.changes.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in difference")
|
55
|
+
assert_equal 6, result.news.size
|
56
|
+
expected = {
|
57
|
+
"00277"=>[:company, :sequence_date, :substances, :composition, :name_base],
|
58
|
+
"61338"=>[:sequence_date, :company, :atc_class],
|
59
|
+
"61367"=>
|
60
|
+
[:sequence_date,
|
61
|
+
:ikscat,
|
62
|
+
:substances,
|
63
|
+
:composition,
|
64
|
+
:sequence,
|
65
|
+
:replaced_package],
|
66
|
+
"61416"=>[:sequence_date],
|
67
|
+
"63164"=>[:new],
|
68
|
+
"65040"=>[:new],
|
69
|
+
"00275"=>[:delete],
|
70
|
+
"61345"=>[:delete]
|
71
|
+
}
|
72
|
+
assert_equal(expected, result.changes)
|
73
|
+
diff_string =%(+ 63164: Rivastigmin Patch Sandoz 5, Transdermales Pflaster
|
74
|
+
+ 65040: Panthoben, Salbe
|
75
|
+
- 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
76
|
+
- 61345: Terbinafin-Teva 125 mg, Tabletten
|
77
|
+
> 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Zulassungsinhaber (Sérolab, société anonyme), Zulassungsdatum Sequenz (2010-04-26), Wirkstoffe (globulina equina (immunisé avec coeur, endothélium vasculaire porcins)), Zusammensetzung (globulina equina (immunisé avec coeur, endothélium vasculaire porcins) 8 mg, propylenglycolum, conserv.: E 216, E 218, excipiens pro suppositorio.), Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
|
78
|
+
> 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsdatum Sequenz (2010-03-16), Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
|
79
|
+
> 61367: Hypericum-Mepha 250, Lactab; Zulassungsdatum Sequenz (2010-04-23), Abgabekategorie (D), Wirkstoffe (hyperici herbae extractum ethanolicum siccum quantificatum), Zusammensetzung (hyperici herbae extractum ethanolicum siccum quantificatum 250 mg corresp. hypericinum 0.25-0.75 mg, DER: 4-7:1, excipiens pro compresso obducto.), Packungs-Nummer (006 -> 005)
|
80
|
+
> 61416: Otriduo Schnupfen, Nasentropfen; Zulassungsdatum Sequenz (2010-05-12))
|
81
|
+
assert_equal(diff_string, @diff.to_s)
|
82
|
+
end
|
83
|
+
def test_diff
|
84
|
+
result = @diff.diff(@data, @older)
|
85
|
+
assert_equal 3, result.news.size
|
86
|
+
assert_equal 'Cardio-Pulmo-Rénal Sérocytol, suppositoire',
|
87
|
+
result.news.first.at(2)
|
88
|
+
assert_equal 2, result.updates.size
|
89
|
+
assert_equal 'Coeur-Vaisseaux Sérocytol, suppositoire(update)',
|
90
|
+
result.updates.first.at(2)
|
91
|
+
assert_equal 6, result.changes.size
|
92
|
+
expected = {
|
93
|
+
"00275"=>[:new],
|
94
|
+
"00277"=>[:name_base],
|
95
|
+
"61338"=>[:company, :atc_class],
|
96
|
+
"61367"=>[:sequence, :replaced_package],
|
97
|
+
"61416"=>[:new],
|
98
|
+
"00274"=>[:delete]
|
99
|
+
}
|
100
|
+
assert_equal(expected, result.changes)
|
101
|
+
assert_equal 3, result.package_deletions.size
|
102
|
+
assert_equal 4, result.package_deletions.first.size
|
103
|
+
iksnrs = result.package_deletions.collect { |row| row.at(0) }.sort
|
104
|
+
ikscds = result.package_deletions.collect { |row| row.at(2) }.sort
|
105
|
+
assert_equal ["00274", "61367", "61367"], iksnrs
|
106
|
+
assert_equal ["001", "002", "005"], ikscds
|
107
|
+
assert_equal 1, result.sequence_deletions.size
|
108
|
+
assert_equal ["00274", "01"], result.sequence_deletions.at(0)
|
109
|
+
assert_equal 1, result.registration_deletions.size
|
110
|
+
assert_equal ["00274"], result.registration_deletions.at(0)
|
111
|
+
assert_equal 1, result.replacements.size
|
112
|
+
assert_equal '005', result.replacements.values.first
|
113
|
+
end
|
114
|
+
def test_diff_error_column
|
115
|
+
assert_raise(RuntimeError) {
|
116
|
+
@diff.diff(@data_error_column, @older)
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
# if row.size < COLUMNS.size/2
|
121
|
+
def test_diff_error_missing_case1
|
122
|
+
assert_raise(RuntimeError) {
|
123
|
+
@diff.diff(@data_error_missing_case1, @older)
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
# if row.select{|val| val==nil}.size > COLUMNS.size/2
|
128
|
+
def test_diff_error_missing_case2
|
129
|
+
assert_raise(RuntimeError) {
|
130
|
+
@diff.diff(@data_error_missing_case2, @older)
|
131
|
+
}
|
132
|
+
end
|
133
|
+
def test_diff__ignore
|
134
|
+
ignore = [:company, :atc_class]
|
135
|
+
result = @diff.diff(@data, @older, ignore)
|
136
|
+
assert_equal 3, result.news.size
|
137
|
+
assert_equal 'Cardio-Pulmo-Rénal Sérocytol, suppositoire',
|
138
|
+
result.news.first.at(2)
|
139
|
+
assert_equal 1, result.updates.size
|
140
|
+
assert_equal 'Coeur-Vaisseaux Sérocytol, suppositoire(update)',
|
141
|
+
result.updates.first.at(2)
|
142
|
+
assert_equal 5, result.changes.size
|
143
|
+
expected = {
|
144
|
+
"00275"=>[:new],
|
145
|
+
"00277"=>[:name_base],
|
146
|
+
"61367"=>[:sequence, :replaced_package],
|
147
|
+
"61416"=>[:new],
|
148
|
+
"00274"=>[:delete]
|
149
|
+
}
|
150
|
+
assert_equal(expected, result.changes)
|
151
|
+
assert_equal 3, result.package_deletions.size
|
152
|
+
assert_equal 4, result.package_deletions.first.size
|
153
|
+
iksnrs = result.package_deletions.collect { |row| row.at(0) }.sort
|
154
|
+
ikscds = result.package_deletions.collect { |row| row.at(2) }.sort
|
155
|
+
assert_equal ["00274", "61367", "61367"], iksnrs
|
156
|
+
assert_equal ["001", "002", "005"], ikscds
|
157
|
+
assert_equal 1, result.sequence_deletions.size
|
158
|
+
assert_equal ["00274", "01"], result.sequence_deletions.at(0)
|
159
|
+
assert_equal 1, result.registration_deletions.size
|
160
|
+
assert_equal ["00274"], result.registration_deletions.at(0)
|
161
|
+
assert_equal 1, result.replacements.size
|
162
|
+
assert_equal '005', result.replacements.values.first
|
163
|
+
end
|
164
|
+
def test_to_s
|
165
|
+
assert_nothing_raised {
|
166
|
+
@diff.to_s
|
167
|
+
}
|
168
|
+
@diff.diff(@data, @older)
|
169
|
+
assert_equal <<-EOS.strip, @diff.to_s
|
170
|
+
+ 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
171
|
+
+ 61416: Otriduo Schnupfen, Nasentropfen
|
172
|
+
- 00274: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
173
|
+
> 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
|
174
|
+
> 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
|
175
|
+
> 61367: Hypericum-Mepha 250, Lactab; Packungs-Nummer (005 -> 006)
|
176
|
+
EOS
|
177
|
+
assert_equal <<-EOS.strip, @diff.to_s(:name)
|
178
|
+
- 00274: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
179
|
+
+ 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
180
|
+
> 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
|
181
|
+
> 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
|
182
|
+
> 61367: Hypericum-Mepha 250, Lactab; Packungs-Nummer (005 -> 006)
|
183
|
+
+ 61416: Otriduo Schnupfen, Nasentropfen
|
184
|
+
EOS
|
185
|
+
assert_equal <<-EOS.strip, @diff.to_s(:registration)
|
186
|
+
- 00274: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
187
|
+
+ 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
188
|
+
> 00277: Coeur-Vaisseaux Sérocytol, suppositoire; Namensänderung (Coeur-Vaisseaux Sérocytol, suppositoire)
|
189
|
+
> 61338: Cefuroxim Fresenius i.v. 750 mg, Pulver zur Herstellung einer i.v. Lösung; Zulassungsinhaber (Fresenius Kabi (Schweiz) AG), ATC-Code (J01DC02)
|
190
|
+
> 61367: Hypericum-Mepha 250, Lactab; Packungs-Nummer (005 -> 006)
|
191
|
+
+ 61416: Otriduo Schnupfen, Nasentropfen
|
192
|
+
EOS
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swissmedic-diff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.10'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.10'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hoe
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.13'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.13'
|
46
|
+
description: ! '* Compares two Excel Documents provided by Swissmedic and displays
|
47
|
+
the
|
48
|
+
|
49
|
+
salient differences. Also: Find out what Products have changed on the
|
50
|
+
|
51
|
+
swiss healthcare market.
|
52
|
+
|
53
|
+
|
54
|
+
Up-To-Date file:
|
55
|
+
|
56
|
+
|
57
|
+
* http://www.swissmedic.ch//daten/00080/00251/index.html'
|
58
|
+
email:
|
59
|
+
- mhatakeyama@ywesee.com, zdavatz@ywesee.com
|
60
|
+
executables:
|
61
|
+
- swissmedic-diff
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files:
|
64
|
+
- History.txt
|
65
|
+
- Manifest.txt
|
66
|
+
- README.txt
|
67
|
+
files:
|
68
|
+
- .gitignore
|
69
|
+
- .travis.yml
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- History.txt
|
73
|
+
- LICENSE
|
74
|
+
- Manifest.txt
|
75
|
+
- README.txt
|
76
|
+
- Rakefile
|
77
|
+
- bin/swissmedic-diff
|
78
|
+
- lib/swissmedic-diff.rb
|
79
|
+
- setup.rb
|
80
|
+
- swissmedic-diff.gemspec
|
81
|
+
- test/data/Packungen-2013.10.14.xls
|
82
|
+
- test/data/Packungen.older.xls
|
83
|
+
- test/data/Packungen.xls
|
84
|
+
- test/data/Packungen_error_column.xls
|
85
|
+
- test/data/Packungen_error_missing1.xls
|
86
|
+
- test/data/Packungen_error_missing2.xls
|
87
|
+
- test/test_swissmedic-diff.rb
|
88
|
+
- .gemtest
|
89
|
+
homepage: https://github.com/zdavatz/swissmedic-diff
|
90
|
+
licenses: []
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options:
|
93
|
+
- --main
|
94
|
+
- README.txt
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project: swissmedic-diff
|
111
|
+
rubygems_version: 1.8.25
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: ! '* Compares two Excel Documents provided by Swissmedic and displays the
|
115
|
+
salient differences'
|
116
|
+
test_files:
|
117
|
+
- test/test_swissmedic-diff.rb
|