oddb2xml 2.9.7 → 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/lib/oddb2xml/cli.rb +15 -5
- data/lib/oddb2xml/downloader.rb +7 -43
- data/lib/oddb2xml/extractor.rb +26 -15
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +58 -18
- metadata +2 -2
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/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
@@ -216,7 +216,7 @@ module Oddb2xml
|
|
216
216
|
include DownloadMethod
|
217
217
|
def init
|
218
218
|
super
|
219
|
-
@url ||= "
|
219
|
+
@url ||= "https://www.spezialitaetenliste.ch/File.axd?file=XMLPublications.zip"
|
220
220
|
end
|
221
221
|
|
222
222
|
def download
|
@@ -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-02
|
11
|
+
date: 2025-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|