oddb2xml 2.6.7 → 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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +40 -0
  3. data/.standard.yml +2 -0
  4. data/Elexis_Artikelstamm_v5.xsd +0 -3
  5. data/Gemfile +3 -3
  6. data/History.txt +30 -0
  7. data/README.md +1 -1
  8. data/Rakefile +24 -23
  9. data/bin/check_artikelstamm +11 -11
  10. data/bin/compare_v5 +23 -23
  11. data/bin/oddb2xml +14 -13
  12. data/lib/oddb2xml.rb +1 -1
  13. data/lib/oddb2xml/builder.rb +1077 -1039
  14. data/lib/oddb2xml/calc.rb +232 -233
  15. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  16. data/lib/oddb2xml/cli.rb +252 -233
  17. data/lib/oddb2xml/compare.rb +70 -59
  18. data/lib/oddb2xml/compositions_syntax.rb +448 -430
  19. data/lib/oddb2xml/compressor.rb +20 -20
  20. data/lib/oddb2xml/downloader.rb +155 -129
  21. data/lib/oddb2xml/extractor.rb +302 -296
  22. data/lib/oddb2xml/options.rb +34 -35
  23. data/lib/oddb2xml/parslet_compositions.rb +263 -265
  24. data/lib/oddb2xml/semantic_check.rb +39 -33
  25. data/lib/oddb2xml/util.rb +169 -159
  26. data/lib/oddb2xml/version.rb +1 -1
  27. data/lib/oddb2xml/xml_definitions.rb +32 -33
  28. data/oddb2xml.gemspec +32 -30
  29. data/spec/artikelstamm_spec.rb +139 -132
  30. data/spec/builder_spec.rb +495 -524
  31. data/spec/calc_spec.rb +552 -593
  32. data/spec/check_artikelstamm_spec.rb +26 -26
  33. data/spec/cli_spec.rb +182 -157
  34. data/spec/compare_spec.rb +9 -11
  35. data/spec/composition_syntax_spec.rb +390 -409
  36. data/spec/compressor_spec.rb +48 -48
  37. data/spec/data/Preparations.xml +139 -3
  38. data/spec/data/refdata_NonPharma.xml +0 -3
  39. data/spec/data/refdata_Pharma.xml +10 -25
  40. data/spec/data/swissmedic_package.xlsx +0 -0
  41. data/spec/data/transfer.dat +3 -1
  42. data/spec/data/varia_De.htm +2 -2
  43. data/spec/data_helper.rb +47 -49
  44. data/spec/downloader_spec.rb +247 -260
  45. data/spec/extractor_spec.rb +173 -165
  46. data/spec/galenic_spec.rb +233 -256
  47. data/spec/options_spec.rb +116 -119
  48. data/spec/parslet_spec.rb +833 -861
  49. data/spec/spec_helper.rb +154 -153
  50. data/test_options.rb +39 -42
  51. data/tools/win_fetch_cacerts.rb +2 -3
  52. metadata +49 -5
  53. data/.travis.yml +0 -30
@@ -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,58 +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
- it "should have correct info for pharmacode 1699947 correctly" do
64
+ it "should have correct info for no8 62069008 correctly" do
64
65
  @pharma_items = subject.to_hash
