oddb2xml 2.6.8 → 2.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +40 -0
- data/.standard.yml +2 -0
- data/Elexis_Artikelstamm_v5.xsd +0 -3
- data/Gemfile +3 -3
- data/History.txt +29 -0
- data/README.md +3 -3
- 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 +1075 -1048
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -233
- 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 +154 -128
- data/lib/oddb2xml/extractor.rb +295 -302
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +263 -265
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +166 -164
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/oddb2xml.gemspec +31 -30
- data/spec/artikelstamm_spec.rb +116 -135
- data/spec/builder_spec.rb +495 -524
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +182 -157
- 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/refdata_NonPharma.xml +0 -3
- data/spec/data/refdata_Pharma.xml +0 -26
- data/spec/data/transfer.dat +1 -0
- data/spec/data/varia_De.htm +2 -2
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +247 -260
- data/spec/extractor_spec.rb +172 -164
- 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 +48 -4
- data/.travis.yml +0 -29
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,58 +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
|
-
it "should have correct info for
|
64
|
+
it "should have correct info for no8 62069008 correctly" do
|
64
65
|
@pharma_items = subject.to_hash
|
65
|
-
|
66
|
-
item_found = @pharma_items.values.find{ |x| x[:pharmacode].eql?(pharma_code_LEVETIRACETAM)}
|
66
|
+
item_found = @pharma_items.values.find { |x| x[:ean13].eql?(Oddb2xml::LEVETIRACETAM_GTIN) }
|
67
67
|
expect(item_found).not_to be nil
|
68
|
-
expected = {:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
:company_name=>"Desitin Pharma GmbH",
|
80
|
-
: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"}
|
81
79
|
expect(item_found).to eq(expected)
|
82
80
|
end
|
83
|
-
|
84
|
-
context
|
81
|
+
end
|
82
|
+
context "should handle nonpharma articles" do
|
85
83
|
subject do
|
86
84
|
@downloader = Oddb2xml::RefdataDownloader.new({}, :nonpharma)
|
87
85
|
xml = @downloader.download
|
@@ -90,21 +88,19 @@ describe Oddb2xml::RefdataExtractor do
|
|
90
88
|
|
91
89
|
it "should have correct info for nonpharma with pharmacode 0058502 correctly" do
|
92
90
|
@non_pharma_items = subject.to_hash
|
93
|
-
|
94
|
-
item_found = @non_pharma_items.values.find{ |x| x[:pharmacode].eql?(pharma_code_TUBEGAZE)}
|
91
|
+
item_found = @non_pharma_items.values.find { |x| x[:ean13].eql?("7611600441020") }
|
95
92
|
expect(item_found).not_to be nil
|
96
|
-
expected = {:
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
:company_ean=>"7601001000896"}
|
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"}
|
108
104
|
expect(item_found).to eq(expected)
|
109
105
|
end
|
110
106
|
end
|
@@ -113,20 +109,20 @@ end
|
|
113
109
|
describe Oddb2xml::BagXmlExtractor do
|
114
110
|
before(:all) { common_before }
|
115
111
|
after(:all) { common_after }
|
116
|
-
context
|
112
|
+
context "should handle articles with and without pharmacode" do
|
117
113
|
subject do
|
118
|
-
dat = File.read(File.join(Oddb2xml::SpecData,
|
114
|
+
dat = File.read(File.join(Oddb2xml::SpecData, "Preparations.xml"))
|
119
115
|
Oddb2xml::BagXmlExtractor.new(dat).to_hash
|
120
116
|
end
|
121
117
|
it "should handle pub_price for 3TC correctly" do
|
122
118
|
@items = subject.to_hash
|
123
119
|
with_pharma = @items[Oddb2xml::THREE_TC_GTIN]
|
124
120
|
expect(with_pharma).not_to be_nil
|
125
|
-
expect(with_pharma[:name_de]).to eq
|
121
|
+
expect(with_pharma[:name_de]).to eq "3TC"
|
126
122
|
expect(with_pharma[:atc_code]).not_to be_nil
|
127
123
|
expect(with_pharma[:packages].size).to eq(1)
|
128
124
|
expect(with_pharma[:packages].first[0]).to eq(Oddb2xml::THREE_TC_GTIN)
|
129
|
-
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")
|
130
126
|
end
|
131
127
|
it "should handle pub_price for #{Oddb2xml::LEVETIRACETAM_GTIN} correctly" do
|
132
128
|
@items = subject.to_hash
|
@@ -136,7 +132,7 @@ describe Oddb2xml::BagXmlExtractor do
|
|
136
132
|
expect(no_pharma[:pharmacodes]).not_to be_nil
|
137
133
|
expect(no_pharma[:packages].size).to eq(1)
|
138
134
|
expect(no_pharma[:packages].first[0]).to eq(Oddb2xml::LEVETIRACETAM_GTIN)
|
139
|
-
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")
|
140
136
|
end
|
141
137
|
end
|
142
138
|
end
|
@@ -148,83 +144,86 @@ describe Oddb2xml::SwissmedicInfoExtractor do
|
|
148
144
|
before(:each) do
|
149
145
|
@downloader = Oddb2xml::SwissmedicInfoDownloader.new
|
150
146
|
end
|
151
|
-
context
|
147
|
+
context "builds fachfinfo" do
|
152
148
|
it {
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
}
|
161
|
-
expect(levetiracetam[:owner]).to eq('Desitin Pharma GmbH')
|
162
|
-
expect(levetiracetam[:paragraph].to_s).to match(/Packungen/)
|
163
|
-
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])
|
164
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
|
+
}
|
165
161
|
end
|
166
162
|
end
|
167
163
|
|
168
164
|
describe Oddb2xml::SwissmedicExtractor do
|
169
|
-
before(:all)
|
165
|
+
before(:all) do
|
166
|
+
common_before
|
167
|
+
cleanup_directories_before_run
|
168
|
+
end
|
170
169
|
after(:all) { common_after }
|
171
|
-
context
|
170
|
+
context "when transfer.dat is empty" do
|
172
171
|
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
|
173
172
|
it { expect(subject.to_hash).to be_empty }
|
174
173
|
end
|
175
|
-
context
|
174
|
+
context "can parse swissmedic_package.xlsx" do
|
176
175
|
before(:all) do
|
177
|
-
|
178
|
-
|
176
|
+
@filename = File.join(Oddb2xml::SpecData, "swissmedic_package.xlsx")
|
177
|
+
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :package).to_hash
|
179
178
|
end
|
180
179
|
|
181
180
|
def get_pack_by_ean13(ean13)
|
182
|
-
@packs.find{|pack| pack[1][:ean13] == ean13.to_s }[1]
|
181
|
+
@packs.find { |pack| pack[1][:ean13] == ean13.to_s }[1]
|
183
182
|
end
|
184
|
-
it
|
183
|
+
it "should have correct nr of packages" do
|
185
184
|
expect(@packs.size).to eq(41)
|
186
185
|
end
|
187
186
|
|
188
|
-
it
|
187
|
+
it "should have serocytol" do
|
189
188
|
serocytol = get_pack_by_ean13(7680620690084)
|
190
|
-
expect(serocytol[:atc_code]).to eq(
|
191
|
-
expect(serocytol[:swissmedic_category]).to eq(
|
192
|
-
expect(serocytol[:package_size]).to eq(
|
193
|
-
expect(serocytol[:einheit_swissmedic]).to eq(
|
194
|
-
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")
|
195
194
|
end
|
196
195
|
|
197
|
-
it
|
196
|
+
it "should have a correct insulin (gentechnik)" do
|
198
197
|
humalog = get_pack_by_ean13(7680532900196)
|
199
|
-
expect(humalog[:atc_code]).to eq(
|
200
|
-
expect(humalog[:swissmedic_category]).to eq(
|
201
|
-
expect(humalog[:package_size]).to eq(
|
202
|
-
expect(humalog[:einheit_swissmedic]).to eq(
|
203
|
-
expect(humalog[:substance_swissmedic]).to eq(
|
204
|
-
expect(humalog[:gen_production]).to eq(
|
205
|
-
expect(humalog[:insulin_category]).to eq(
|
206
|
-
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("")
|
207
206
|
end
|
208
207
|
|
209
|
-
it
|
208
|
+
it "should have a correct drug information" do
|
210
209
|
humalog = get_pack_by_ean13(7680555610041)
|
211
|
-
expect(humalog[:atc_code]).to eq(
|
212
|
-
expect(humalog[:swissmedic_category]).to eq(
|
213
|
-
expect(humalog[:sequence_name]).to eq(
|
214
|
-
expect(humalog[:gen_production]).to eq(
|
215
|
-
expect(humalog[:insulin_category]).to eq(
|
216
|
-
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")
|
217
216
|
end
|
218
217
|
end
|
219
218
|
|
220
|
-
context
|
219
|
+
context "can parse swissmedic_orphans.xls" do
|
221
220
|
it do
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
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")
|
228
227
|
end
|
229
228
|
end
|
230
229
|
end
|
@@ -232,13 +231,13 @@ end
|
|
232
231
|
describe Oddb2xml::EphaExtractor do
|
233
232
|
before(:all) { common_before }
|
234
233
|
after(:all) { common_after }
|
235
|
-
context
|
234
|
+
context "can parse epha_interactions.csv" do
|
236
235
|
it {
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
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
|
+
}
|
242
241
|
end
|
243
242
|
end
|
244
243
|
|
@@ -251,27 +250,27 @@ end
|
|
251
250
|
describe Oddb2xml::ZurroseExtractor do
|
252
251
|
before(:all) { common_before }
|
253
252
|
after(:all) { common_after }
|
254
|
-
context
|
253
|
+
context "when transfer.dat is empty" do
|
255
254
|
subject { Oddb2xml::ZurroseExtractor.new("") }
|
256
255
|
it { expect(subject.to_hash).to be_empty }
|
257
256
|
end
|
258
|
-
context
|
257
|
+
context "when transfer.dat is nil" do
|
259
258
|
subject { Oddb2xml::ZurroseExtractor.new(nil) }
|
260
259
|
it { expect(subject.to_hash).to be_empty }
|
261
260
|
end
|
262
261
|
context 'it should work also when \n is the line ending' do
|
263
262
|
subject do
|
264
|
-
dat =
|
265
|
-
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
263
|
+
dat = <<~DAT
|
264
|
+
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
|
266
265
|
DAT
|
267
266
|
Oddb2xml::ZurroseExtractor.new(dat)
|
268
267
|
end
|
269
268
|
it { expect(subject.to_hash.size).to eq(1) }
|
270
269
|
end
|
271
|
-
context
|
270
|
+
context "when expected line is given" do
|
272
271
|
subject do
|
273
|
-
dat =
|
274
|
-
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
|
272
|
+
dat = <<~DAT
|
273
|
+
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
|
275
274
|
DAT
|
276
275
|
Oddb2xml::ZurroseExtractor.new(dat)
|
277
276
|
end
|
@@ -279,78 +278,87 @@ describe Oddb2xml::ZurroseExtractor do
|
|
279
278
|
it { expect(subject.to_hash.keys.first).to eq(Oddb2xml::FERRO_GRADUMET_GTIN) }
|
280
279
|
it { expect(subject.to_hash.values.first[:price]).to eq("8.95") }
|
281
280
|
end
|
282
|
-
context
|
281
|
+
context "when Estradiol Creme is given" do
|
283
282
|
subject do
|
284
|
-
dat =
|
285
|
-
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
|
286
285
|
DAT
|
287
286
|
Oddb2xml::ZurroseExtractor.new(dat)
|
288
287
|
end
|
289
288
|
it { expect(subject.to_hash.keys.length).to eq(1) }
|
290
|
-
it { expect(subject.to_hash.keys.first).to eq(
|
289
|
+
it { expect(subject.to_hash.keys.first).to eq("7680284070840") }
|
291
290
|
it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
|
292
291
|
it { expect(subject.to_hash.values.first[:price]).to eq("9.40") }
|
293
292
|
it { expect(subject.to_hash.values.first[:pub_price]).to eq("16.30") }
|
294
|
-
it { expect(subject.to_hash.values.first[:pharmacode]).to eq(
|
293
|
+
it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0921929") }
|
295
294
|
end
|
296
|
-
context
|
295
|
+
context "when SELSUN Shampoo is given" do
|
297
296
|
subject do
|
298
|
-
dat =
|
299
|
-
1120020652SELSUN Shampoo Susp 120 ml 001576002430300D100400076801723306812\r\n
|
297
|
+
dat = <<~DAT
|
298
|
+
1120020652SELSUN Shampoo Susp 120 ml 001576002430300D100400076801723306812\r\n
|
300
299
|
DAT
|
301
300
|
Oddb2xml::ZurroseExtractor.new(dat)
|
302
301
|
end
|
303
302
|
it { expect(subject.to_hash.keys.length).to eq(1) }
|
304
|
-
it { expect(subject.to_hash.keys.first).to eq(
|
303
|
+
it { expect(subject.to_hash.keys.first).to eq("7680172330681") }
|
305
304
|
it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
|
306
305
|
it { expect(subject.to_hash.values.first[:price]).to eq("15.76") }
|
307
306
|
it { expect(subject.to_hash.values.first[:pub_price]).to eq("24.30") }
|
308
|
-
it { expect(subject.to_hash.values.first[:pharmacode]).to eq(
|
309
|
-
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
|
310
311
|
end
|
311
|
-
context
|
312
|
+
context "when SOFRADEX is given" do
|
312
313
|
subject do
|
313
|
-
dat =
|
314
|
-
1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572\r\n
|
314
|
+
dat = <<~DAT
|
315
|
+
1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572\r\n
|
315
316
|
DAT
|
316
317
|
Oddb2xml::ZurroseExtractor.new(dat)
|
317
318
|
end
|
318
|
-
#it { expect(subject.to_hash.keys.first).to eq("7680316950157") }
|
319
|
-
it "should set the correct SALECD cmut code" do
|
320
|
-
|
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
|
321
326
|
end
|
322
|
-
context
|
327
|
+
context "when Ethacridin is given" do
|
323
328
|
subject do
|
324
|
-
dat =
|
325
|
-
1128807890Ethacridin lactat 1\069 100ml 0009290013701000000000000000000000002\r\n
|
329
|
+
dat = <<~DAT
|
330
|
+
1128807890Ethacridin lactat 1\069 100ml 0009290013701000000000000000000000002\r\n
|
326
331
|
DAT
|
327
332
|
Oddb2xml::ZurroseExtractor.new(dat, true)
|
328
333
|
end
|
329
|
-
it { expect(subject.to_hash.keys.first).to eq(
|
330
|
-
it "should set the correct SALECD cmut code" do
|
331
|
-
|
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
|
332
341
|
end
|
333
|
-
context
|
342
|
+
context "when parsing examples" do
|
334
343
|
subject do
|
335
|
-
filename = File.expand_path(File.join(__FILE__,
|
344
|
+
filename = File.expand_path(File.join(__FILE__, "..", "data", "transfer.dat"))
|
336
345
|
Oddb2xml::ZurroseExtractor.new(filename, true)
|
337
346
|
end
|
338
347
|
|
339
348
|
it "should extract EPIMINERAL" do
|
340
|
-
|
341
|
-
|
349
|
+
ethacridin = subject.to_hash.values.find { |x| /EPIMINERAL/i.match(x[:description]) }
|
350
|
+
expect(ethacridin[:description]).to eq("EPIMINERAL Paste 20 g")
|
342
351
|
end
|
343
352
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
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
|
+
}
|
355
363
|
end
|
356
364
|
end
|