oddb2xml 2.2.6 → 2.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +18 -0
- data/Gemfile.lock +28 -28
- data/History.txt +6 -0
- data/lib/oddb2xml/builder.rb +8 -8
- data/lib/oddb2xml/cli.rb +5 -6
- data/lib/oddb2xml/extractor.rb +12 -4
- data/lib/oddb2xml/version.rb +1 -1
- data/oddb2xml.xsd +2 -1
- data/spec/builder_spec.rb +159 -137
- data/spec/calc_spec.rb +40 -40
- data/spec/cli_spec.rb +57 -55
- data/spec/compressor_spec.rb +16 -16
- data/spec/data/swissmedic_fridge.xlsx +0 -0
- data/spec/data/swissmedic_orphan.xlsx +0 -0
- data/spec/data/swissmedic_package.xlsx +0 -0
- data/spec/downloader_spec.rb +50 -45
- data/spec/extractor_spec.rb +8 -8
- data/spec/fixtures/vcr_cassettes/oddb2xml.json +660 -1599
- data/spec/spec_helper.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5231618926015f8fe6730a4bb96e5c1b02bcd7a6
|
4
|
+
data.tar.gz: 46d8563881526d72bfafa74d328b599e59f5ead8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcaad4b40f4e4a353c8d81a0628a766f71072926365ab4227b28c495448ef504f7a3870b13cbbe1ce6bc32f47f18ad844d6bade36f5ac4118275352361eaf044
|
7
|
+
data.tar.gz: c34d48f22e6f16b235695f1fe911d0249884287d0f787ec891b3cd4db7d145a3c60b011b91c0228c7af33db0d5d61fdbb5c521ff197ca682d82a111506524abd
|
data/.gitignore
CHANGED
@@ -15,3 +15,21 @@ test/tmp
|
|
15
15
|
test/version_tmp
|
16
16
|
tmp
|
17
17
|
.ruby-version
|
18
|
+
*#
|
19
|
+
# Ignore downloaded files
|
20
|
+
.project
|
21
|
+
.buildpath
|
22
|
+
/*.xlsx
|
23
|
+
/oddb_*.xml
|
24
|
+
/oddb_*.txt
|
25
|
+
/oddb2xml*.txt
|
26
|
+
/spec/run
|
27
|
+
/*tar.gz
|
28
|
+
/*.patch
|
29
|
+
/ausgabe
|
30
|
+
/downloads
|
31
|
+
/duplicate_ean13_from_zur_rose.txt
|
32
|
+
/epha_interactions.csv
|
33
|
+
/missing_in_refdata.txt
|
34
|
+
/oddb2xml_files_nonpharma.xls
|
35
|
+
/oddb_calc.csv
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oddb2xml (2.2.
|
4
|
+
oddb2xml (2.2.7)
|
5
5
|
archive-tar-minitar
|
6
6
|
httpi (>= 2.4.1)
|
7
7
|
mechanize
|
@@ -25,17 +25,16 @@ GEM
|
|
25
25
|
archive-tar-minitar (0.5.2)
|
26
26
|
blankslate (3.1.3)
|
27
27
|
builder (3.2.2)
|
28
|
-
byebug (
|
29
|
-
columnize (= 0.9.0)
|
28
|
+
byebug (8.2.0)
|
30
29
|
coderay (1.1.0)
|
31
|
-
columnize (0.9.0)
|
32
30
|
crack (0.4.2)
|
33
31
|
safe_yaml (~> 1.0.0)
|
34
32
|
diff-lcs (1.2.5)
|
35
|
-
domain_name (0.5.
|
33
|
+
domain_name (0.5.25)
|
36
34
|
unf (>= 0.0.5, < 1.0.0)
|
37
35
|
gyoku (1.3.1)
|
38
36
|
builder (>= 2.1.2)
|
37
|
+
hashdiff (0.2.3)
|
39
38
|
http-cookie (1.0.2)
|
40
39
|
domain_name (~> 0.5)
|
41
40
|
httpi (2.4.1)
|
@@ -51,23 +50,23 @@ GEM
|
|
51
50
|
ntlm-http (~> 0.1, >= 0.1.1)
|
52
51
|
webrobots (>= 0.0.9, < 0.2)
|
53
52
|
method_source (0.8.2)
|
54
|
-
mime-types (2.
|
53
|
+
mime-types (2.99)
|
55
54
|
mini_portile (0.6.2)
|
56
|
-
multi_json (1.11.
|
55
|
+
multi_json (1.11.2)
|
57
56
|
net-http-digest_auth (1.4)
|
58
57
|
net-http-persistent (2.9.4)
|
59
|
-
nokogiri (1.6.6.
|
58
|
+
nokogiri (1.6.6.4)
|
60
59
|
mini_portile (~> 0.6.0)
|
61
60
|
nori (2.6.0)
|
62
61
|
ntlm-http (0.1.1)
|
63
|
-
parslet (1.7.
|
62
|
+
parslet (1.7.1)
|
64
63
|
blankslate (>= 2.0, <= 4.0)
|
65
|
-
pry (0.10.
|
64
|
+
pry (0.10.3)
|
66
65
|
coderay (~> 1.1.0)
|
67
66
|
method_source (~> 0.8.1)
|
68
67
|
slop (~> 3.4)
|
69
|
-
pry-byebug (3.
|
70
|
-
byebug (~>
|
68
|
+
pry-byebug (3.3.0)
|
69
|
+
byebug (~> 8.0)
|
71
70
|
pry (~> 0.10)
|
72
71
|
pry-doc (0.8.0)
|
73
72
|
pry (~> 0.9)
|
@@ -76,21 +75,21 @@ GEM
|
|
76
75
|
rake (10.4.2)
|
77
76
|
rdoc (4.2.0)
|
78
77
|
json (~> 1.4)
|
79
|
-
rspec (3.
|
80
|
-
rspec-core (~> 3.
|
81
|
-
rspec-expectations (~> 3.
|
82
|
-
rspec-mocks (~> 3.
|
83
|
-
rspec-core (3.
|
84
|
-
rspec-support (~> 3.
|
85
|
-
rspec-expectations (3.
|
78
|
+
rspec (3.4.0)
|
79
|
+
rspec-core (~> 3.4.0)
|
80
|
+
rspec-expectations (~> 3.4.0)
|
81
|
+
rspec-mocks (~> 3.4.0)
|
82
|
+
rspec-core (3.4.1)
|
83
|
+
rspec-support (~> 3.4.0)
|
84
|
+
rspec-expectations (3.4.0)
|
86
85
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
-
rspec-support (~> 3.
|
88
|
-
rspec-mocks (3.
|
86
|
+
rspec-support (~> 3.4.0)
|
87
|
+
rspec-mocks (3.4.0)
|
89
88
|
diff-lcs (>= 1.2.0, < 2.0)
|
90
|
-
rspec-support (~> 3.
|
91
|
-
rspec-support (3.
|
89
|
+
rspec-support (~> 3.4.0)
|
90
|
+
rspec-support (3.4.1)
|
92
91
|
ruby-ole (1.2.11.8)
|
93
|
-
rubyXL (3.3.
|
92
|
+
rubyXL (3.3.15)
|
94
93
|
nokogiri (>= 1.4.4)
|
95
94
|
rubyzip (>= 1.1.6)
|
96
95
|
rubyntlm (0.5.1)
|
@@ -106,19 +105,20 @@ GEM
|
|
106
105
|
wasabi (~> 3.4)
|
107
106
|
sax-machine (1.3.2)
|
108
107
|
slop (3.6.0)
|
109
|
-
spreadsheet (1.0.
|
108
|
+
spreadsheet (1.0.9)
|
110
109
|
ruby-ole (>= 1.0)
|
111
|
-
timecop (0.
|
110
|
+
timecop (0.8.0)
|
112
111
|
unf (0.1.4)
|
113
112
|
unf_ext
|
114
113
|
unf_ext (0.0.7.1)
|
115
|
-
vcr (
|
114
|
+
vcr (3.0.0)
|
116
115
|
wasabi (3.5.0)
|
117
116
|
httpi (~> 2.0)
|
118
117
|
nokogiri (>= 1.4.2)
|
119
|
-
webmock (1.
|
118
|
+
webmock (1.22.3)
|
120
119
|
addressable (>= 2.3.6)
|
121
120
|
crack (>= 0.3.2)
|
121
|
+
hashdiff
|
122
122
|
webrobots (0.1.1)
|
123
123
|
yard (0.8.7.6)
|
124
124
|
|
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 2.2.7 / 24.11.2015
|
2
|
+
|
3
|
+
* Removed no more emitted QTY from definition of ART in oddb2xml.xsd
|
4
|
+
* Fixed generating COOL in oddb_article.xml
|
5
|
+
* Fixed generating ORPH in oddb_product.xml
|
6
|
+
|
1
7
|
=== 2.2.6 / 09.11.2015
|
2
8
|
|
3
9
|
* Fixed an error when generating oddb_calc.xml and we have no information for a given EAN, eg. 7680653150012
|
data/lib/oddb2xml/builder.rb
CHANGED
@@ -35,7 +35,7 @@ module Oddb2xml
|
|
35
35
|
}
|
36
36
|
class Builder
|
37
37
|
attr_accessor :subject, :refdata, :items, :flags, :lppvs,
|
38
|
-
:actions, :migel, :
|
38
|
+
:actions, :migel, :orphan, :fridge,
|
39
39
|
:infos, :packs, :infos_zur_rose,
|
40
40
|
:ean14, :tag_suffix,
|
41
41
|
:companies, :people,
|
@@ -52,8 +52,8 @@ module Oddb2xml
|
|
52
52
|
@migel = {}
|
53
53
|
@infos_zur_rose = {} # zurrose
|
54
54
|
@actions = []
|
55
|
-
@
|
56
|
-
@
|
55
|
+
@orphan = []
|
56
|
+
@fridge = []
|
57
57
|
@ean14 = false
|
58
58
|
@companies = []
|
59
59
|
@people = []
|
@@ -533,7 +533,7 @@ module Oddb2xml
|
|
533
533
|
#xml.DRGFD
|
534
534
|
#xml.DRGFF
|
535
535
|
obj[:no8] =~ /(\d{5})(\d{3})/
|
536
|
-
if @
|
536
|
+
if @orphan.include?($1.to_s)
|
537
537
|
xml.ORPH true
|
538
538
|
end
|
539
539
|
#xml.BIOPHA
|
@@ -820,7 +820,7 @@ module Oddb2xml
|
|
820
820
|
#xml.GRDFR
|
821
821
|
if no8 and !no8.empty? and
|
822
822
|
no8.to_s =~ /(\d{5})(\d{3})/
|
823
|
-
xml.COOL 1 if @
|
823
|
+
xml.COOL 1 if @fridge.include?($1.to_s)
|
824
824
|
end
|
825
825
|
#xml.TEMP
|
826
826
|
if ean
|
@@ -1025,8 +1025,8 @@ module Oddb2xml
|
|
1025
1025
|
xml.KP('DT' => '') {
|
1026
1026
|
xml.MONID @infos[lang][idx][:monid]
|
1027
1027
|
xml.PRDNO seq[:product_key] unless seq[:product_key].empty?
|
1028
|
-
# as
|
1029
|
-
xml.DEL @
|
1028
|
+
# as orphan ?
|
1029
|
+
xml.DEL @orphan.include?(number) ? true : false
|
1030
1030
|
}
|
1031
1031
|
}
|
1032
1032
|
end
|
@@ -1240,7 +1240,7 @@ module Oddb2xml
|
|
1240
1240
|
'3'
|
1241
1241
|
end
|
1242
1242
|
row << "%#{DAT_LEN[:CLAG]}s" % if ((no8 && no8.to_s =~ /(\d{5})(\d{3})/) and
|
1243
|
-
@
|
1243
|
+
@fridge.include?($1.to_s))
|
1244
1244
|
'1'
|
1245
1245
|
else
|
1246
1246
|
'0'
|
data/lib/oddb2xml/cli.rb
CHANGED
@@ -30,8 +30,8 @@ module Oddb2xml
|
|
30
30
|
@infos_zur_rose = {} # [addition] infos_zur_rose and other infos from zurrose transfer.txt
|
31
31
|
@migel = {} # [addition] additional Non Pharma products from files repo
|
32
32
|
@actions = [] # [addition] interactions from epha
|
33
|
-
@
|
34
|
-
@
|
33
|
+
@orphan = [] # [addition] Orphaned drugs from Swissmedic xls
|
34
|
+
@fridge = [] # [addition] ReFridge drugs from Swissmedic xls
|
35
35
|
# addres
|
36
36
|
@companies = [] # betrieb
|
37
37
|
@people = [] # medizinalperson
|
@@ -89,7 +89,6 @@ module Oddb2xml
|
|
89
89
|
def build
|
90
90
|
Oddb2xml.log("Start build")
|
91
91
|
begin
|
92
|
-
# require 'pry'; binding.pry
|
93
92
|
@_files = {"calc"=>"oddb_calc.xml"} if @options[:calc] and not @options[:extended]
|
94
93
|
files.each_pair do |sbj, file|
|
95
94
|
builder = Builder.new(@options) do |builder|
|
@@ -117,7 +116,7 @@ module Oddb2xml
|
|
117
116
|
builder.infos = @infos
|
118
117
|
builder.packs = @packs
|
119
118
|
# additional sources
|
120
|
-
%w[actions
|
119
|
+
%w[actions orphan fridge migel infos_zur_rose].each do |addition|
|
121
120
|
builder.send("#{addition}=".intern, self.instance_variable_get("@#{addition}"))
|
122
121
|
end
|
123
122
|
end
|
@@ -181,13 +180,13 @@ module Oddb2xml
|
|
181
180
|
end
|
182
181
|
end
|
183
182
|
when :orphan, :fridge
|
184
|
-
var = what.to_s
|
183
|
+
var = what.to_s
|
185
184
|
begin # instead of Thread.new do
|
186
185
|
downloader = SwissmedicDownloader.new(what)
|
187
186
|
bin = downloader.download
|
188
187
|
Oddb2xml.log("SwissmedicDownloader #{var} #{bin} #{File.size(bin)} bytes")
|
189
188
|
self.instance_variable_set(
|
190
|
-
"@#{var}"
|
189
|
+
"@#{var}",
|
191
190
|
items = SwissmedicExtractor.new(bin, what).to_arry
|
192
191
|
)
|
193
192
|
Oddb2xml.log("SwissmedicExtractor added #{items.size} #{var}. File #{bin} was #{File.size(bin)} bytes")
|
data/lib/oddb2xml/extractor.rb
CHANGED
@@ -212,17 +212,24 @@ module Oddb2xml
|
|
212
212
|
case @type
|
213
213
|
when :orphan
|
214
214
|
i = 1
|
215
|
+
col_zulassung = 5
|
216
|
+
raise "Could not find Zulassungsnummer in column #{col_zulassung} of #{@filename}" unless /Zulassungs.*nummer/.match(@sheet[3][col_zulassung].value)
|
215
217
|
@sheet.each do |row|
|
216
|
-
next unless row[
|
217
|
-
number = row[
|
218
|
+
next unless row[col_zulassung]
|
219
|
+
number = row[col_zulassung].value.to_i
|
218
220
|
if number != 0
|
219
221
|
data << sprintf("%05d", number)
|
220
222
|
end
|
221
223
|
end
|
222
224
|
when :fridge
|
223
|
-
|
225
|
+
row_explanation = 9
|
226
|
+
col_zulassung = 0
|
227
|
+
col_cool = 12
|
228
|
+
explanation = @sheet[row_explanation]
|
229
|
+
raise "Could not find Zulassungsnummer in column #{col_zulassung} of #{@filename}" unless /Zul.*Nr/.match(explanation[col_zulassung].value)
|
230
|
+
raise "Could not find Kühlkette in column #{col_cool}" unless /Kühlkette/.match(explanation[col_cool].value)
|
224
231
|
@sheet.each do |row|
|
225
|
-
if row[
|
232
|
+
if row[col_zulassung] and number = row[col_zulassung].value and row[col_cool] and row[col_cool].value.to_s.downcase == 'x'
|
226
233
|
data << sprintf("%05d", number)
|
227
234
|
end
|
228
235
|
end
|
@@ -272,6 +279,7 @@ module Oddb2xml
|
|
272
279
|
|
273
280
|
next if (i <= 1)
|
274
281
|
next unless row and row[i_5] and row[i_3]
|
282
|
+
next unless row[i_5].value.to_i > 0 and row[i_3].value.to_i > 0
|
275
283
|
no8 = sprintf('%05d',row[i_5].value.to_i) + sprintf('%03d',row[i_3].value.to_i)
|
276
284
|
prodno = sprintf('%05d',row[i_5].value.to_i) + row[p_1_2].value.to_i.to_s
|
277
285
|
unless no8.empty?
|
data/lib/oddb2xml/version.rb
CHANGED
data/oddb2xml.xsd
CHANGED
@@ -54,6 +54,8 @@
|
|
54
54
|
* Bezeichnung (DE / FR)
|
55
55
|
* QTY Quantity, e.g. 3 Flaschen 5 ml. The EAN13 specified that this package contains 3 bottles. Think of it as
|
56
56
|
as description of volume/size of the content.
|
57
|
+
The QTY is present in the oddb_product.xml, but not in the oddb_article.xml
|
58
|
+
In oddb_calc.xml you find QTY/UNIT, where QTY is a float and unit something like ml, mg, etc.
|
57
59
|
* ATC
|
58
60
|
* company_name (only for migel)
|
59
61
|
* GLN company_ean, field COMPNO in oddb_article
|
@@ -124,7 +126,6 @@
|
|
124
126
|
<xs:element ref="ns1:CDBG"/>
|
125
127
|
<xs:element ref="ns1:BG"/>
|
126
128
|
</xs:sequence>
|
127
|
-
<xs:element minOccurs="0" ref="ns1:QTY"/>
|
128
129
|
<xs:element ref="ns1:DSCRD"/>
|
129
130
|
<xs:element ref="ns1:DSCRF"/>
|
130
131
|
<xs:element ref="ns1:SORTD"/>
|