swissmedic-diff 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +2 -2
- data/Gemfile +6 -1
- data/Gemfile.lock +18 -18
- data/History.txt +4 -0
- data/lib/swissmedic-diff.rb +11 -14
- data/lib/version.rb +1 -1
- data/test/data/Packungen_2014_small.xlsx +0 -0
- data/test/test_swissmedic-diff.rb +8 -21
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGZmZDYzOTBkNGI4MWQ5OTdlMTU4YmYyNzExNzI0YmU1MmZjOWIyMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTA2M2YwNTU3M2RjNTIxNzJmZTUxZjM5MTg2NWZhZjg1NGM3ZGZlNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzU4YjQ4ODRkMzc4OTZmMWM3MWM2MjUxNTBlNDFmY2Q5ZmM0ZmVhMTJhZDZj
|
10
|
+
MmQ2MTg2NWY2NzY1MzEzZTRkZTBlY2FkMTA3MGY0OGRkOWE4M2YxOTIxM2M2
|
11
|
+
YTZkZWQyODMzZDRjMDE2OGVjNGVhNGM5NTFhNjc2ZjYyYTQ0ZmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjUwYjRmZThhMGUxMTZkMDUxNzdjZTRkNWQyYWFlMzZmMzdmNjI2YmMwZjFk
|
14
|
+
MWFjMmEwOWMwYTNjNTM3YTkyODNjOGE1MGMxNTFhMDIyZjRjOWQ0OWM4M2Qz
|
15
|
+
YTM1ZTgyY2MwZTIwNTM0NzcyNjkwNDFhMjExM2MyZDMzNTgzZjI=
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
swissmedic-diff (0.1.
|
4
|
+
swissmedic-diff (0.1.9)
|
5
5
|
nokogiri
|
6
6
|
rubyXL
|
7
7
|
rubyzip
|
@@ -10,44 +10,44 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
ansi (1.
|
13
|
+
ansi (1.5.0)
|
14
14
|
builder (3.2.2)
|
15
15
|
coderay (1.1.0)
|
16
|
-
columnize (0.
|
16
|
+
columnize (0.9.0)
|
17
17
|
debugger (1.6.8)
|
18
18
|
columnize (>= 0.3.1)
|
19
19
|
debugger-linecache (~> 1.2.0)
|
20
20
|
debugger-ruby_core_source (~> 1.3.5)
|
21
21
|
debugger-linecache (1.2.0)
|
22
|
-
debugger-ruby_core_source (1.3.
|
23
|
-
hoe (3.
|
22
|
+
debugger-ruby_core_source (1.3.8)
|
23
|
+
hoe (3.13.1)
|
24
24
|
rake (>= 0.8, < 11.0)
|
25
25
|
method_source (0.8.2)
|
26
|
-
mini_portile (0.6.
|
27
|
-
minitest (5.
|
28
|
-
minitest-reporters (1.0.
|
26
|
+
mini_portile (0.6.2)
|
27
|
+
minitest (5.7.0)
|
28
|
+
minitest-reporters (1.0.16)
|
29
29
|
ansi
|
30
30
|
builder
|
31
31
|
minitest (>= 5.0)
|
32
32
|
ruby-progressbar
|
33
|
-
nokogiri (1.6.2
|
34
|
-
mini_portile (
|
35
|
-
pry (0.10.
|
33
|
+
nokogiri (1.6.6.2)
|
34
|
+
mini_portile (~> 0.6.0)
|
35
|
+
pry (0.10.1)
|
36
36
|
coderay (~> 1.1.0)
|
37
37
|
method_source (~> 0.8.1)
|
38
38
|
slop (~> 3.4)
|
39
39
|
pry-debugger (0.2.3)
|
40
40
|
debugger (~> 1.3)
|
41
41
|
pry (>= 0.9.10, < 0.11.0)
|
42
|
-
rake (10.
|
43
|
-
ruby-ole (1.2.11.
|
44
|
-
ruby-progressbar (1.5
|
45
|
-
rubyXL (3.
|
42
|
+
rake (10.4.2)
|
43
|
+
ruby-ole (1.2.11.8)
|
44
|
+
ruby-progressbar (1.7.5)
|
45
|
+
rubyXL (3.3.8)
|
46
46
|
nokogiri (>= 1.4.4)
|
47
47
|
rubyzip (>= 1.1.6)
|
48
|
-
rubyzip (1.1.
|
49
|
-
slop (3.
|
50
|
-
spreadsheet (0.
|
48
|
+
rubyzip (1.1.7)
|
49
|
+
slop (3.6.0)
|
50
|
+
spreadsheet (1.0.3)
|
51
51
|
ruby-ole (>= 1.0)
|
52
52
|
|
53
53
|
PLATFORMS
|
data/History.txt
CHANGED
data/lib/swissmedic-diff.rb
CHANGED
@@ -19,11 +19,11 @@ require File.join(File.dirname(__FILE__), 'compatibility.rb')
|
|
19
19
|
#Authors:: Hannes Wyss (hwyss@ywesee.com), Masaomi Hatakeyama (mhatakeyama@ywesee.com)
|
20
20
|
#Version:: 0.1.4 2013-10-16 commit c30af5c15f6b8101f8f84cb482dfd09ab20729d6
|
21
21
|
#Copyright:: Copyright (C) ywesee GmbH, 2010. All rights reserved.
|
22
|
-
#License:: GPLv2.0 Compliance
|
22
|
+
#License:: GPLv2.0 Compliance
|
23
23
|
#Source:: http://scm.ywesee.com/?p=swissmedic-diff/.git;a=summary
|
24
24
|
class SwissmedicDiff
|
25
25
|
module Diff
|
26
|
-
COLUMNS = [ :iksnr, :seqnr, :name_base, :company,
|
26
|
+
COLUMNS = [ :iksnr, :seqnr, :name_base, :company,
|
27
27
|
:index_therapeuticus, :atc_class, :production_science,
|
28
28
|
:registration_date, :sequence_date, :expiry_date, :ikscd,
|
29
29
|
:size, :unit, :ikscat, :substances, :composition,
|
@@ -102,9 +102,6 @@ class SwissmedicDiff
|
|
102
102
|
Spreadsheet.client_encoding = 'UTF-8'
|
103
103
|
tbook = Spreadsheet.open(target)
|
104
104
|
sheet = tbook.worksheet(0)
|
105
|
-
if new_column = cell(sheet.row(2), COLUMNS.size)
|
106
|
-
raise "New column #{COLUMNS.size} (#{new_column})"
|
107
|
-
end
|
108
105
|
idx, prr, prp = nil
|
109
106
|
multiples = {}
|
110
107
|
each_valid_row(tbook) { |row|
|
@@ -137,7 +134,7 @@ class SwissmedicDiff
|
|
137
134
|
(changes[iksnr].concat flags).uniq!
|
138
135
|
updates.push row unless flags.empty?
|
139
136
|
else
|
140
|
-
replacements.store [ iksnr, seqnr, cell(row, column(:size)),
|
137
|
+
replacements.store [ iksnr, seqnr, cell(row, column(:size)),
|
141
138
|
cell(row, column(:unit)) ], row
|
142
139
|
flags = changes[iksnr]
|
143
140
|
flags.push(:sequence).uniq! unless(flags.include? :new)
|
@@ -146,7 +143,7 @@ class SwissmedicDiff
|
|
146
143
|
}
|
147
144
|
@diff.replacements = reps = {}
|
148
145
|
known_pacs.each { |(iksnr, pacnr), row|
|
149
|
-
key = [iksnr, '%02i' % cell(row, column(:seqnr)).to_i,
|
146
|
+
key = [iksnr, '%02i' % cell(row, column(:seqnr)).to_i,
|
150
147
|
cell(row, column(:size)), cell(row, column(:unit))]
|
151
148
|
if(rep = replacements[key])
|
152
149
|
changes[iksnr].push :replaced_package
|
@@ -157,7 +154,7 @@ class SwissmedicDiff
|
|
157
154
|
changes.delete_if { |iksnr, flags| flags.empty? }
|
158
155
|
@diff.package_deletions = known_pacs.collect { |key, row|
|
159
156
|
## the keys in known_pacs don't include the sequence number (which
|
160
|
-
# would prevent us from properly recognizing multi-sequence-Packages),
|
157
|
+
# would prevent us from properly recognizing multi-sequence-Packages),
|
161
158
|
# so we need complete the path to the package now
|
162
159
|
key[1,0] = '%02i' % cell(row, column(:seqnr)).to_i
|
163
160
|
key
|
@@ -205,7 +202,7 @@ class SwissmedicDiff
|
|
205
202
|
known_regs.store [iksnr], row
|
206
203
|
known_seqs.store [iksnr, seqnr], row
|
207
204
|
known_pacs.store [iksnr, pacnr, idx], row
|
208
|
-
(newest_rows[iksnr] ||= {})[pacnr] = row
|
205
|
+
(newest_rows[iksnr] ||= {})[pacnr] = row
|
209
206
|
}
|
210
207
|
end
|
211
208
|
def name(diff, iksnr)
|
@@ -236,7 +233,7 @@ class SwissmedicDiff
|
|
236
233
|
def to_s(sort=:group)
|
237
234
|
@diff ||= nil
|
238
235
|
return '' unless @diff
|
239
|
-
@diff.changes.sort_by { |iksnr, flags|
|
236
|
+
@diff.changes.sort_by { |iksnr, flags|
|
240
237
|
_sort_by(sort, iksnr, flags)
|
241
238
|
}.collect { |iksnr, flags|
|
242
239
|
if(flags.include? :new)
|
@@ -245,7 +242,7 @@ class SwissmedicDiff
|
|
245
242
|
"- " << describe(@diff, iksnr)
|
246
243
|
else
|
247
244
|
"> " << describe(@diff, iksnr) << "; " \
|
248
|
-
<< flags.collect { |flag| describe_flag(@diff, iksnr, flag)
|
245
|
+
<< flags.collect { |flag| describe_flag(@diff, iksnr, flag)
|
249
246
|
}.compact.join(", ")
|
250
247
|
end
|
251
248
|
}.join("\n")
|
@@ -279,7 +276,7 @@ class SwissmedicDiff
|
|
279
276
|
end
|
280
277
|
end
|
281
278
|
end
|
282
|
-
|
279
|
+
|
283
280
|
#=== iterate over all valid rows of a swissmedic Packungen.xls
|
284
281
|
#
|
285
282
|
# Iterates over all rows, ignoring Tierarzneimittel and
|
@@ -312,7 +309,7 @@ class SwissmedicDiff
|
|
312
309
|
yield row
|
313
310
|
}
|
314
311
|
end
|
315
|
-
|
312
|
+
|
316
313
|
def rows_to_skip(spreadsheet)
|
317
314
|
# Packungen.xls of swissmedic before October 2013 had 3 leading rows
|
318
315
|
# Packungen.xls of swissmedic after October 2013 have 4 leading rows
|
@@ -325,7 +322,7 @@ class SwissmedicDiff
|
|
325
322
|
end
|
326
323
|
j
|
327
324
|
end
|
328
|
-
|
325
|
+
|
329
326
|
end
|
330
327
|
include Diff
|
331
328
|
end
|
data/lib/version.rb
CHANGED
Binary file
|
@@ -35,8 +35,8 @@ module ODDB
|
|
35
35
|
assert(result.changes.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
36
36
|
# puts "Got #{result.news.size} news, #{result.changes.size} changes, #{result.updates.size} updates."
|
37
37
|
assert_equal(8, result.news.size)
|
38
|
-
assert_equal(
|
39
|
-
assert_equal(
|
38
|
+
assert_equal(4, result.changes.size)
|
39
|
+
assert_equal(2, result.updates.size)
|
40
40
|
assert(result.news.first.index('00280'), "Should find 00280 in news")
|
41
41
|
assert(result.news.flatten.index('65034'), "Should find 65034 in news")
|
42
42
|
assert(result.news.flatten.index('00277') == nil, "Should not find 00277 in news")
|
@@ -67,7 +67,7 @@ module ODDB
|
|
67
67
|
|
68
68
|
def test_diff_xlsx_and_xls
|
69
69
|
@diff = SwissmedicDiff.new
|
70
|
-
last_month = File.expand_path 'data/
|
70
|
+
last_month = File.expand_path 'data/Packungen_2014_01.xlsx', File.dirname(__FILE__)
|
71
71
|
this_month = File.expand_path 'data/Packungen.xls', File.dirname(__FILE__)
|
72
72
|
result = @diff.diff last_month, this_month, [:atc_class, :sequence_date]
|
73
73
|
assert_equal(7, result.news.size)
|
@@ -79,26 +79,14 @@ module ODDB
|
|
79
79
|
end
|
80
80
|
def test_diff_xlsx_and_xlsx
|
81
81
|
@diff = SwissmedicDiff.new
|
82
|
-
last_month = File.expand_path 'data/
|
82
|
+
last_month = File.expand_path 'data/Packungen_2014_01.xlsx', File.dirname(__FILE__)
|
83
83
|
this_month = File.expand_path 'data/Packungen_2014_small.xlsx', File.dirname(__FILE__)
|
84
84
|
result = @diff.diff last_month, this_month, [:atc_class, :sequence_date]
|
85
|
-
assert_equal({}, result.changes)
|
85
|
+
assert_equal({"00277"=>[:expiry_date, :indication_sequence]}, result.changes)
|
86
|
+
assert_equal(1, result.updates.size)
|
86
87
|
assert_equal([], result.news)
|
87
|
-
assert_equal([], result.updates)
|
88
88
|
end
|
89
89
|
|
90
|
-
# This is not a unit test as it takes way too long (> 1 minute)
|
91
|
-
# Instead it might just tell you how to test with real data
|
92
|
-
def test_real_diff
|
93
|
-
@diff = SwissmedicDiff.new
|
94
|
-
last_month = File.expand_path 'data/Packungen-2013.08.16.xls', File.dirname(__FILE__)
|
95
|
-
this_month = File.expand_path 'data/Packungen-2013.11.04.xls', File.dirname(__FILE__)
|
96
|
-
result = @diff.diff last_month, this_month, [:atc_class, :sequence_date]
|
97
|
-
assert(result.changes.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
98
|
-
assert(result.news.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
99
|
-
assert(result.news.flatten.index('00277') == nil, "Should not find 00277 in news")
|
100
|
-
end if false
|
101
|
-
|
102
90
|
def test_iterate
|
103
91
|
diff = SwissmedicDiff.new
|
104
92
|
strings = []
|
@@ -187,9 +175,8 @@ module ODDB
|
|
187
175
|
assert_equal '005', result.replacements.values.first
|
188
176
|
end
|
189
177
|
def test_diff_error_column
|
190
|
-
|
191
|
-
|
192
|
-
}
|
178
|
+
res = @diff.diff(@data_error_column, @older)
|
179
|
+
assert_equal(OpenStruct, res.class)
|
193
180
|
end
|
194
181
|
|
195
182
|
# if row.size < COLUMNS.size/2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swissmedic-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.7'
|
41
41
|
description: ! '* Compares two Excel Documents provided by Swissmedic and displays
|
42
42
|
the
|
43
43
|
|
@@ -86,7 +86,8 @@ files:
|
|
86
86
|
- test/data/Packungen_error_missing2.xls
|
87
87
|
- test/test_swissmedic-diff.rb
|
88
88
|
homepage: https://github.com/zdavatz/swissmedic-diff
|
89
|
-
licenses:
|
89
|
+
licenses:
|
90
|
+
- MIT
|
90
91
|
metadata: {}
|
91
92
|
post_install_message:
|
92
93
|
rdoc_options:
|
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
109
|
rubyforge_project: swissmedic-diff
|
109
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.3.0
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: ! '* Compares two Excel Documents provided by Swissmedic and displays the
|