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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.standard.yml +2 -0
  4. data/Gemfile +3 -3
  5. data/History.txt +8 -0
  6. data/README.md +1 -1
  7. data/Rakefile +24 -23
  8. data/bin/check_artikelstamm +11 -11
  9. data/bin/compare_v5 +23 -23
  10. data/bin/oddb2xml +14 -13
  11. data/lib/oddb2xml.rb +1 -1
  12. data/lib/oddb2xml/builder.rb +1070 -1038
  13. data/lib/oddb2xml/calc.rb +232 -233
  14. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  15. data/lib/oddb2xml/cli.rb +252 -236
  16. data/lib/oddb2xml/compare.rb +70 -59
  17. data/lib/oddb2xml/compositions_syntax.rb +448 -430
  18. data/lib/oddb2xml/compressor.rb +20 -20
  19. data/lib/oddb2xml/downloader.rb +153 -127
  20. data/lib/oddb2xml/extractor.rb +302 -289
  21. data/lib/oddb2xml/options.rb +34 -35
  22. data/lib/oddb2xml/parslet_compositions.rb +263 -269
  23. data/lib/oddb2xml/semantic_check.rb +39 -33
  24. data/lib/oddb2xml/util.rb +163 -163
  25. data/lib/oddb2xml/version.rb +1 -1
  26. data/lib/oddb2xml/xml_definitions.rb +32 -33
  27. data/oddb2xml.gemspec +31 -32
  28. data/spec/artikelstamm_spec.rb +111 -110
  29. data/spec/builder_spec.rb +489 -505
  30. data/spec/calc_spec.rb +552 -593
  31. data/spec/check_artikelstamm_spec.rb +26 -26
  32. data/spec/cli_spec.rb +173 -174
  33. data/spec/compare_spec.rb +9 -11
  34. data/spec/composition_syntax_spec.rb +390 -409
  35. data/spec/compressor_spec.rb +48 -48
  36. data/spec/data/transfer.dat +1 -0
  37. data/spec/data_helper.rb +47 -49
  38. data/spec/downloader_spec.rb +247 -260
  39. data/spec/extractor_spec.rb +171 -159
  40. data/spec/galenic_spec.rb +233 -256
  41. data/spec/options_spec.rb +116 -119
  42. data/spec/parslet_spec.rb +833 -861
  43. data/spec/spec_helper.rb +154 -153
  44. data/test_options.rb +39 -42
  45. data/tools/win_fetch_cacerts.rb +2 -3
  46. metadata +19 -3
@@ -1,20 +1,20 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
1
+ require "spec_helper"
4
2
  require "#{Dir.pwd}/lib/oddb2xml/downloader"
5
- ENV['TZ'] = 'UTC' # needed for last_change
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
- @savedDir = Dir.pwd
10
- FileUtils.makedirs(Oddb2xml::WorkDir)
11
- Dir.chdir(Oddb2xml::WorkDir)
12
- VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
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(@savedDir) if @savedDir and File.directory?(@savedDir)
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
- describe Oddb2xml::MigelExtractor do
34
- before(:all) {
35
- common_before
36
- @downloader = Oddb2xml::MigelDownloader.new
37
- xml = @downloader.download
38
- @items = Oddb2xml::MigelExtractor.new(xml).to_hash
39
- }
40
- after(:all) { common_after }
41
- it "should have at some items" do
42
- expect(@items.size).not_to eq 0
43
- expect(@items.find{|k,v| 3248410 == v[:pharmacode] }).not_to be_nil
44
- expect(@items.find{|k,v| /Novopen/i.match(v[:desc_de]) }).not_to be_nil
45
- expect(@items.find{|k,v| 3036984 == v[:pharmacode] }).not_to be_nil
46
- # Epimineral without pharmacode nor GTIN should not appear
47
- expect(@items.find{|k,v| /Epimineral/i.match(v[:desc_de]) }).to be_nil
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 unless SkipMigelDownloader
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 'should handle pharma articles' do
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, 'PHARMA').to_hash
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 = {:data_origin=>"refdata",
68
- :refdata=>true,
69
- :_type=>:pharma,
70
- :ean13=> Oddb2xml::LEVETIRACETAM_GTIN.to_s,
71
- :no8 => "62069008",
72
- :data_origin => "refdata",
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"}
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
- end
82
- context 'should handle nonpharma articles' do
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?('7611600441020')}
91
+ item_found = @non_pharma_items.values.find { |x| x[:ean13].eql?("7611600441020") }
92
92
  expect(item_found).not_to be nil
93
- expected = {:refdata=>true,
94
- :_type=>:nonpharma,
95
- :ean13=>'7611600441020',
96
- :no8 => nil,
97
- :last_change => Last_change,
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"}
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 'should handle articles with and without pharmacode' do
112
+ context "should handle articles with and without pharmacode" do
113
113
  subject do
114
- dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml'))
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 '3TC'
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('205.3')
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('27.8')
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 'builds fachfinfo' do
147
+ context "builds fachfinfo" do
148
148
  it {
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])
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) { common_before; cleanup_directories_before_run }
165
+ before(:all) do
166
+ common_before
167
+ cleanup_directories_before_run
168
+ end
166
169
  after(:all) { common_after }
167
- context 'when transfer.dat is empty' do
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 'can parse swissmedic_package.xlsx' do
174
+ context "can parse swissmedic_package.xlsx" do
172
175
  before(:all) do