65
- pharma_code_LEVETIRACETAM = '5819012'
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 = {:data_origin=>"refdata",
69
- :refdata=>true,
70
- :_type=>:pharma,
71
- :ean13=> Oddb2xml::LEVETIRACETAM_GTIN.to_s,
72
- :no8 => "62069008",
73
- :pharmacode=> pharma_code_LEVETIRACETAM,
74
- :data_origin => "refdata",
75
- :desc_de=>"LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk",
76
- :desc_fr=>"LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce",
77
- :atc_code=>"N03AX14",
78
- :last_change => "2017-12-08 00:00:00 +0000",
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
- end
84
- context 'should handle nonpharma articles' do
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
- pharma_code_TUBEGAZE = '0058519'
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 = {:refdata=>true,
97
- :_type=>:nonpharma,
98
- :ean13=>'7611600441020',
99
- :no8 => nil,
100
- :pharmacode=>pharma_code_TUBEGAZE,
101
- :last_change => @@last_change,
102
- :data_origin => "refdata",
103
- :desc_de=>"TUBEGAZE Verband weiss Nr 12 20m Finger gross",
104
- :desc_fr=>"TUBEGAZE pans tubul blanc Nr 12 20m doigts grands",
105
- :atc_code=>"",
106
- :company_name=>"IVF HARTMANN AG",
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 'should handle articles with and without pharmacode' do
112
+ context "should handle articles with and without pharmacode" do
117
113
  subject do
118
- dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml'))
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 '3TC'
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('205.3')
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('27.8')
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 'builds fachfinfo' do
147
+ context "builds fachfinfo" do
152
148
  it {
153
- xml = @downloader.download
154
- @infos = Oddb2xml::SwissmedicInfoExtractor.new(xml).to_hash
155
- expect(@infos.keys).to eq ['de']
156
- expect(@infos['de'].size).to eq 2
157
- levetiracetam = nil
158
- @infos['de'].each{|info|
159
- levetiracetam = info if /Levetiracetam/.match(info[:name])
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) { common_before; cleanup_directories_before_run }
165
+ before(:all) do
166
+ common_before
167
+ cleanup_directories_before_run
168
+ end
170
169
  after(:all) { common_after }
171
- context 'when transfer.dat is empty' do
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 'can parse swissmedic_package.xlsx' do
174
+ context "can parse swissmedic_package.xlsx" do
176
175
  before(:all) do
177
- @filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
178
- @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
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 'should have correct nr of packages' do
185
- expect(@packs.size).to eq(40)
183
+ it "should have correct nr of packages" do
184
+ expect(@packs.size).to eq(41)
186
185
  end
187
186
 
188
- it 'should have serocytol' do
187
+ it "should have serocytol" do
189
188
  serocytol = get_pack_by_ean13(7680620690084)
190
- expect(serocytol[:atc_code]).to eq('N03AX14')
191
- expect(serocytol[:swissmedic_category]).to eq('B')
192
- expect(serocytol[:package_size]).to eq('30')
193
- expect(serocytol[:einheit_swissmedic]).to eq('Tablette(n)')
194
- 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")
195
194
  end
196
195
 
197
- it 'should have a correct insulin (gentechnik)' do
196
+ it "should have a correct insulin (gentechnik)" do
198
197
  humalog = get_pack_by_ean13(7680532900196)
199
- expect(humalog[:atc_code]).to eq('A10AB04')
200
- expect(humalog[:swissmedic_category]).to eq('B')
201
- expect(humalog[:package_size]).to eq('1 x 10 ml')
202
- expect(humalog[:einheit_swissmedic]).to eq('Flasche(n)')
203
- expect(humalog[:substance_swissmedic]).to eq('insulinum lisprum')
204
- expect(humalog[:gen_production]).to eq('X')
205
- expect(humalog[:insulin_category]).to eq('Insulinanalog: schnell wirkend')
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 'should have a correct drug information' do
208
+ it "should have a correct drug information" do
210
209
  humalog = get_pack_by_ean13(7680555610041)
211
- expect(humalog[:atc_code]).to eq('N07BC06')
212
- expect(humalog[:swissmedic_category]).to eq('A')
213
- expect(humalog[:sequence_name]).to eq('Diaphin 10 g i.v., Injektionspräparat')
214
- expect(humalog[:gen_production]).to eq('')
215
- expect(humalog[:insulin_category]).to eq('')
216
- 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")
217
216
  end
218
217
  end
219
218
 
220
- context 'can parse swissmedic_orphans.xls' do
219
+ context "can parse swissmedic_orphans.xls" do
221
220
  it do
222
- @filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
223
- expect(File.exists?(@filename)).to eq(true), "File #{@filename} must exists"
224
- @packs = Oddb2xml::SwissmedicExtractor.new(@filename, :orphan).to_arry
225
- expect(@packs.size).to eq 96
226
- expect(@packs.first).to eq("62132")
227
- 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")
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 'can parse epha_interactions.csv' do
234
+ context "can parse epha_interactions.csv" do
236
235
  it {
237
- filename = File.join(Oddb2xml::SpecData, 'epha_interactions.csv')
238
- string = IO.read(filename)
239
- @actions = Oddb2xml::EphaExtractor.new(string).to_arry
240
- expect(@actions.size).to eq(2)
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 'when transfer.dat is empty' do
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 'when transfer.dat is nil' do
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 = <<-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 'when expected line is given' do
270
+ context "when expected line is given" do
272
271
  subject do
273
- dat = <<-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 'when Estradiol Creme is given' do
281
+ context "when Estradiol Creme is given" do
283
282
  subject do
284
- dat = <<-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('7680284070840') }
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('0921929') }
293
+ it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0921929") }
295
294
  end
296
- context 'when SELSUN Shampoo is given' do
295
+ context "when SELSUN Shampoo is given" do
297
296
  subject do
298
- dat = <<-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('7680172330681') }
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('0020652') }
309
- 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
310
311
  end
311
- context 'when SOFRADEX is given' do
312
+ context "when SOFRADEX is given" do
312
313
  subject do
313
- dat = <<-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 expect(subject.to_hash.values.first[:cmut]).to eq("3") end
320
- 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
321
326
  end
322
- context 'when Ethacridin is given' do
327
+ context "when Ethacridin is given" do
323
328
  subject do
324
- dat = <<-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('9999998807890') }
330
- it "should set the correct SALECD cmut code" do expect(subject.to_hash.values.first[:cmut]).to eq("2") end
331
- 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
332
341
  end
333
- context 'when parsing examples' do
342
+ context "when parsing examples" do
334
343
  subject do
335
- filename = File.expand_path(File.join(__FILE__, '..', 'data', 'transfer.dat'))
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
- ethacridin = subject.to_hash.values.find{ |x| /EPIMINERAL/i.match(x[:description])}
341
- 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")
342
351
  end
343
352
 
344
- specials = { 'SEMPER Cookie' => "SEMPER Cookie-O's Biskuit glutenfrei 150 g",
345
- 'DermaSilk' => 'DermaSilk Set Body + Strumpfhöschen 24-36 Mon (98)',
346
- 'after sting Roll-on' => "CER'8 after sting Roll-on 20 ml",
347
- 'Inkosport' => 'Inkosport Activ Pro 80 Himbeer - Joghurt Ds 750g',}.
348
- each{ | key, value |
349
- it "should set the correct #{key} description" do
350
- item = subject.to_hash.values.find{ |x| /#{key}/i.match(x[:description])}
351
- expect(item[:description]).to eq(value)
352
- end
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