oddb2xml 2.9.8 → 2.9.9
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/Gemfile.lock +48 -56
- data/lib/oddb2xml/cli.rb +15 -5
- data/lib/oddb2xml/downloader.rb +6 -42
- data/lib/oddb2xml/extractor.rb +26 -15
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +58 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 538eaca672eb756d84b1aa382f5a9a27e4109a3f28575386d4f0ad0aed1f7e58
|
4
|
+
data.tar.gz: 3d7cd4d55f9e738acfabe9ab04b2b391c4144b30db8f21534d7f8c58dbf8e9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 953e11dece40e657143b7e85ca9d0a32d614b0cdd717f4ffb4dd6a6a4ddbc55bb851afd2db2a19d4b8c5e651488514a392951dffee677e763573beb0c2c0b6e2
|
7
|
+
data.tar.gz: 55289f276f21c170ae2bb50ab8c5c53ab197529f3b101079b941d15688f2650571f0a158c7067807106920c87363641baae0196d432e2e7406ce90394dfee7b4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oddb2xml (2.9.
|
4
|
+
oddb2xml (2.9.2)
|
5
5
|
htmlentities
|
6
6
|
httpi
|
7
7
|
mechanize
|
@@ -28,36 +28,34 @@ GEM
|
|
28
28
|
specs:
|
29
29
|
addressable (2.8.5)
|
30
30
|
public_suffix (>= 2.0.2, < 6.0)
|
31
|
-
akami (1.3.
|
32
|
-
base64
|
31
|
+
akami (1.3.1)
|
33
32
|
gyoku (>= 0.4.0)
|
34
33
|
nokogiri
|
35
|
-
ast (2.4.
|
36
|
-
base64 (0.
|
37
|
-
|
38
|
-
builder (3.3.0)
|
34
|
+
ast (2.4.2)
|
35
|
+
base64 (0.1.1)
|
36
|
+
builder (3.2.4)
|
39
37
|
byebug (11.1.3)
|
40
38
|
coderay (1.1.3)
|
41
|
-
connection_pool (2.
|
39
|
+
connection_pool (2.4.1)
|
42
40
|
crack (0.4.5)
|
43
41
|
rexml
|
44
42
|
diff-lcs (1.5.0)
|
45
|
-
domain_name (0.
|
43
|
+
domain_name (0.5.20190701)
|
44
|
+
unf (>= 0.0.5, < 1.0.0)
|
46
45
|
flexmock (2.3.8)
|
47
46
|
gyoku (1.4.0)
|
48
47
|
builder (>= 2.1.2)
|
49
48
|
rexml (~> 3.0)
|
50
49
|
hashdiff (1.0.1)
|
51
50
|
htmlentities (4.3.4)
|
52
|
-
http-cookie (1.0.
|
51
|
+
http-cookie (1.0.5)
|
53
52
|
domain_name (~> 0.5)
|
54
53
|
httpi (2.5.0)
|
55
54
|
rack
|
56
55
|
socksify
|
57
|
-
json (2.
|
58
|
-
language_server-protocol (3.17.0.
|
56
|
+
json (2.6.3)
|
57
|
+
language_server-protocol (3.17.0.3)
|
59
58
|
lint_roller (1.1.0)
|
60
|
-
logger (1.7.0)
|
61
59
|
mechanize (2.7.7)
|
62
60
|
domain_name (~> 0.5, >= 0.5.1)
|
63
61
|
http-cookie (~> 1.0)
|
@@ -69,31 +67,27 @@ GEM
|
|
69
67
|
webrick (~> 1.7)
|
70
68
|
webrobots (>= 0.0.9, < 0.2)
|
71
69
|
method_source (1.0.0)
|
72
|
-
mime-types (3.
|
73
|
-
logger
|
70
|
+
mime-types (3.5.1)
|
74
71
|
mime-types-data (~> 3.2015)
|
75
|
-
mime-types-data (3.
|
72
|
+
mime-types-data (3.2023.0808)
|
76
73
|
mini_portile2 (2.8.4)
|
77
|
-
minitar (
|
74
|
+
minitar (0.9)
|
78
75
|
multi_json (1.15.0)
|
79
76
|
net-http-digest_auth (1.4.1)
|
80
|
-
net-http-persistent (4.0.
|
77
|
+
net-http-persistent (4.0.2)
|
81
78
|
connection_pool (~> 2.2)
|
82
79
|
nokogiri (1.13.9)
|
83
80
|
mini_portile2 (~> 2.8.0)
|
84
81
|
racc (~> 1.4)
|
85
|
-
nori (2.
|
86
|
-
bigdecimal
|
82
|
+
nori (2.6.0)
|
87
83
|
ntlm-http (0.1.1)
|
88
|
-
optimist (3.
|
89
|
-
ox (2.14.
|
90
|
-
|
91
|
-
|
92
|
-
parser (3.3.7.4)
|
84
|
+
optimist (3.1.0)
|
85
|
+
ox (2.14.17)
|
86
|
+
parallel (1.23.0)
|
87
|
+
parser (3.2.2.3)
|
93
88
|
ast (~> 2.4.1)
|
94
89
|
racc
|
95
90
|
parslet (2.0.0)
|
96
|
-
prism (1.4.0)
|
97
91
|
pry (0.14.2)
|
98
92
|
coderay (~> 1.1)
|
99
93
|
method_source (~> 1.0)
|
@@ -110,7 +104,7 @@ GEM
|
|
110
104
|
rainbow (3.1.1)
|
111
105
|
rake (13.0.6)
|
112
106
|
rdoc (6.3.3)
|
113
|
-
regexp_parser (2.
|
107
|
+
regexp_parser (2.8.1)
|
114
108
|
rexml (3.2.6)
|
115
109
|
rspec (3.12.0)
|
116
110
|
rspec-core (~> 3.12.0)
|
@@ -125,31 +119,30 @@ GEM
|
|
125
119
|
diff-lcs (>= 1.2.0, < 2.0)
|
126
120
|
rspec-support (~> 3.12.0)
|
127
121
|
rspec-support (3.12.1)
|
128
|
-
rubocop (1.
|
122
|
+
rubocop (1.56.4)
|
123
|
+
base64 (~> 0.1.1)
|
129
124
|
json (~> 2.3)
|
130
|
-
language_server-protocol (
|
131
|
-
lint_roller (~> 1.1.0)
|
125
|
+
language_server-protocol (>= 3.17.0)
|
132
126
|
parallel (~> 1.10)
|
133
|
-
parser (>= 3.
|
127
|
+
parser (>= 3.2.2.3)
|
134
128
|
rainbow (>= 2.2.2, < 4.0)
|
135
|
-
regexp_parser (>=
|
136
|
-
|
129
|
+
regexp_parser (>= 1.8, < 3.0)
|
130
|
+
rexml (>= 3.2.5, < 4.0)
|
131
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
137
132
|
ruby-progressbar (~> 1.7)
|
138
|
-
unicode-display_width (>= 2.4.0, <
|
139
|
-
rubocop-ast (1.
|
140
|
-
parser (>= 3.
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
rubocop-ast (>= 1.38.0, < 2.0)
|
146
|
-
ruby-ole (1.2.13.1)
|
133
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
134
|
+
rubocop-ast (1.29.0)
|
135
|
+
parser (>= 3.2.1.0)
|
136
|
+
rubocop-performance (1.19.1)
|
137
|
+
rubocop (>= 1.7.0, < 2.0)
|
138
|
+
rubocop-ast (>= 0.4.0)
|
139
|
+
ruby-ole (1.2.12.2)
|
147
140
|
ruby-progressbar (1.13.0)
|
148
|
-
rubyXL (3.4.
|
141
|
+
rubyXL (3.4.25)
|
149
142
|
nokogiri (>= 1.10.8)
|
150
143
|
rubyzip (>= 1.3.0)
|
151
144
|
rubyntlm (0.5.1)
|
152
|
-
rubyzip (2.
|
145
|
+
rubyzip (2.3.2)
|
153
146
|
savon (2.12.1)
|
154
147
|
akami (~> 1.2)
|
155
148
|
builder (>= 2.1.2)
|
@@ -160,28 +153,27 @@ GEM
|
|
160
153
|
wasabi (~> 3.4)
|
161
154
|
sax-machine (1.3.2)
|
162
155
|
socksify (1.7.1)
|
163
|
-
spreadsheet (1.3.
|
164
|
-
bigdecimal
|
165
|
-
logger
|
156
|
+
spreadsheet (1.3.0)
|
166
157
|
ruby-ole
|
167
|
-
standard (1.
|
158
|
+
standard (1.31.1)
|
168
159
|
language_server-protocol (~> 3.17.0.2)
|
169
160
|
lint_roller (~> 1.0)
|
170
|
-
rubocop (~> 1.
|
161
|
+
rubocop (~> 1.56.2)
|
171
162
|
standard-custom (~> 1.0.0)
|
172
|
-
standard-performance (~> 1.
|
163
|
+
standard-performance (~> 1.2)
|
173
164
|
standard-custom (1.0.2)
|
174
165
|
lint_roller (~> 1.0)
|
175
166
|
rubocop (~> 1.50)
|
176
|
-
standard-performance (1.
|
167
|
+
standard-performance (1.2.0)
|
177
168
|
lint_roller (~> 1.1)
|
178
|
-
rubocop-performance (~> 1.
|
169
|
+
rubocop-performance (~> 1.19.0)
|
179
170
|
standardrb (1.0.1)
|
180
171
|
standard
|
181
172
|
timecop (0.9.8)
|
182
|
-
|
183
|
-
|
184
|
-
|
173
|
+
unf (0.1.4)
|
174
|
+
unf_ext
|
175
|
+
unf_ext (0.0.8.2)
|
176
|
+
unicode-display_width (2.5.0)
|
185
177
|
vcr (6.2.0)
|
186
178
|
wasabi (3.7.0)
|
187
179
|
addressable
|
@@ -191,7 +183,7 @@ GEM
|
|
191
183
|
addressable (>= 2.8.0)
|
192
184
|
crack (>= 0.3.2)
|
193
185
|
hashdiff (>= 0.4.0, < 2.0.0)
|
194
|
-
webrick (1.
|
186
|
+
webrick (1.8.1)
|
195
187
|
webrobots (0.1.2)
|
196
188
|
xml-simple (1.1.9)
|
197
189
|
rexml
|
data/lib/oddb2xml/cli.rb
CHANGED
@@ -65,7 +65,12 @@ module Oddb2xml
|
|
65
65
|
threads << download(:firstbase) # https://github.com/zdavatz/oddb2xml/issues/63
|
66
66
|
end
|
67
67
|
types.each do |type|
|
68
|
-
|
68
|
+
begin
|
69
|
+
threads << download(:refdata, type) # refdata
|
70
|
+
rescue error
|
71
|
+
# Should continue even when error #102
|
72
|
+
Oddb2xml.log("Error in downloading refdata #{error}")
|
73
|
+
end
|
69
74
|
end
|
70
75
|
end
|
71
76
|
begin
|
@@ -311,10 +316,15 @@ module Oddb2xml
|
|
311
316
|
end
|
312
317
|
end
|
313
318
|
@mutex.synchronize do
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
319
|
+
begin
|
320
|
+
hsh = RefdataExtractor.new(xml, type).to_hash
|
321
|
+
@refdata_types[type] = hsh
|
322
|
+
Oddb2xml.log("RefdataExtractor #{type} added #{hsh.size} keys now #{@refdata_types.keys} items from xml with #{xml.size} bytes")
|
323
|
+
@refdata_types[type]
|
324
|
+
rescue error
|
325
|
+
# Should continue even when error https://github.com/zdavatz/oddb2xml/issues/102
|
326
|
+
Oddb2xml.log("Error in RefdataExtractor #{error}")
|
327
|
+
end
|
318
328
|
end
|
319
329
|
|
320
330
|
when :firstbase
|
data/lib/oddb2xml/downloader.rb
CHANGED
@@ -241,9 +241,9 @@ module Oddb2xml
|
|
241
241
|
end
|
242
242
|
|
243
243
|
class RefdataDownloader < Downloader
|
244
|
+
include DownloadMethod
|
244
245
|
def initialize(options = {}, type = :pharma)
|
245
|
-
|
246
|
-
url = "https://refdatabase.refdata.ch/Service/Article.asmx?WSDL"
|
246
|
+
url = "https://files.refdata.ch/simis-public-prod/Articles/1.0/Refdata.Articles.zip"
|
247
247
|
super(options, url)
|
248
248
|
end
|
249
249
|
|
@@ -258,46 +258,10 @@ module Oddb2xml
|
|
258
258
|
end
|
259
259
|
|
260
260
|
def download
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
<SOAP-ENV:Body>
|
266
|
-
<ns2:DownloadArticleInput>
|
267
|
-
<ns1:ATYPE>#{@type.upcase}</ns1:ATYPE>
|
268
|
-
</ns2:DownloadArticleInput>
|
269
|
-
</SOAP-ENV:Body>
|
270
|
-
</SOAP-ENV:Envelope>
|
271
|
-
</ns1:ATYPE></ns2:DownloadArticleInput></SOAP-ENV:Body>
|
272
|
-
)
|
273
|
-
report_download(@url, @file2save)
|
274
|
-
return IO.read(@file2save) if Oddb2xml.skip_download? && File.exist?(@file2save)
|
275
|
-
FileUtils.rm_f(@file2save, verbose: true)
|
276
|
-
response = @client.call(:download, xml: soap)
|
277
|
-
if response.success?
|
278
|
-
if (xml = response.to_xml)
|
279
|
-
xml = File.read(File.join(Oddb2xml::SpecData, File.basename(@file2save))) if defined?(RSpec)
|
280
|
-
response = nil # win
|
281
|
-
FileUtils.makedirs(DOWNLOADS)
|
282
|
-
File.open(@file2save, "w+") { |file| file.write xml }
|
283
|
-
if @options[:artikelstamm]
|
284
|
-
cmd = "xmllint --format --output #{@file2save} #{@file2save}"
|
285
|
-
Oddb2xml.log(cmd)
|
286
|
-
system(cmd)
|
287
|
-
end
|
288
|
-
else
|
289
|
-
# received broken data or internal error
|
290
|
-
raise StandardError
|
291
|
-
end
|
292
|
-
else
|
293
|
-
raise Timeout::Error
|
294
|
-
end
|
295
|
-
rescue HTTPI::SSLError
|
296
|
-
exit # catch me in Cli class
|
297
|
-
rescue Timeout::Error, Errno::ETIMEDOUT
|
298
|
-
retrievable? ? retry : raise
|
299
|
-
end
|
300
|
-
xml
|
261
|
+
filename = "Refdata.Articles.zip"
|
262
|
+
download_as(filename, "w+")
|
263
|
+
content = read_xml_from_zip(/Refdata.Articles.xml/, File.join(DOWNLOADS, filename))
|
264
|
+
content
|
301
265
|
end
|
302
266
|
end
|
303
267
|
|
data/lib/oddb2xml/extractor.rb
CHANGED
@@ -208,10 +208,13 @@ module Oddb2xml
|
|
208
208
|
|
209
209
|
def to_hash
|
210
210
|
data = {}
|
211
|
-
result =
|
212
|
-
|
213
|
-
|
214
|
-
|
211
|
+
result = SwissRegArticles.parse(@xml.sub(STRIP_FOR_SAX_MACHINE, ""), lazy: true)
|
212
|
+
result.Article.each do |article|
|
213
|
+
article_type = article.MedicinalProduct.ProductClassification.ProductClass
|
214
|
+
if article_type != @type
|
215
|
+
next
|
216
|
+
end
|
217
|
+
ean13 = @type == "PHARMA" ? article.PackagedProduct.DataCarrierIdentifier : article.MedicinalProduct.Identifier
|
215
218
|
if ean13.size < 13
|
216
219
|
puts "Refdata #{@type} use 13 chars not #{ean13.size} for #{ean13}" if $VERBOSE
|
217
220
|
ean13 = ean13.rjust(13, "0")
|
@@ -220,21 +223,29 @@ module Oddb2xml
|
|
220
223
|
puts "Refdata #{@type} remove leading '0' for #{ean13}" if $VERBOSE
|
221
224
|
ean13 = ean13[1..-1]
|
222
225
|
end
|
223
|
-
# but in refdata_nonPharma we have a about 700 GTINs which are 14 characters and longer
|
224
226
|
item = {}
|
225
227
|
item[:ean13] = ean13
|
226
|
-
item[:no8] =
|
228
|
+
item[:no8] = article.PackagedProduct.RegulatedAuthorisationIdentifier || ""
|
227
229
|
item[:data_origin] = "refdata"
|
228
230
|
item[:refdata] = true
|
229
|
-
item[:_type] =
|
230
|
-
item[:last_change] =
|
231
|
-
item[:desc_de] =
|
232
|
-
item[:desc_fr] =
|
233
|
-
item[:desc_it] =
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
231
|
+
item[:_type] = @type.downcase.to_sym
|
232
|
+
item[:last_change] = "" # TODO: Date and time of last data change
|
233
|
+
item[:desc_de] = ""
|
234
|
+
item[:desc_fr] = ""
|
235
|
+
item[:desc_it] = ""
|
236
|
+
article.PackagedProduct.Name.each do |name|
|
237
|
+
if name.Language == "DE"
|
238
|
+
item[:desc_de] = name.FullName
|
239
|
+
elsif name.Language == "FR"
|
240
|
+
item[:desc_fr] = name.FullName
|
241
|
+
elsif name.Language == "IT"
|
242
|
+
item[:desc_it] = name.FullName
|
243
|
+
end
|
244
|
+
end
|
245
|
+
item[:atc_code] = article.MedicinalProduct.ProductClassification.Atc || ""
|
246
|
+
item[:company_name] = article.PackagedProduct.Holder.Name || ""
|
247
|
+
item[:company_ean] = article.PackagedProduct.Holder.Identifier || ""
|
248
|
+
data[ean13] = item
|
238
249
|
end
|
239
250
|
data
|
240
251
|
end
|
data/lib/oddb2xml/version.rb
CHANGED
@@ -238,29 +238,69 @@ class MedicalInformationsEntry
|
|
238
238
|
element :medicalInformations, class: MedicalInformationsContent
|
239
239
|
end
|
240
240
|
|
241
|
-
class
|
241
|
+
class SwissRegProductClassification
|
242
242
|
include SAXMachine
|
243
|
-
|
244
|
-
element :
|
245
|
-
element :GTIN
|
246
|
-
element :PHAR
|
247
|
-
element :SWMC_AUTHNR
|
248
|
-
element :NAME_DE
|
249
|
-
element :NAME_FR
|
250
|
-
element :ADDSCR
|
251
|
-
element :ATC
|
252
|
-
element :AUTH_HOLDER_NAME
|
253
|
-
element :AUTH_HOLDER_GLN
|
243
|
+
element :ProductClass
|
244
|
+
element :Atc
|
254
245
|
end
|
255
246
|
|
256
|
-
class
|
247
|
+
class SwissRegMedicinalProduct
|
257
248
|
include SAXMachine
|
258
|
-
|
259
|
-
|
249
|
+
element :Identifier
|
250
|
+
element :Domain
|
251
|
+
element :LegalStatusOfSupply
|
252
|
+
element :RegulatedAuthorisationIdentifier
|
253
|
+
element :ProductClassification, class: SwissRegProductClassification
|
260
254
|
end
|
261
255
|
|
262
|
-
class
|
256
|
+
class SwissRegHolder
|
263
257
|
include SAXMachine
|
264
|
-
element :
|
265
|
-
element :
|
258
|
+
element :Identifier
|
259
|
+
element :Name
|
260
|
+
end
|
261
|
+
|
262
|
+
class SwissRegName
|
263
|
+
include SAXMachine
|
264
|
+
element :Language
|
265
|
+
element :FullName
|
266
|
+
end
|
267
|
+
|
268
|
+
class SwissRegMarketingStatus
|
269
|
+
include SAXMachine
|
270
|
+
element :DateStart
|
271
|
+
end
|
272
|
+
|
273
|
+
class SwissRegPackagedProduct
|
274
|
+
include SAXMachine
|
275
|
+
element :Identifier
|
276
|
+
element :RegulatedAuthorisationIdentifier
|
277
|
+
element :DataCarrierIdentifier
|
278
|
+
element :Holder, class: SwissRegHolder
|
279
|
+
elements :Name, class: SwissRegName
|
280
|
+
element :MarketingStatus, class: SwissRegMarketingStatus
|
281
|
+
end
|
282
|
+
|
283
|
+
class SwissRegArticle
|
284
|
+
include SAXMachine
|
285
|
+
element :MedicinalProduct, class: SwissRegMedicinalProduct
|
286
|
+
element :PackagedProduct, class: SwissRegPackagedProduct
|
287
|
+
end
|
288
|
+
|
289
|
+
class SwissRegDocumentReference
|
290
|
+
include SAXMachine
|
291
|
+
element :Language
|
292
|
+
element :Url
|
293
|
+
end
|
294
|
+
|
295
|
+
class SwissRegProductPrice
|
296
|
+
include SAXMachine
|
297
|
+
element :RetailPrice
|
298
|
+
end
|
299
|
+
|
300
|
+
class SwissRegArticles
|
301
|
+
include SAXMachine
|
302
|
+
elements :Article, class: SwissRegArticle
|
303
|
+
elements :DocumentReference, class: SwissRegDocumentReference
|
304
|
+
element :Hpc
|
305
|
+
element :ProductPrice, class: SwissRegProductPrice
|
266
306
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oddb2xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -565,7 +565,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
565
565
|
- !ruby/object:Gem::Version
|
566
566
|
version: '0'
|
567
567
|
requirements: []
|
568
|
-
rubygems_version: 3.
|
568
|
+
rubygems_version: 3.5.22
|
569
569
|
signing_key:
|
570
570
|
specification_version: 4
|
571
571
|
summary: oddb2xml creates xml files.
|