oddb2xml 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/History.txt +5 -0
- data/README.md +0 -1
- data/lib/oddb2xml/builder.rb +15 -11
- data/lib/oddb2xml/cli.rb +0 -13
- data/lib/oddb2xml/downloader.rb +0 -7
- data/lib/oddb2xml/extractor.rb +3 -4
- data/lib/oddb2xml/version.rb +1 -1
- data/oddb2xml.xsd +3 -0
- data/spec/builder_spec.rb +39 -11
- data/spec/calc_spec.rb +152 -105
- data/spec/data/swissmedic_package.xlsx +0 -0
- data/spec/downloader_spec.rb +1 -29
- data/spec/extractor_spec.rb +53 -37
- data/spec/fixtures/vcr_cassettes/oddb2xml.json +875 -873
- data/spec/spec_helper.rb +2 -0
- metadata +1 -1
data/spec/downloader_spec.rb
CHANGED
@@ -79,7 +79,7 @@ def common_after
|
|
79
79
|
Dir.chdir(@savedDir) if @savedDir and File.directory?(@savedDir)
|
80
80
|
VCR.eject_cassette
|
81
81
|
vcr_file = File.expand_path(File.join(Oddb2xml::SpecData, '..', 'fixtures', 'vcr_cassettes', 'oddb2xml.json'))
|
82
|
-
puts "Pretty-printing #{vcr_file} exists? #{File.exists?(vcr_file)}"
|
82
|
+
puts "Pretty-printing #{vcr_file} exists? #{File.exists?(vcr_file)}" if $VERBOSE
|
83
83
|
vcr_file_new = vcr_file.sub('.json', '.new')
|
84
84
|
cmd = "cat #{vcr_file} | python -mjson.tool > #{vcr_file_new}"
|
85
85
|
res = system(cmd)
|
@@ -343,34 +343,6 @@ describe Oddb2xml::EphaDownloader do
|
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
346
|
-
describe Oddb2xml::BMUpdateDownloader do
|
347
|
-
include ServerMockHelper
|
348
|
-
before(:all) do VCR.eject_cassette end
|
349
|
-
before(:each) do
|
350
|
-
@downloader = Oddb2xml::BMUpdateDownloader.new
|
351
|
-
VCR.insert_cassette('oddb2xml', :tag => :BMUpdate)
|
352
|
-
common_before
|
353
|
-
end
|
354
|
-
after(:each) do
|
355
|
-
common_after
|
356
|
-
end
|
357
|
-
|
358
|
-
it_behaves_like 'any downloader'
|
359
|
-
context 'when download is called' do
|
360
|
-
let(:txt) {
|
361
|
-
@downloader.download
|
362
|
-
}
|
363
|
-
it 'should read txt as String' do
|
364
|
-
txt.should be_a String
|
365
|
-
txt.bytes.should_not nil
|
366
|
-
end
|
367
|
-
it 'should clean up current directory' do
|
368
|
-
expect { txt }.not_to raise_error
|
369
|
-
# File.exist?('oddb2xml_files_bm_update.txt').should eq(false)
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
346
|
describe Oddb2xml::BagXmlDownloader do
|
375
347
|
include ServerMockHelper
|
376
348
|
before(:all) do VCR.eject_cassette end
|
data/spec/extractor_spec.rb
CHANGED
@@ -4,19 +4,7 @@ require 'spec_helper'
|
|
4
4
|
require "#{Dir.pwd}/lib/oddb2xml/downloader"
|
5
5
|
ENV['TZ'] = 'UTC' # needed for last_change
|
6
6
|
LAST_CHANGE = "2015-07-03 00:00:00 +0000"
|
7
|
-
|
8
|
-
before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
|
9
|
-
after(:all) { VCR.eject_cassette }
|
10
|
-
before(:all) {
|
11
|
-
VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
|
12
|
-
@downloader = Oddb2xml::BMUpdateDownloader.new
|
13
|
-
xml = @downloader.download
|
14
|
-
@items = Oddb2xml::BMUpdateExtractor.new(xml).to_hash
|
15
|
-
}
|
16
|
-
it "should have at least one item" do
|
17
|
-
expect(@items.size).not_to eq 0
|
18
|
-
end
|
19
|
-
end
|
7
|
+
NR_PACKS = 17
|
20
8
|
|
21
9
|
describe Oddb2xml::LppvExtractor do
|
22
10
|
before(:all) {
|
@@ -76,7 +64,7 @@ describe Oddb2xml::RefdataExtractor do
|
|
76
64
|
:company_name=>"Desitin Pharma GmbH",
|
77
65
|
:company_ean=>"7601001320451"}
|
78
66
|
expect(item_found).to eq(expected)
|
79
|
-
expect(@pharma_items.size).to eq(
|
67
|
+
expect(@pharma_items.size).to eq(NR_PACKS)
|
80
68
|
end
|
81
69
|
end
|
82
70
|
context 'should handle nonpharma articles' do
|
@@ -165,44 +153,72 @@ describe Oddb2xml::SwissmedicInfoExtractor do
|
|
165
153
|
end
|
166
154
|
|
167
155
|
describe Oddb2xml::SwissmedicExtractor do
|
168
|
-
before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml') }
|
156
|
+
before(:all) { VCR.eject_cassette; VCR.insert_cassette('oddb2xml'); cleanup_directories_before_run }
|
169
157
|
after(:all) { VCR.eject_cassette }
|
170
158
|
context 'when transfer.dat is empty' do
|
171
159
|
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
|
172
160
|
it { expect(subject.to_hash).to be_empty }
|
173
161
|
end
|
174
162
|
context 'can parse swissmedic_package.xlsx' do
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
163
|
+
before(:all) do
|
164
|
+
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
|
165
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :package).to_hash
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_pack_by_ean13(ean13)
|
169
|
+
@packs.find{|pack| pack[1][:ean] == ean13.to_s }[1]
|
170
|
+
end
|
171
|
+
it 'should have correct nr of packages' do
|
172
|
+
expect(@packs.size).to eq(NR_PACKS)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should have serocytol' do
|
176
|
+
serocytol = get_pack_by_ean13(7680620690084)
|
177
|
+
expect(serocytol[:atc_code]).to eq('N03AX14')
|
178
|
+
expect(serocytol[:swissmedic_category]).to eq('B')
|
179
|
+
expect(serocytol[:package_size]).to eq('30')
|
180
|
+
expect(serocytol[:einheit_swissmedic]).to eq('Tablette(n)')
|
181
|
+
expect(serocytol[:substance_swissmedic]).to eq('levetiracetamum')
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should have a correct insulin (gentechnik)' do
|
185
|
+
humalog = get_pack_by_ean13(7680532900196)
|
186
|
+
expect(humalog[:atc_code]).to eq('A10AB04')
|
187
|
+
expect(humalog[:swissmedic_category]).to eq('B')
|
188
|
+
expect(humalog[:package_size]).to eq('1 x 10 ml')
|
189
|
+
expect(humalog[:einheit_swissmedic]).to eq('Flasche(n)')
|
190
|
+
expect(humalog[:substance_swissmedic]).to eq('insulinum lisprum')
|
191
|
+
expect(humalog[:gen_production]).to eq('X')
|
192
|
+
expect(humalog[:insulin_category]).to eq('Insulinanalog: schnell wirkend')
|
193
|
+
expect(humalog[:drug_index]).to eq('')
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should have a correct drug information' do
|
197
|
+
humalog = get_pack_by_ean13(7680555610041)
|
198
|
+
expect(humalog[:atc_code]).to eq('N07BC06')
|
199
|
+
expect(humalog[:swissmedic_category]).to eq('A')
|
200
|
+
expect(humalog[:sequence_name]).to eq('Diaphin 10 g i.v., Injektionspräparat')
|
201
|
+
expect(humalog[:gen_production]).to eq('')
|
202
|
+
expect(humalog[:insulin_category]).to eq('')
|
203
|
+
expect(humalog[:drug_index]).to eq('d')
|
204
|
+
end
|
190
205
|
end
|
206
|
+
|
191
207
|
context 'can parse swissmedic_fridge.xlsx' do
|
192
208
|
it {
|
193
|
-
filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
|
194
|
-
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :fridge).to_arry
|
195
|
-
expect(@packs.size
|
209
|
+
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
|
210
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :fridge).to_arry
|
211
|
+
expect(@packs.size).to eq NR_PACKS
|
196
212
|
expect(@packs[0]).to eq("58618")
|
197
213
|
expect(@packs[1]).to eq("00696")
|
198
214
|
}
|
199
215
|
end
|
200
216
|
context 'can parse swissmedic_orphans.xls' do
|
201
217
|
it {
|
202
|
-
filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
|
203
|
-
expect(File.exists?(filename)).to eq(true), "File #{filename} must exists"
|
204
|
-
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :orphan).to_arry
|
205
|
-
expect(@packs.size
|
218
|
+
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
|
219
|
+
expect(File.exists?(@filename)).to eq(true), "File #{@filename} must exists"
|
220
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :orphan).to_arry
|
221
|
+
expect(@packs.size).to eq 78
|
206
222
|
expect(@packs.first).to eq("62132")
|
207
223
|
expect(@packs[7]).to eq("00687")
|
208
224
|
}
|