173
- @filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
174
- @packs = Oddb2xml::SwissmedicExtractor.new(@filename, :package).to_hash
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 'should have correct nr of packages' do
183
+ it "should have correct nr of packages" do
181
184
  expect(@packs.size).to eq(41)
182
185
  end
183
186
 
184
- it 'should have serocytol' do
187
+ it "should have serocytol" do
185
188
  serocytol = get_pack_by_ean13(7680620690084)
186
- expect(serocytol[:atc_code]).to eq('N03AX14')
187
- expect(serocytol[:swissmedic_category]).to eq('B')
188
- expect(serocytol[:package_size]).to eq('30')
189
- expect(serocytol[:einheit_swissmedic]).to eq('Tablette(n)')
190
- expect(serocytol[:substance_swissmedic]).to eq('levetiracetamum')
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 'should have a correct insulin (gentechnik)' do
196
+ it "should have a correct insulin (gentechnik)" do
194
197
  humalog = get_pack_by_ean13(7680532900196)
195
- expect(humalog[:atc_code]).to eq('A10AB04')
196
- expect(humalog[:swissmedic_category]).to eq('B')
197
- expect(humalog[:package_size]).to eq('1 x 10 ml')
198
- expect(humalog[:einheit_swissmedic]).to eq('Flasche(n)')
199
- expect(humalog[:substance_swissmedic]).to eq('insulinum lisprum')
200
- expect(humalog[:gen_production]).to eq('X')
201
- expect(humalog[:insulin_category]).to eq('Insulinanalog: schnell wirkend')
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 'should have a correct drug information' do
208
+ it "should have a correct drug information" do
206
209
  humalog = get_pack_by_ean13(7680555610041)
207
- expect(humalog[:atc_code]).to eq('N07BC06')
208
- expect(humalog[:swissmedic_category]).to eq('A')
209
- expect(humalog[:sequence_name]).to eq('Diaphin 10 g i.v., Injektionspräparat')
210
- expect(humalog[:gen_production]).to eq('')
211
- expect(humalog[:insulin_category]).to eq('')
212
- expect(humalog[:drug_index]).to eq('d')
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 'can parse swissmedic_orphans.xls' do
219
+ context "can parse swissmedic_orphans.xls" do
217
220
  it do
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 96
222
- expect(@packs.first).to eq("62132")
223
- expect(@packs[7]).to eq("00687")
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 'can parse epha_interactions.csv' do
234
+ context "can parse epha_interactions.csv" do
232
235
  it {
233
- filename = File.join(Oddb2xml::SpecData, 'epha_interactions.csv')
234
- string = IO.read(filename)
235
- @actions = Oddb2xml::EphaExtractor.new(string).to_arry
236
- expect(@actions.size).to eq(2)
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 'when transfer.dat is empty' do
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 'when transfer.dat is nil' do
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 = <<-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 'when expected line is given' do
270
+ context "when expected line is given" do
268
271
  subject do
269
- dat = <<-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 'when Estradiol Creme is given' do
281
+ context "when Estradiol Creme is given" do
279
282
  subject do
280
- dat = <<-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('7680284070840') }
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('0921929') }
293
+ it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0921929") }
291
294
  end
292
- context 'when SELSUN Shampoo is given' do
295
+ context "when SELSUN Shampoo is given" do
293
296
  subject do
294
- dat = <<-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('7680172330681') }
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('0020652') }
305
- it 'should set the correct SALECD cmut code' do expect(subject.to_hash.values.first[:cmut]).to eq("2") end
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 'when SOFRADEX is given' do
312
+ context "when SOFRADEX is given" do
308
313
  subject do
309
- dat = <<-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 expect(subject.to_hash.values.first[:cmut]).to eq("3") end
316
- it "should set the correct SALECD description" do expect(subject.to_hash.values.first[:description]).to eq("SOFRADEX Gtt Auric 8 ml") end
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 'when Ethacridin is given' do
327
+ context "when Ethacridin is given" do
319
328
  subject do
320
- dat = <<-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('9999998807890') }
326
- it "should set the correct SALECD cmut code" do expect(subject.to_hash.values.first[:cmut]).to eq("2") end
327
- it "should set the correct SALECD description" do expect(subject.to_hash.values.first[:description]).to match(/Ethacridin lactat 1.+ 100ml/) end
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 'when parsing examples' do
342
+ context "when parsing examples" do
330
343
  subject do
331
- filename = File.expand_path(File.join(__FILE__, '..', 'data', 'transfer.dat'))
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
- ethacridin = subject.to_hash.values.find{ |x| /EPIMINERAL/i.match(x[:description])}
337
- expect(ethacridin[:description]).to eq("EPIMINERAL Paste 20 g")
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
- specials = { 'SEMPER Cookie' => "SEMPER Cookie-O's Biskuit glutenfrei 150 g",
341
- 'DermaSilk' => 'DermaSilk Set Body + Strumpfhöschen 24-36 Mon (98)',
342
- 'after sting Roll-on' => "CER'8 after sting Roll-on 20 ml",
343
- 'Inkosport' => 'Inkosport Activ Pro 80 Himbeer - Joghurt Ds 750g',}.
344
- each{ | key, value |
345
- it "should set the correct #{key} description" do
346
- item = subject.to_hash.values.find{ |x| /#{key}/i.match(x[:description])}
347
- expect(item[:description]).to eq(value)
348
- end
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