oddb2xml 1.6.2 → 1.6.3
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.
- data/Gemfile +4 -0
- data/History.txt +6 -0
- data/bin/oddb2xml +8 -2
- data/lib/oddb2xml/builder.rb +15 -5
- data/lib/oddb2xml/cli.rb +4 -2
- data/lib/oddb2xml/compressor.rb +2 -4
- data/lib/oddb2xml/downloader.rb +44 -47
- data/lib/oddb2xml/extractor.rb +1 -0
- data/lib/oddb2xml/version.rb +1 -1
- data/spec/builder_spec.rb +76 -1
- data/spec/cli_spec.rb +6 -2
- data/spec/data/XMLPublications.zip +0 -0
- data/spec/data/swissindex_pharma.xml +22 -36
- data/spec/data/swissmedic_packages.xls +0 -0
- data/spec/extractor_spec.rb +30 -7
- data/spec/spec_helper.rb +2 -2
- metadata +2 -2
data/Gemfile
CHANGED
data/History.txt
CHANGED
data/bin/oddb2xml
CHANGED
@@ -13,6 +13,7 @@ def help
|
|
13
13
|
#$0 ver.#{Oddb2xml::VERSION}
|
14
14
|
Usage:
|
15
15
|
oddb2xml [option]
|
16
|
+
produced files are found under data
|
16
17
|
-a T, --append=T Additional target. T, only 'nonpharma' is available.
|
17
18
|
-c F, --compress=F Compress format F. {tar.gz|zip}
|
18
19
|
-f F, --format=F File format F, default is xml. {xml|dat}
|
@@ -24,6 +25,10 @@ Usage:
|
|
24
25
|
-t S, --tag-suffix=S XML tag suffix S. Default is none. [A-z0-9]
|
25
26
|
If S is given, it is also used as prefix of filename.
|
26
27
|
-x N, --context=N context N {product|address}. product is default.
|
28
|
+
|
29
|
+
For debugging purposes
|
30
|
+
--skip-download skips downloading files it the file is already under data/downloads.
|
31
|
+
Downloaded files are saved under data/downloads
|
27
32
|
-h, --help Show this help message.
|
28
33
|
EOS
|
29
34
|
end
|
@@ -38,6 +43,7 @@ opts = {
|
|
38
43
|
:tag_suffix => nil,
|
39
44
|
:debug => false,
|
40
45
|
:ean14 => false,
|
46
|
+
:skip_download=> false,
|
41
47
|
}
|
42
48
|
|
43
49
|
parser.on('-a v', '--append v', /^nonpharma$/) {|v| opts[:nonpharma] = true }
|
@@ -48,7 +54,7 @@ parser.on('-i v', '--include v', /^ean14$/) {|v| opts[:ean14] = true }
|
|
48
54
|
parser.on('-t v', '--tag-suffix v', /^[A-z0-9]*$/i) {|v| opts[:tag_suffix] = v.upcase }
|
49
55
|
parser.on('-x v', '--context v', /^addr(ess)*$/i){|v| opts[:address] = true }
|
50
56
|
parser.on('-p v', '--price v', /^zurrose$/) {|v| opts[:price] = v.intern }
|
51
|
-
|
57
|
+
parser.on('--skip-download') {|v| opts[:skip_download] = true }
|
52
58
|
parser.on_tail('-h', '--help') { puts help; exit }
|
53
59
|
|
54
60
|
args = ARGV.dup
|
@@ -81,6 +87,6 @@ then you will not see anymore warnings
|
|
81
87
|
end
|
82
88
|
ui.run
|
83
89
|
rescue Interrupt
|
84
|
-
puts
|
85
90
|
exit
|
86
91
|
end
|
92
|
+
puts "#{Time.now}: #{__LINE__} done"; $stdout.sync
|
data/lib/oddb2xml/builder.rb
CHANGED
@@ -22,7 +22,8 @@ module Oddb2xml
|
|
22
22
|
:infos, :packs, :prices,
|
23
23
|
:ean14, :tag_suffix,
|
24
24
|
:companies, :people
|
25
|
-
def initialize
|
25
|
+
def initialize(args = {})
|
26
|
+
@options = args
|
26
27
|
@subject = nil
|
27
28
|
@index = {}
|
28
29
|
@items = {}
|
@@ -390,8 +391,12 @@ module Oddb2xml
|
|
390
391
|
seq = obj[:seq]
|
391
392
|
length += 1
|
392
393
|
xml.PRD('DT' => '') {
|
393
|
-
|
394
|
-
|
394
|
+
ean = obj[:ean].to_s
|
395
|
+
xml.GTIN ean
|
396
|
+
ppac = ((_ppac = @packs[ean[4..11].intern] and !_ppac[:is_tier]) ? _ppac : {})
|
397
|
+
unless ppac
|
398
|
+
ppac = @packs.find{|pac| pac.ean == ean }.first
|
399
|
+
end
|
395
400
|
xml.PRODNO ppac[:prodno] if ppac[:prodno] and !ppac[:prodno].empty?
|
396
401
|
if seq
|
397
402
|
%w[de fr].each do |l|
|
@@ -537,8 +542,12 @@ module Oddb2xml
|
|
537
542
|
fr_idx = obj[:fr][i] # swissindex FR
|
538
543
|
pac,no8 = nil,de_idx[:ean][4..11] # BAG-XML(SL/LS)
|
539
544
|
ppac = nil # Packungen
|
545
|
+
ean = de_idx[:ean]
|
540
546
|
if obj[:seq]
|
541
547
|
pac = obj[:seq][:packages][de_idx[:pharmacode]]
|
548
|
+
pac = obj[:seq][:packages][ean] unless pac
|
549
|
+
else
|
550
|
+
pac = @items[ean][:packages][ean] if @items and @items[ean]
|
542
551
|
end
|
543
552
|
if no8
|
544
553
|
ppac = ((_ppac = @packs[no8.intern] and !_ppac[:is_tier]) ? _ppac : nil)
|
@@ -573,7 +582,7 @@ module Oddb2xml
|
|
573
582
|
if de_idx
|
574
583
|
xml.SALECD(de_idx[:status].empty? ? 'N' : de_idx[:status])
|
575
584
|
end
|
576
|
-
if pac
|
585
|
+
if pac and pac[:limitation_points]
|
577
586
|
#xml.INSLIM
|
578
587
|
xml.LIMPTS pac[:limitation_points] unless pac[:limitation_points].empty?
|
579
588
|
end
|
@@ -656,7 +665,7 @@ module Oddb2xml
|
|
656
665
|
#xml.LINENO
|
657
666
|
#xml.NOUNITS
|
658
667
|
#}
|
659
|
-
if pac
|
668
|
+
if pac and pac[:prices]
|
660
669
|
pac[:prices].each_pair do |key, price|
|
661
670
|
xml.ARTPRI {
|
662
671
|
xml.VDAT price[:valid_date] unless price[:valid_date].empty?
|
@@ -956,6 +965,7 @@ module Oddb2xml
|
|
956
965
|
pac,no8 = nil,nil
|
957
966
|
if obj[:seq]
|
958
967
|
pac = obj[:seq][:packages][idx[:pharmacode]]
|
968
|
+
pac = obj[:seq][:packages][idx[:ean]] unless pac
|
959
969
|
end
|
960
970
|
# :swissmedic_numbers
|
961
971
|
if pac
|
data/lib/oddb2xml/cli.rb
CHANGED
@@ -5,6 +5,7 @@ require 'oddb2xml/builder'
|
|
5
5
|
require 'oddb2xml/downloader'
|
6
6
|
require 'oddb2xml/extractor'
|
7
7
|
require 'oddb2xml/compressor'
|
8
|
+
require 'oddb2xml/util'
|
8
9
|
|
9
10
|
module Oddb2xml
|
10
11
|
class Cli
|
@@ -14,6 +15,7 @@ module Oddb2xml
|
|
14
15
|
LANGUAGES = %w[DE FR] # EN does not exist
|
15
16
|
def initialize(args)
|
16
17
|
@options = args
|
18
|
+
Oddb2xml.save_options(@options)
|
17
19
|
@mutex = Mutex.new
|
18
20
|
# product
|
19
21
|
@items = {} # Items from Preparations.xml in BAG
|
@@ -88,7 +90,7 @@ module Oddb2xml
|
|
88
90
|
def build
|
89
91
|
begin
|
90
92
|
files.each_pair do |sbj, file|
|
91
|
-
builder = Builder.new do |builder|
|
93
|
+
builder = Builder.new(@options) do |builder|
|
92
94
|
if @options[:address]
|
93
95
|
builder.subject = sbj
|
94
96
|
builder.companies = @companies
|
@@ -143,7 +145,7 @@ module Oddb2xml
|
|
143
145
|
rescue Interrupt
|
144
146
|
files.values.each do |file|
|
145
147
|
if File.exist? file
|
146
|
-
File.unlink
|
148
|
+
File.unlink(file) # we don't save it as it might be only partly downloaded
|
147
149
|
end
|
148
150
|
end
|
149
151
|
raise Interrupt
|
data/lib/oddb2xml/compressor.rb
CHANGED
@@ -36,13 +36,11 @@ module Oddb2xml
|
|
36
36
|
end
|
37
37
|
if File.exists? @compress_file
|
38
38
|
@contents.each do |file|
|
39
|
-
|
39
|
+
Oddb2xml.download_finished(file)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
rescue Errno::ENOENT, StandardError
|
43
|
-
|
44
|
-
File.unlink @compress_file
|
45
|
-
end
|
43
|
+
Oddb2xml.download_finished(@compress_file)
|
46
44
|
return false
|
47
45
|
end
|
48
46
|
return true
|
data/lib/oddb2xml/downloader.rb
CHANGED
@@ -9,18 +9,21 @@ module Oddb2xml
|
|
9
9
|
private
|
10
10
|
def download_as(file, option='r')
|
11
11
|
data = nil
|
12
|
-
|
13
|
-
response = @agent.get(@url)
|
14
|
-
response.save_as(file)
|
15
|
-
response = nil # win
|
12
|
+
if Oddb2xml.skip_download(file)
|
16
13
|
io = File.open(file, option)
|
17
14
|
data = io.read
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
File.
|
15
|
+
else
|
16
|
+
begin
|
17
|
+
response = @agent.get(@url)
|
18
|
+
response.save_as(file)
|
19
|
+
response = nil # win
|
20
|
+
io = File.open(file, option)
|
21
|
+
data = io.read
|
22
|
+
rescue Timeout::Error, Errno::ETIMEDOUT
|
23
|
+
retrievable? ? retry : raise
|
24
|
+
ensure
|
25
|
+
io.close if io and !io.closed? # win
|
26
|
+
Oddb2xml.download_finished(file)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
return data
|
@@ -153,17 +156,17 @@ module Oddb2xml
|
|
153
156
|
if @options[:debug]
|
154
157
|
FileUtils.copy(File.expand_path("../../../spec/data/#{file}", __FILE__), '.')
|
155
158
|
else
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
+
unless Oddb2xml.skip_download(file)
|
160
|
+
response = @agent.get(@url)
|
161
|
+
response.save_as(file)
|
162
|
+
response = nil # win
|
163
|
+
end
|
159
164
|
end
|
160
|
-
|
165
|
+
read_xml_form_zip(/^Preparation/iu, file)
|
161
166
|
rescue Timeout::Error, Errno::ETIMEDOUT
|
162
167
|
retrievable? ? retry : raise
|
163
168
|
ensure
|
164
|
-
|
165
|
-
File.unlink(file)
|
166
|
-
end
|
169
|
+
Oddb2xml.download_finished(file)
|
167
170
|
end
|
168
171
|
end
|
169
172
|
end
|
@@ -189,6 +192,7 @@ module Oddb2xml
|
|
189
192
|
if @options[:debug]
|
190
193
|
return File.read(File.expand_path("../../../spec/data/swissindex_#{@type}_#{@lang}.xml", __FILE__))
|
191
194
|
end
|
195
|
+
file2save = File.expand_path("../../../data/download/swissindex_#{@type}_#{@lang}.xml", __FILE__)
|
192
196
|
soap = <<XML
|
193
197
|
<?xml version="1.0" encoding="utf-8"?>
|
194
198
|
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
@@ -201,6 +205,7 @@ XML
|
|
201
205
|
if response.success?
|
202
206
|
if xml = response.to_xml
|
203
207
|
response = nil # win
|
208
|
+
File.open(file2save, 'w+') { |file| file.puts xml }
|
204
209
|
return xml
|
205
210
|
else
|
206
211
|
# received broken data or internal error
|
@@ -239,9 +244,11 @@ XML
|
|
239
244
|
page = @agent.get(@url)
|
240
245
|
if link_node = page.search(@xpath).first
|
241
246
|
link = Mechanize::Page::Link.new(link_node, @agent, page)
|
242
|
-
|
243
|
-
|
244
|
-
|
247
|
+
unless Oddb2xml.skip_download(file)
|
248
|
+
response = link.click
|
249
|
+
response.save_as(file)
|
250
|
+
response = nil # win
|
251
|
+
end
|
245
252
|
end
|
246
253
|
io = File.open(file, 'rb')
|
247
254
|
return io.read
|
@@ -249,9 +256,7 @@ XML
|
|
249
256
|
retrievable? ? retry : raise
|
250
257
|
ensure
|
251
258
|
io.close if io and !io.closed?
|
252
|
-
|
253
|
-
File.unlink(file)
|
254
|
-
end
|
259
|
+
Oddb2xml.download_finished(file)
|
255
260
|
end
|
256
261
|
end
|
257
262
|
end
|
@@ -264,37 +269,29 @@ XML
|
|
264
269
|
def download
|
265
270
|
file = "swissmedic_info.zip"
|
266
271
|
begin
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
272
|
+
unless Oddb2xml.skip_download(file)
|
273
|
+
response = nil
|
274
|
+
if home = @agent.get(@url)
|
275
|
+
form = home.form_with(:id => 'Form1')
|
276
|
+
bttn = form.button_with(:name => 'ctl00$MainContent$btnOK')
|
277
|
+
if page = form.submit(bttn)
|
278
|
+
form = page.form_with(:id => 'Form1')
|
279
|
+
bttn = form.button_with(:name => 'ctl00$MainContent$BtnYes')
|
280
|
+
response = form.submit(bttn)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
if response
|
284
|
+
response.save_as(file)
|
285
|
+
response = nil # win
|
275
286
|
end
|
276
287
|
end
|
277
|
-
|
278
|
-
response.save_as(file)
|
279
|
-
response = nil # win
|
280
|
-
end
|
281
|
-
return read_xml_form_zip(/^AipsDownload_/iu, file)
|
288
|
+
read_xml_form_zip(/^AipsDownload_/iu, file)
|
282
289
|
rescue Timeout::Error, Errno::ETIMEDOUT
|
283
290
|
retrievable? ? retry : raise
|
284
291
|
rescue NoMethodError
|
285
292
|
# pass
|
286
293
|
ensure
|
287
|
-
|
288
|
-
deleted = false
|
289
|
-
if File.exists?(file)
|
290
|
-
until deleted
|
291
|
-
begin
|
292
|
-
File.unlink(file)
|
293
|
-
deleted = true
|
294
|
-
rescue Errno::EACCES # Permission Denied on Windows
|
295
|
-
end
|
296
|
-
end
|
297
|
-
end
|
294
|
+
Oddb2xml.download_finished(file)
|
298
295
|
end
|
299
296
|
end
|
300
297
|
end
|
data/lib/oddb2xml/extractor.rb
CHANGED
@@ -240,6 +240,7 @@ module Oddb2xml
|
|
240
240
|
no8 = sprintf('%05d',row[i_5].to_i) + sprintf('%03d',row[i_3].to_i)
|
241
241
|
prodno = sprintf('%05d',row[i_5].to_i) + row[p_1_2].to_i.to_s
|
242
242
|
unless no8.empty?
|
243
|
+
next if no8.to_i == 0
|
243
244
|
ean_base12 = "7680#{no8}"
|
244
245
|
data[no8.intern] = {
|
245
246
|
:ean => (ean_base12.ljust(12, '0') + calc_checksum(ean_base12)),
|
data/lib/oddb2xml/version.rb
CHANGED
data/spec/builder_spec.rb
CHANGED
@@ -2,7 +2,82 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
+
module Kernel
|
6
|
+
def capture(stream)
|
7
|
+
begin
|
8
|
+
stream = stream.to_s
|
9
|
+
eval "$#{stream} = StringIO.new"
|
10
|
+
yield
|
11
|
+
result = eval("$#{stream}").string
|
12
|
+
ensure
|
13
|
+
eval "$#{stream} = #{stream.upcase}"
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
5
19
|
describe Oddb2xml::Builder do
|
6
|
-
|
20
|
+
include ServerMockHelper
|
21
|
+
before(:all) do
|
22
|
+
files = (Dir.glob('oddb_*.tar.gz')+ Dir.glob('oddb_*.zip')+ Dir.glob('oddb_*.xml'))# +Dir.glob('data/download/*'))
|
23
|
+
files.each{ |file| FileUtils.rm(file) }
|
24
|
+
end
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
setup_server_mocks
|
28
|
+
setup_swiss_index_server_mock(types = ['NonPharma', 'Pharma'])
|
29
|
+
end
|
30
|
+
context 'should handle BAG-articles with and without pharmacode' do
|
31
|
+
subject do
|
32
|
+
dat = File.read(File.expand_path('../data/Preparation.xml', __FILE__))
|
33
|
+
@items = Oddb2xml::BagXmlExtractor.new(dat).to_hash
|
34
|
+
end
|
35
|
+
it {
|
36
|
+
saved = @items.clone
|
37
|
+
@items = subject.to_hash
|
38
|
+
expect(@items.size).to eq(2)
|
39
|
+
expect(saved).to eq(@items)
|
40
|
+
}
|
41
|
+
end if false
|
42
|
+
|
43
|
+
context 'when no option is given' do
|
44
|
+
let(:cli) do
|
45
|
+
opts = {}
|
46
|
+
Oddb2xml::Cli.new(opts)
|
47
|
+
end
|
48
|
+
it 'should generate a valid oddb_product.xml' do
|
49
|
+
res = capture(:stdout){ cli.run }
|
50
|
+
res.should match(/products/)
|
51
|
+
article_filename = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb_article.xml'))
|
52
|
+
File.exists?(article_filename).should be_true
|
53
|
+
article_xml = IO.read(article_filename)
|
54
|
+
product_filename = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb_product.xml'))
|
55
|
+
File.exists?(product_filename).should be_true
|
56
|
+
product_xml = IO.read(product_filename)
|
57
|
+
article_xml.should match(/3TC/)
|
58
|
+
article_xml.should match(/<PHAR>1699947</)
|
59
|
+
article_xml.should match(/<SMNO>53662013</)
|
60
|
+
article_xml.should match(/<DSCRD>3TC Filmtabl 150 mg</)
|
61
|
+
article_xml.should match(/<COMPNO>7601001392175</)
|
62
|
+
article_xml.should match(/<BC>7680536620137</)
|
63
|
+
article_xml.should match(/<VDAT>01.10.2011</)
|
64
|
+
article_xml.should match(/<PTYP>PEXF</)
|
65
|
+
article_xml.should match(/<PRICE>164.55</)
|
66
|
+
article_xml.should match(/<PTYP>PPUB</)
|
67
|
+
article_xml.should match(/<PRICE>205.3</)
|
68
|
+
|
69
|
+
article_xml.should match(/Levetiracetam DESITIN/i) #
|
70
|
+
article_xml.should match(/7680536620137/) # Pharmacode
|
71
|
+
article_xml.should match(/<PRICE>13.49</)
|
72
|
+
article_xml.should match(/<PRICE>27.8</)
|
73
|
+
|
74
|
+
product_xml.should match(/3TC/)
|
75
|
+
product_xml.should match(/7680620690084/) # Levetiracetam DESITIN
|
76
|
+
article_xml.scan(/<ART DT=/).size.should eq(2) # we should find two articles
|
77
|
+
article_xml.should match(/<PHAR>5819012</)
|
78
|
+
article_xml.should match(/<DSCRD>LEVETIRACETAM DESITIN Filmtabl 250 mg/)
|
79
|
+
article_xml.should match(/<COMPNO>7601001320451</)
|
80
|
+
end
|
81
|
+
end
|
7
82
|
end
|
8
83
|
|
data/spec/cli_spec.rb
CHANGED
@@ -46,6 +46,10 @@ end
|
|
46
46
|
|
47
47
|
describe Oddb2xml::Cli do
|
48
48
|
include ServerMockHelper
|
49
|
+
before(:all) do
|
50
|
+
files = (Dir.glob('oddb_*.tar.gz')+ Dir.glob('oddb_*.zip')+ Dir.glob('oddb_*.xml'))# +Dir.glob('data/download/*'))
|
51
|
+
files.each{ |file| FileUtils.rm(file) }
|
52
|
+
end
|
49
53
|
before(:each) do
|
50
54
|
setup_server_mocks
|
51
55
|
end
|
@@ -72,7 +76,7 @@ describe Oddb2xml::Cli do
|
|
72
76
|
it 'should not create any xml file' do
|
73
77
|
capture(:stdout) { cli.run }.should match(/Pharma/)
|
74
78
|
Dir.glob('oddb_*.xml').each do |file|
|
75
|
-
File.exists?(file).should
|
79
|
+
File.exists?(file).should be_false
|
76
80
|
end
|
77
81
|
end
|
78
82
|
after(:each) do
|
@@ -104,7 +108,7 @@ describe Oddb2xml::Cli do
|
|
104
108
|
it 'should not create any xml file' do
|
105
109
|
capture(:stdout) { cli.run }.should match(/Pharma/)
|
106
110
|
Dir.glob('oddb_*.xml').each do |file|
|
107
|
-
File.exists?(file).should
|
111
|
+
File.exists?(file).should be_false
|
108
112
|
end
|
109
113
|
end
|
110
114
|
after(:each) do
|
Binary file
|
@@ -1,55 +1,41 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<soap:Envelope
|
3
|
-
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
4
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
-
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
2
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
6
3
|
<soap:Body>
|
7
|
-
<PHARMA
|
4
|
+
<PHARMA xmlns="http://swissindex.e-mediat.net/SwissindexPharma_out_V101" CREATION_DATETIME="2013-12-10T10:09:26.8198427+01:00">
|
5
|
+
<!-- spec/data/swissindex_pharma.xml. Values for spec/builder_spec.rb -->
|
8
6
|
CREATION_DATETIME="2012-10-18T06:31:19.4687619+02:00"
|
9
7
|
xmlns="http://example.com/test">
|
10
|
-
<ITEM DT="
|
11
|
-
<GTIN>
|
12
|
-
<PHAR>
|
8
|
+
<ITEM DT="2013-06-22T00:00:00">
|
9
|
+
<GTIN>7680536620137</GTIN>
|
10
|
+
<PHAR>1699947</PHAR>
|
13
11
|
<STATUS>A</STATUS>
|
14
|
-
<STDATE>
|
12
|
+
<STDATE>1996-03-20T00:00:00</STDATE>
|
15
13
|
<LANG>DE</LANG>
|
16
|
-
<DSCR>
|
17
|
-
<ADDSCR>
|
18
|
-
<ATC>
|
14
|
+
<DSCR>3TC Filmtabl 150 mg</DSCR>
|
15
|
+
<ADDSCR>60 Stk</ADDSCR>
|
16
|
+
<ATC>J05AF05</ATC>
|
19
17
|
<COMP>
|
20
|
-
<NAME>
|
21
|
-
<GLN>
|
18
|
+
<NAME>ViiV Healthcare GmbH</NAME>
|
19
|
+
<GLN>7601001392175</GLN>
|
22
20
|
</COMP>
|
23
21
|
</ITEM>
|
24
|
-
<ITEM DT="
|
25
|
-
<GTIN>
|
26
|
-
<PHAR>
|
22
|
+
<ITEM DT="2013-12-06T00:00:00">
|
23
|
+
<GTIN>7680620690084</GTIN>
|
24
|
+
<PHAR>5819012</PHAR>
|
27
25
|
<STATUS>A</STATUS>
|
28
|
-
<STDATE>
|
26
|
+
<STDATE>2013-10-26T00:00:00</STDATE>
|
29
27
|
<LANG>DE</LANG>
|
30
|
-
<DSCR>
|
31
|
-
<ADDSCR>
|
32
|
-
<ATC>
|
28
|
+
<DSCR>LEVETIRACETAM DESITIN Filmtabl 250 mg</DSCR>
|
29
|
+
<ADDSCR>30 Stk</ADDSCR>
|
30
|
+
<ATC>N03AX14</ATC>
|
33
31
|
<COMP>
|
34
|
-
<NAME>
|
35
|
-
|
36
|
-
</ITEM>
|
37
|
-
<ITEM DT="2012-10-18T00:00:00">
|
38
|
-
<GTIN>0000000000002</GTIN>
|
39
|
-
<PHAR>00002</PHAR>
|
40
|
-
<STATUS>A</STATUS>
|
41
|
-
<STDATE>2002-05-23T00:00:00</STDATE>
|
42
|
-
<LANG>DE</LANG>
|
43
|
-
<DSCR>Baz 10 Tablet</DSCR>
|
44
|
-
<ADDSCR>5 Stk</ADDSCR>
|
45
|
-
<ATC>A03AA03</ATC>
|
46
|
-
<COMP>
|
47
|
-
<NAME>EXAMPLE.AC AG</NAME>
|
32
|
+
<NAME>Desitin Pharma GmbH</NAME>
|
33
|
+
<GLN>7601001320451</GLN>
|
48
34
|
</COMP>
|
49
35
|
</ITEM>
|
50
36
|
<RESULT>
|
51
37
|
<OK_ERROR>OK</OK_ERROR>
|
52
|
-
<NBR_RECORD>
|
38
|
+
<NBR_RECORD>2</NBR_RECORD>
|
53
39
|
</RESULT>
|
54
40
|
</PHARMA>
|
55
41
|
</soap:Body>
|
Binary file
|
data/spec/extractor_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require "#{Dir.pwd}/lib/oddb2xml/downloader"
|
4
5
|
|
5
6
|
describe Oddb2xml::Extractor do
|
6
7
|
it "pending"
|
@@ -41,27 +42,49 @@ describe Oddb2xml::SwissIndexExtractor do
|
|
41
42
|
it "pending"
|
42
43
|
end
|
43
44
|
|
44
|
-
describe Oddb2xml::
|
45
|
+
describe Oddb2xml::BMUpdateExtractor do
|
45
46
|
it "pending"
|
46
47
|
end
|
47
48
|
|
48
|
-
describe Oddb2xml::
|
49
|
+
describe Oddb2xml::LppvExtractor do
|
49
50
|
it "pending"
|
50
51
|
end
|
51
52
|
|
52
|
-
describe Oddb2xml::
|
53
|
+
describe Oddb2xml::SwissIndexExtractor do
|
53
54
|
it "pending"
|
54
55
|
end
|
55
56
|
|
56
|
-
describe Oddb2xml::
|
57
|
+
describe Oddb2xml::MigelExtractor do
|
57
58
|
it "pending"
|
58
59
|
end
|
59
60
|
|
60
|
-
describe Oddb2xml::
|
61
|
-
|
61
|
+
describe Oddb2xml::SwissmedicInfoExtractor do
|
62
|
+
context 'when transfer.dat is empty' do
|
63
|
+
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
|
64
|
+
it { expect(subject.to_hash).to be_empty }
|
65
|
+
end
|
66
|
+
context 'can parse swissmedic_packages.xls' do
|
67
|
+
it {
|
68
|
+
filename = File.join(File.dirname(__FILE__), 'data/swissmedic_packages.xls')
|
69
|
+
bin = IO.read(filename)
|
70
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(bin, :package).to_hash
|
71
|
+
expect(@packs.size).to eq(14)
|
72
|
+
}
|
73
|
+
end
|
62
74
|
end
|
63
75
|
|
64
|
-
describe Oddb2xml::
|
76
|
+
describe Oddb2xml::EphaExtractor do
|
77
|
+
context 'can parse epha_interactions.csv' do
|
78
|
+
it {
|
79
|
+
filename = File.join(File.dirname(__FILE__), 'data/epha_interactions.csv')
|
80
|
+
string = IO.read(filename)
|
81
|
+
@actions = Oddb2xml::EphaExtractor.new(string).to_arry
|
82
|
+
expect(@actions.size).to eq(2)
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe Oddb2xml::MedregbmExtractor do
|
65
88
|
it "pending"
|
66
89
|
end
|
67
90
|
|
data/spec/spec_helper.rb
CHANGED
@@ -42,8 +42,8 @@ module ServerMockHelper
|
|
42
42
|
:headers => {'Content-Type' => 'application/zip; charset=utf-8'},
|
43
43
|
:body => stub_response)
|
44
44
|
end
|
45
|
-
def setup_swiss_index_server_mock
|
46
|
-
|
45
|
+
def setup_swiss_index_server_mock(types = ['Pharma', 'NonPharma'])
|
46
|
+
types.each do |type|
|
47
47
|
# wsdl
|
48
48
|
stub_wsdl_url = "https://index.ws.e-mediat.net/Swissindex/#{type}/ws_#{type}_V101.asmx?WSDL"
|
49
49
|
stub_response = File.read(File.expand_path("../data/wsdl_#{type.downcase}.xml", __FILE__))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oddb2xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|