oddb2xml 2.7.1 → 2.7.2
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/.github/workflows/ruby.yml +1 -1
- data/.standard.yml +2 -0
- data/Gemfile +3 -3
- data/History.txt +8 -0
- data/README.md +1 -1
- data/Rakefile +24 -23
- data/bin/check_artikelstamm +11 -11
- data/bin/compare_v5 +23 -23
- data/bin/oddb2xml +14 -13
- data/lib/oddb2xml.rb +1 -1
- data/lib/oddb2xml/builder.rb +1070 -1038
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -236
- data/lib/oddb2xml/compare.rb +70 -59
- data/lib/oddb2xml/compositions_syntax.rb +448 -430
- data/lib/oddb2xml/compressor.rb +20 -20
- data/lib/oddb2xml/downloader.rb +153 -127
- data/lib/oddb2xml/extractor.rb +302 -289
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +263 -269
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +163 -163
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/oddb2xml.gemspec +31 -32
- data/spec/artikelstamm_spec.rb +111 -110
- data/spec/builder_spec.rb +489 -505
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +173 -174
- data/spec/compare_spec.rb +9 -11
- data/spec/composition_syntax_spec.rb +390 -409
- data/spec/compressor_spec.rb +48 -48
- data/spec/data/transfer.dat +1 -0
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +247 -260
- data/spec/extractor_spec.rb +171 -159
- data/spec/galenic_spec.rb +233 -256
- data/spec/options_spec.rb +116 -119
- data/spec/parslet_spec.rb +833 -861
- data/spec/spec_helper.rb +154 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +19 -3
data/spec/extractor_spec.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
4
2
|
require "#{Dir.pwd}/lib/oddb2xml/downloader"
|
5
|
-
ENV[
|
3
|
+
ENV["TZ"] = "UTC" # needed for last_change
|
6
4
|
LAST_CHANGE = "2015-07-03 00:00:00 +0000"
|
5
|
+
LAST_CHANGE_2 = "2015-11-24 00:00:00 +0000"
|
7
6
|
|
8
7
|
def common_before
|
9
|
-
@
|
10
|
-
FileUtils.makedirs(Oddb2xml::
|
11
|
-
Dir.chdir(Oddb2xml::
|
12
|
-
VCR.eject_cassette
|
8
|
+
@saved_dir = Dir.pwd
|
9
|
+
FileUtils.makedirs(Oddb2xml::WORK_DIR)
|
10
|
+
Dir.chdir(Oddb2xml::WORK_DIR)
|
11
|
+
VCR.eject_cassette
|
12
|
+
VCR.insert_cassette("oddb2xml")
|
13
13
|
end
|
14
14
|
|
15
15
|
def common_after
|
16
16
|
VCR.eject_cassette
|
17
|
-
Dir.chdir(@
|
17
|
+
Dir.chdir(@saved_dir) if @saved_dir && File.directory?(@saved_dir)
|
18
18
|
end
|
19
19
|
|
20
20
|
describe Oddb2xml::LppvExtractor do
|
@@ -30,56 +30,56 @@ describe Oddb2xml::LppvExtractor do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
unless SKIP_MIGEL_DOWNLOADER
|
34
|
+
describe Oddb2xml::MigelExtractor do
|
35
|
+
before(:all) {
|
36
|
+
common_before
|
37
|
+
@downloader = Oddb2xml::MigelDownloader.new
|
38
|
+
xml = @downloader.download
|
39
|
+
@items = Oddb2xml::MigelExtractor.new(xml).to_hash
|
40
|
+
}
|
41
|
+
after(:all) { common_after }
|
42
|
+
it "should have at some items" do
|
43
|
+
expect(@items.size).not_to eq 0
|
44
|
+
expect(@items.find { |k, v| v[:pharmacode] == 3248410 }).not_to be_nil
|
45
|
+
expect(@items.find { |k, v| /Novopen/i.match(v[:desc_de]) }).not_to be_nil
|
46
|
+
expect(@items.find { |k, v| v[:pharmacode] == 3036984 }).not_to be_nil
|
47
|
+
# Epimineral without pharmacode nor GTIN should not appear
|
48
|
+
expect(@items.find { |k, v| /Epimineral/i.match(v[:desc_de]) }).to be_nil
|
49
|
+
end
|
48
50
|
end
|
49
|
-
end
|
51
|
+
end
|
50
52
|
|
51
53
|
describe Oddb2xml::RefdataExtractor do
|
52
54
|
before(:all) { common_before }
|
53
55
|
after(:all) { common_after }
|
54
|
-
Last_change = '2015-11-24 00:00:00 +0000'
|
55
56
|
|
56
|
-
context
|
57
|
+
context "should handle pharma articles" do
|
57
58
|
subject do
|
58
59
|
@downloader = Oddb2xml::RefdataDownloader.new({}, :pharma)
|
59
60
|
xml = @downloader.download
|
60
|
-
@pharma_items = Oddb2xml::RefdataExtractor.new(xml,
|
61
|
+
@pharma_items = Oddb2xml::RefdataExtractor.new(xml, "PHARMA").to_hash
|
61
62
|
end
|
62
63
|
|
63
64
|
it "should have correct info for no8 62069008 correctly" do
|
64
65
|
@pharma_items = subject.to_hash
|
65
|
-
item_found = @pharma_items.values.find{ |x| x[:ean13].eql?(Oddb2xml::LEVETIRACETAM_GTIN)}
|
66
|
+
item_found = @pharma_items.values.find { |x| x[:ean13].eql?(Oddb2xml::LEVETIRACETAM_GTIN) }
|
66
67
|
expect(item_found).not_to be nil
|
67
|
-
expected = {:
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
:company_ean=>"7601001320451"}
|
68
|
+
expected = {data_origin: "refdata",
|
69
|
+
refdata: true,
|
70
|
+
_type: :pharma,
|
71
|
+
ean13: Oddb2xml::LEVETIRACETAM_GTIN.to_s,
|
72
|
+
no8: "62069008",
|
73
|
+
desc_de: "LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk",
|
74
|
+
desc_fr: "LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce",
|
75
|
+
atc_code: "N03AX14",
|
76
|
+
last_change: "2017-12-08 00:00:00 +0000",
|
77
|
+
company_name: "Desitin Pharma GmbH",
|
78
|
+
company_ean: "7601001320451"}
|
79
79
|
expect(item_found).to eq(expected)
|
80
80
|
end
|
81
|
-
|
82
|
-
context
|
81
|
+
end
|
82
|
+
context "should handle nonpharma articles" do
|
83
83
|
subject do
|
84
84
|
@downloader = Oddb2xml::RefdataDownloader.new({}, :nonpharma)
|
85
85
|
xml = @downloader.download
|
@@ -88,19 +88,19 @@ describe Oddb2xml::RefdataExtractor do
|
|
88
88
|
|
89
89
|
it "should have correct info for nonpharma with pharmacode 0058502 correctly" do
|
90
90
|
@non_pharma_items = subject.to_hash
|
91
|
-
item_found = @non_pharma_items.values.find{ |x| x[:ean13].eql?(
|
91
|
+
item_found = @non_pharma_items.values.find { |x| x[:ean13].eql?("7611600441020") }
|
92
92
|
expect(item_found).not_to be nil
|
93
|
-
expected = {:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
93
|
+
expected = {refdata: true,
|
94
|
+
_type: :nonpharma,
|
95
|
+
ean13: "7611600441020",
|
96
|
+
no8: nil,
|
97
|
+
last_change: LAST_CHANGE_2,
|
98
|
+
data_origin: "refdata",
|
99
|
+
desc_de: "TUBEGAZE Verband weiss Nr 12 20m Finger gross",
|
100
|
+
desc_fr: "TUBEGAZE pans tubul blanc Nr 12 20m doigts grands",
|
101
|
+
atc_code: "",
|
102
|
+
company_name: "IVF HARTMANN AG",
|
103
|
+
company_ean: "7601001000896"}
|
104
104
|
expect(item_found).to eq(expected)
|
105
105
|
end
|
106
106
|
end
|
@@ -109,20 +109,20 @@ end
|
|
109
109
|
describe Oddb2xml::BagXmlExtractor do
|
110
110
|
before(:all) { common_before }
|
111
111
|
after(:all) { common_after }
|
112
|
-
context
|
112
|
+
context "should handle articles with and without pharmacode" do
|
113
113
|
subject do
|
114
|
-
dat = File.read(File.join(Oddb2xml::SpecData,
|
114
|
+
dat = File.read(File.join(Oddb2xml::SpecData, "Preparations.xml"))
|
115
115
|
Oddb2xml::BagXmlExtractor.new(dat).to_hash
|
116
116
|
end
|
117
117
|
it "should handle pub_price for 3TC correctly" do
|
118
118
|
@items = subject.to_hash
|
119
119
|
with_pharma = @items[Oddb2xml::THREE_TC_GTIN]
|
120
120
|
expect(with_pharma).not_to be_nil
|
121
|
-
expect(with_pharma[:name_de]).to eq
|
121
|
+
expect(with_pharma[:name_de]).to eq "3TC"
|
122
122
|
expect(with_pharma[:atc_code]).not_to be_nil
|
123
123
|
expect(with_pharma[:packages].size).to eq(1)
|
124
124
|
expect(with_pharma[:packages].first[0]).to eq(Oddb2xml::THREE_TC_GTIN)
|
125
|
-
expect(with_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq(
|
125
|
+
expect(with_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq("205.3")
|
126
126
|
end
|
127
127
|
it "should handle pub_price for #{Oddb2xml::LEVETIRACETAM_GTIN} correctly" do
|
128
128
|
@items = subject.to_hash
|
@@ -132,7 +132,7 @@ describe Oddb2xml::BagXmlExtractor do
|
|
132
132
|
expect(no_pharma[:pharmacodes]).not_to be_nil
|
133
133
|
expect(no_pharma[:packages].size).to eq(1)
|
134
134
|
expect(no_pharma[:packages].first[0]).to eq(Oddb2xml::LEVETIRACETAM_GTIN)
|
135
|
-
expect(no_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq(
|
135
|
+
expect(no_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq("27.8")
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -144,83 +144,86 @@ describe Oddb2xml::SwissmedicInfoExtractor do
|
|
144
144
|
before(:each) do
|
145
145
|
@downloader = Oddb2xml::SwissmedicInfoDownloader.new
|
146
146
|
end
|
147
|
-
context
|
147
|
+
context "builds fachfinfo" do
|
148
148
|
it {
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
}
|
157
|
-
expect(levetiracetam[:owner]).to eq('Desitin Pharma GmbH')
|
158
|
-
expect(levetiracetam[:paragraph].to_s).to match(/Packungen/)
|
159
|
-
expect(levetiracetam[:paragraph].to_s).to match(/Zulassungsinhaberin/)
|
149
|
+
xml = @downloader.download
|
150
|
+
@infos = Oddb2xml::SwissmedicInfoExtractor.new(xml).to_hash
|
151
|
+
expect(@infos.keys).to eq ["de"]
|
152
|
+
expect(@infos["de"].size).to eq 2
|
153
|
+
levetiracetam = nil
|
154
|
+
@infos["de"].each { |info|
|
155
|
+
levetiracetam = info if /Levetiracetam/.match?(info[:name])
|
160
156
|
}
|
157
|
+
expect(levetiracetam[:owner]).to eq("Desitin Pharma GmbH")
|
158
|
+
expect(levetiracetam[:paragraph].to_s).to match(/Packungen/)
|
159
|
+
expect(levetiracetam[:paragraph].to_s).to match(/Zulassungsinhaberin/)
|
160
|
+
}
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
164
|
describe Oddb2xml::SwissmedicExtractor do
|
165
|
-
before(:all)
|
165
|
+
before(:all) do
|
166
|
+
common_before
|
167
|
+
cleanup_directories_before_run
|
168
|
+
end
|
166
169
|
after(:all) { common_after }
|
167
|
-
context
|
170
|
+
context "when transfer.dat is empty" do
|
168
171
|
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
|
169
172
|
it { expect(subject.to_hash).to be_empty }
|
170
173
|
end
|
171
|
-
context
|
174
|
+
context "can parse swissmedic_package.xlsx" do
|
172
175
|
before(:all) do
|
173
|
-
|
174
|
-
|
176
|
+
@filename = File.join(Oddb2xml::SpecData, "swissmedic_package.xlsx")
|
177
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :package).to_hash
|
175
178
|
end
|
176
179
|
|
177
180
|
def get_pack_by_ean13(ean13)
|
178
|
-
@packs.find{|pack| pack[1][:ean13] == ean13.to_s }[1]
|
181
|
+
@packs.find { |pack| pack[1][:ean13] == ean13.to_s }[1]
|
179
182
|
end
|
180
|
-
it
|
183
|
+
it "should have correct nr of packages" do
|
181
184
|
expect(@packs.size).to eq(41)
|
182
185
|
end
|
183
186
|
|
184
|
-
it
|
187
|
+
it "should have serocytol" do
|
185
188
|
serocytol = get_pack_by_ean13(7680620690084)
|
186
|
-
expect(serocytol[:atc_code]).to eq(
|
187
|
-
expect(serocytol[:swissmedic_category]).to eq(
|
188
|
-
expect(serocytol[:package_size]).to eq(
|
189
|
-
expect(serocytol[:einheit_swissmedic]).to eq(
|
190
|
-
expect(serocytol[:substance_swissmedic]).to eq(
|
189
|
+
expect(serocytol[:atc_code]).to eq("N03AX14")
|
190
|
+
expect(serocytol[:swissmedic_category]).to eq("B")
|
191
|
+
expect(serocytol[:package_size]).to eq("30")
|
192
|
+
expect(serocytol[:einheit_swissmedic]).to eq("Tablette(n)")
|
193
|
+
expect(serocytol[:substance_swissmedic]).to eq("levetiracetamum")
|
191
194
|
end
|
192
195
|
|
193
|
-
it
|
196
|
+
it "should have a correct insulin (gentechnik)" do
|
194
197
|
humalog = get_pack_by_ean13(7680532900196)
|
195
|
-
expect(humalog[:atc_code]).to eq(
|
196
|
-
expect(humalog[:swissmedic_category]).to eq(
|
197
|
-
expect(humalog[:package_size]).to eq(
|
198
|
-
expect(humalog[:einheit_swissmedic]).to eq(
|
199
|
-
expect(humalog[:substance_swissmedic]).to eq(
|
200
|
-
expect(humalog[:gen_production]).to eq(
|
201
|
-
expect(humalog[:insulin_category]).to eq(
|
202
|
-
expect(humalog[:drug_index]).to eq(
|
198
|
+
expect(humalog[:atc_code]).to eq("A10AB04")
|
199
|
+
expect(humalog[:swissmedic_category]).to eq("B")
|
200
|
+
expect(humalog[:package_size]).to eq("1 x 10 ml")
|
201
|
+
expect(humalog[:einheit_swissmedic]).to eq("Flasche(n)")
|
202
|
+
expect(humalog[:substance_swissmedic]).to eq("insulinum lisprum")
|
203
|
+
expect(humalog[:gen_production]).to eq("X")
|
204
|
+
expect(humalog[:insulin_category]).to eq("Insulinanalog: schnell wirkend")
|
205
|
+
expect(humalog[:drug_index]).to eq("")
|
203
206
|
end
|
204
207
|
|
205
|
-
it
|
208
|
+
it "should have a correct drug information" do
|
206
209
|
humalog = get_pack_by_ean13(7680555610041)
|
207
|
-
expect(humalog[:atc_code]).to eq(
|
208
|
-
expect(humalog[:swissmedic_category]).to eq(
|
209
|
-
expect(humalog[:sequence_name]).to eq(
|
210
|
-
expect(humalog[:gen_production]).to eq(
|
211
|
-
expect(humalog[:insulin_category]).to eq(
|
212
|
-
expect(humalog[:drug_index]).to eq(
|
210
|
+
expect(humalog[:atc_code]).to eq("N07BC06")
|
211
|
+
expect(humalog[:swissmedic_category]).to eq("A")
|
212
|
+
expect(humalog[:sequence_name]).to eq("Diaphin 10 g i.v., Injektionspräparat")
|
213
|
+
expect(humalog[:gen_production]).to eq("")
|
214
|
+
expect(humalog[:insulin_category]).to eq("")
|
215
|
+
expect(humalog[:drug_index]).to eq("d")
|
213
216
|
end
|
214
217
|
end
|
215
218
|
|
216
|
-
context
|
219
|
+
context "can parse swissmedic_orphans.xls" do
|
217
220
|
it do
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
221
|
+
@filename = File.join(Oddb2xml::SpecData, "swissmedic_orphan.xlsx")
|
222
|
+
expect(File.exist?(@filename)).to eq(true), "File #{@filename} must exists"
|
223
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :orphan).to_arry
|
224
|
+
expect(@packs.size).to eq 96
|
225
|
+
expect(@packs.first).to eq("62132")
|
226
|
+
expect(@packs[7]).to eq("00687")
|
224
227
|
end
|
225
228
|
end
|
226
229
|
end
|
@@ -228,13 +231,13 @@ end
|
|
228
231
|
describe Oddb2xml::EphaExtractor do
|
229
232
|
before(:all) { common_before }
|
230
233
|
after(:all) { common_after }
|
231
|
-
context
|
234
|
+
context "can parse epha_interactions.csv" do
|
232
235
|
it {
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
236
|
+
filename = File.join(Oddb2xml::SpecData, "epha_interactions.csv")
|
237
|
+
string = IO.read(filename)
|
238
|
+
@actions = Oddb2xml::EphaExtractor.new(string).to_arry
|
239
|
+
expect(@actions.size).to eq(2)
|
240
|
+
}
|
238
241
|
end
|
239
242
|
end
|
240
243
|
|
@@ -247,27 +250,27 @@ end
|
|
247
250
|
describe Oddb2xml::ZurroseExtractor do
|
248
251
|
before(:all) { common_before }
|
249
252
|
after(:all) { common_after }
|
250
|
-
context
|
253
|
+
context "when transfer.dat is empty" do
|
251
254
|
subject { Oddb2xml::ZurroseExtractor.new("") }
|
252
255
|
it { expect(subject.to_hash).to be_empty }
|
253
256
|
end
|
254
|
-
context
|
257
|
+
context "when transfer.dat is nil" do
|
255
258
|
subject { Oddb2xml::ZurroseExtractor.new(nil) }
|
256
259
|
it { expect(subject.to_hash).to be_empty }
|
257
260
|
end
|
258
261
|
context 'it should work also when \n is the line ending' do
|
259
262
|
subject do
|
260
|
-
dat =
|
261
|
-
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
263
|
+
dat = <<~DAT
|
264
|
+
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
262
265
|
DAT
|
263
266
|
Oddb2xml::ZurroseExtractor.new(dat)
|
264
267
|
end
|
265
268
|
it { expect(subject.to_hash.size).to eq(1) }
|
266
269
|
end
|
267
|
-
context
|
270
|
+
context "when expected line is given" do
|
268
271
|
subject do
|
269
|
-
dat =
|
270
|
-
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
|
272
|
+
dat = <<~DAT
|
273
|
+
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
|
271
274
|
DAT
|
272
275
|
Oddb2xml::ZurroseExtractor.new(dat)
|
273
276
|
end
|
@@ -275,78 +278,87 @@ describe Oddb2xml::ZurroseExtractor do
|
|
275
278
|
it { expect(subject.to_hash.keys.first).to eq(Oddb2xml::FERRO_GRADUMET_GTIN) }
|
276
279
|
it { expect(subject.to_hash.values.first[:price]).to eq("8.95") }
|
277
280
|
end
|
278
|
-
context
|
281
|
+
context "when Estradiol Creme is given" do
|
279
282
|
subject do
|
280
|
-
dat =
|
281
|
-
1130921929OESTRADIOL Inj L�s 5 mg 10 Amp 1 ml 000940001630300B070820076802840708402\r\n
|
283
|
+
dat = <<~DAT
|
284
|
+
1130921929OESTRADIOL Inj L�s 5 mg 10 Amp 1 ml 000940001630300B070820076802840708402\r\n
|
282
285
|
DAT
|
283
286
|
Oddb2xml::ZurroseExtractor.new(dat)
|
284
287
|
end
|
285
288
|
it { expect(subject.to_hash.keys.length).to eq(1) }
|
286
|
-
it { expect(subject.to_hash.keys.first).to eq(
|
289
|
+
it { expect(subject.to_hash.keys.first).to eq("7680284070840") }
|
287
290
|
it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
|
288
291
|
it { expect(subject.to_hash.values.first[:price]).to eq("9.40") }
|
289
292
|
it { expect(subject.to_hash.values.first[:pub_price]).to eq("16.30") }
|
290
|
-
it { expect(subject.to_hash.values.first[:pharmacode]).to eq(
|
293
|
+
it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0921929") }
|
291
294
|
end
|
292
|
-
context
|
295
|
+
context "when SELSUN Shampoo is given" do
|
293
296
|
subject do
|
294
|
-
dat =
|
295
|
-
1120020652SELSUN Shampoo Susp 120 ml 001576002430300D100400076801723306812\r\n
|
297
|
+
dat = <<~DAT
|
298
|
+
1120020652SELSUN Shampoo Susp 120 ml 001576002430300D100400076801723306812\r\n
|
296
299
|
DAT
|
297
300
|
Oddb2xml::ZurroseExtractor.new(dat)
|
298
301
|
end
|
299
302
|
it { expect(subject.to_hash.keys.length).to eq(1) }
|
300
|
-
it { expect(subject.to_hash.keys.first).to eq(
|
303
|
+
it { expect(subject.to_hash.keys.first).to eq("7680172330681") }
|
301
304
|
it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
|
302
305
|
it { expect(subject.to_hash.values.first[:price]).to eq("15.76") }
|
303
306
|
it { expect(subject.to_hash.values.first[:pub_price]).to eq("24.30") }
|
304
|
-
it { expect(subject.to_hash.values.first[:pharmacode]).to eq(
|
305
|
-
it
|
307
|
+
it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0020652") }
|
308
|
+
it "should set the correct SALECD cmut code" do
|
309
|
+
expect(subject.to_hash.values.first[:cmut]).to eq("2")
|
310
|
+
end
|
306
311
|
end
|
307
|
-
context
|
312
|
+
context "when SOFRADEX is given" do
|
308
313
|
subject do
|
309
|
-
dat =
|
310
|
-
1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572\r\n
|
314
|
+
dat = <<~DAT
|
315
|
+
1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572\r\n
|
311
316
|
DAT
|
312
317
|
Oddb2xml::ZurroseExtractor.new(dat)
|
313
318
|
end
|
314
|
-
#it { expect(subject.to_hash.keys.first).to eq("7680316950157") }
|
315
|
-
it "should set the correct SALECD cmut code" do
|
316
|
-
|
319
|
+
# it { expect(subject.to_hash.keys.first).to eq("7680316950157") }
|
320
|
+
it "should set the correct SALECD cmut code" do
|
321
|
+
expect(subject.to_hash.values.first[:cmut]).to eq("3")
|
322
|
+
end
|
323
|
+
it "should set the correct SALECD description" do
|
324
|
+
expect(subject.to_hash.values.first[:description]).to eq("SOFRADEX Gtt Auric 8 ml")
|
325
|
+
end
|
317
326
|
end
|
318
|
-
context
|
327
|
+
context "when Ethacridin is given" do
|
319
328
|
subject do
|
320
|
-
dat =
|
321
|
-
1128807890Ethacridin lactat 1\069 100ml 0009290013701000000000000000000000002\r\n
|
329
|
+
dat = <<~DAT
|
330
|
+
1128807890Ethacridin lactat 1\069 100ml 0009290013701000000000000000000000002\r\n
|
322
331
|
DAT
|
323
332
|
Oddb2xml::ZurroseExtractor.new(dat, true)
|
324
333
|
end
|
325
|
-
it { expect(subject.to_hash.keys.first).to eq(
|
326
|
-
it "should set the correct SALECD cmut code" do
|
327
|
-
|
334
|
+
it { expect(subject.to_hash.keys.first).to eq("9999998807890") }
|
335
|
+
it "should set the correct SALECD cmut code" do
|
336
|
+
expect(subject.to_hash.values.first[:cmut]).to eq("2")
|
337
|
+
end
|
338
|
+
it "should set the correct SALECD description" do
|
339
|
+
expect(subject.to_hash.values.first[:description]).to match(/Ethacridin lactat 1.+ 100ml/)
|
340
|
+
end
|
328
341
|
end
|
329
|
-
context
|
342
|
+
context "when parsing examples" do
|
330
343
|
subject do
|
331
|
-
filename = File.expand_path(File.join(__FILE__,
|
344
|
+
filename = File.expand_path(File.join(__FILE__, "..", "data", "transfer.dat"))
|
332
345
|
Oddb2xml::ZurroseExtractor.new(filename, true)
|
333
346
|
end
|
334
347
|
|
335
348
|
it "should extract EPIMINERAL" do
|
336
|
-
|
337
|
-
|
349
|
+
ethacridin = subject.to_hash.values.find { |x| /EPIMINERAL/i.match(x[:description]) }
|
350
|
+
expect(ethacridin[:description]).to eq("EPIMINERAL Paste 20 g")
|
338
351
|
end
|
339
352
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
353
|
+
{"SEMPER Cookie" => "SEMPER Cookie-O's Biskuit glutenfrei 150 g",
|
354
|
+
"DermaSilk" => "DermaSilk Set Body + Strumpfhöschen 24-36 Mon (98)",
|
355
|
+
"after sting Roll-on" => "CER'8 after sting Roll-on 20 ml",
|
356
|
+
"Inkosport" => "Inkosport Activ Pro 80 Himbeer - Joghurt Ds 750g"}
|
357
|
+
.each { |key, value|
|
358
|
+
it "should set the correct #{key} description" do
|
359
|
+
item = subject.to_hash.values.find { |x| /#{key}/i.match(x[:description]) }
|
360
|
+
expect(item[:description]).to eq(value)
|
361
|
+
end
|
362
|
+
}
|
351
363
|
end
|
352
364
|
end
|