oddb2xml 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
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
data/spec/calc_spec.rb CHANGED
@@ -1,811 +1,770 @@
1
- # encoding: utf-8
2
-
3
- require 'pp'
4
- require 'spec_helper'
1
+ require "pp"
2
+ require "spec_helper"
5
3
  require "rexml/document"
6
- include REXML
7
- require "#{Dir.pwd}/lib/oddb2xml/calc"
8
- include Oddb2xml
4
+ require_relative "../lib/oddb2xml/calc"
5
+
6
+ # after each name you find the column of swissmedic_package.xlsx file
7
+ TestExample = Struct.new("TestExample", :test_description, :iksnr_a, :seqnr_b, :pack_K, :name_c, :package_size_L, :einheit_m, :active_substance_0, :composition_P,
8
+ :values_to_compare)
9
+ class TestExample
10
+ def url
11
+ "http://ch.oddb.org/de/gcc/drug/reg/#{sprintf("%05d" % iksnr_a)}/seq/#{sprintf("%02d" % seqnr_b)}/pack/#{sprintf("%03d" % pack_K)}"
12
+ end
13
+ end
14
+ Tst_nutriflex = TestExample.new("Nutriflex Lipid plus ohne Elektrolyte, Infusionsemulsion 1250ml",
15
+ 56089, 1, 1, "Nutriflex Lipid plus, Infusionsemulsion, 1250ml",
16
+ "5 x 1250", "ml",
17
+ "glucosum anhydricum, isoleucinum, leucinum, lysinum anhydricum, methioninum, phenylalaninum, threoninum, tryptophanum, valinum, argininum, histidinum, alaninum, acidum asparticum, acidum glutamicum, glycinum, prolinum, serinum, aminoacida, carbohydrata, materia crassa, sojae oleum, triglycerida saturata media",
18
+ "I) Glucoselösung: glucosum anhydricum 150 g ut glucosum monohydricum, acidum citricum anhydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.
19
+ II) Fettemulsion: sojae oleum 25 g, triglycerida saturata media 25 g, lecithinum ex ovo, glycerolum, natrii oleas, aqua q.s. ad emulsionem.
20
+ III) Aminosäurenlösung: isoleucinum 2.82 g, leucinum 3.76 g, lysinum anhydricum 2.73 g ut lysinum monohydricum, methioninum 2.35 g, phenylalaninum 4.21 g, threoninum 2.18 g, tryptophanum 0.68 g, valinum 3.12 g, argininum 3.24 g, histidinum 1.50 g, alaninum 5.82 g, acidum asparticum 1.80 g, acidum glutamicum 4.21 g, glycinum 1.98 g, prolinum 4.08 g, serinum 3.60 g, acidum citricum anhydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.
21
+ .
22
+ I) et II) et III) corresp.: aminoacida 48 g/l, carbohydrata 150 g/l, materia crassa 50 g/l, in emulsione recenter mixta 1250 ml.
23
+ Corresp. 5300 kJ.",
24
+ { # :selling_units => 5,
25
+ # :measure => 'Infusionsemulsion',
26
+ #:count => 25, :multi => 1
27
+ })
9
28
 
10
29
  describe Oddb2xml::Calc do
11
- before(:all) do VCR.eject_cassette; VCR.insert_cassette('oddb2xml') end
12
- after(:all) do VCR.eject_cassette end
30
+ before(:all) do
31
+ VCR.eject_cassette
32
+ VCR.insert_cassette("oddb2xml")
33
+ end
34
+ after(:all) { VCR.eject_cassette }
13
35
 
14
36
  after(:each) do
15
- FileUtils.rm(Dir.glob(File.join(Oddb2xml::WorkDir, '*.*')))
16
- FileUtils.rm(Dir.glob(File.join(Oddb2xml::WorkDir, 'downloads', '*')))
37
+ FileUtils.rm(Dir.glob(File.join(Oddb2xml::WORK_DIR, "*.*")))
38
+ FileUtils.rm(Dir.glob(File.join(Oddb2xml::WORK_DIR, "downloads", "*")))
17
39
  end
18
40
  before(:each) do
19
- FileUtils.rm(Dir.glob(File.join(Oddb2xml::WorkDir, '*.xml')))
20
- FileUtils.rm(Dir.glob(File.join(Oddb2xml::WorkDir, '*.csv')))
41
+ FileUtils.rm(Dir.glob(File.join(Oddb2xml::WORK_DIR, "*.xml")))
42
+ FileUtils.rm(Dir.glob(File.join(Oddb2xml::WORK_DIR, "*.csv")))
21
43
  # setup_epha_atc_csv_mock
22
44
  end
23
45
 
24
- Line_1 = 'I) Glucoselösung: glucosum anhydricum 150 g ut glucosum monohydricum, natrii dihydrogenophosphas dihydricus 2.34 g, zinci acetas dihydricus 6.58 mg, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.'
25
- Line_2 = 'II) Fettemulsion: sojae oleum 25 g, triglycerida saturata media 25 g, lecithinum ex ovo 3 g, glycerolum, natrii oleas, aqua q.s. ad emulsionem pro 250 ml.'
26
- Line_3 = 'III) Aminosäurenlösung: isoleucinum 2.34 g, leucinum 3.13 g, lysinum anhydricum 2.26 g ut lysini hydrochloridum, methioninum 1.96 g, aqua ad iniectabilia q.s. ad solutionem pro 400 ml.'
27
- Line_4 = 'I) et II) et III) corresp.: aminoacida 32 g/l, acetas 32 mmol/l, acidum citricum monohydricum, in emulsione recenter mixta 1250 ml.'
28
- Line_5 = 'Corresp. 4000 kJ.'
29
-
30
- # after each name you find the column of swissmedic_package.xlsx file
31
- TestExample = Struct.new("TestExample", :test_description, :iksnr_A, :seqnr_B, :pack_K, :name_C, :package_size_L, :einheit_M, :active_substance_0, :composition_P,
32
- :values_to_compare)
33
-
34
- tst_grains_de_valse = TestExample.new('Grains de Vals',
35
- 55491, 1, 1, "Grains de Vals, comprimés ",
36
- '20', 'Tablette(n)',
37
- 'sennae folii extractum methanolicum siccum',
38
- 'sennae folii extractum methanolicum siccum 78-104 mg corresp. sennosidum B 12.5 mg, DER: 18:1, excipiens pro compresso.',
39
- { :selling_units => 20,
40
- :measure => 'Tablette(n)',
41
- }
42
- )
43
- tst_cardio_pumal = TestExample.new('Cardio-Pulmo-Rénal Sérocytol',
44
- 274, 1, 1, "Cardio-Pulmo-Rénal Sérocytol, suppositoire",
45
- '3', 'Suppositorien',
46
- 'globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)',
47
- 'globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins) 8 mg, propylenglycolum, conserv.: E 216, E 218, excipiens pro suppositorio.',
48
- { :selling_units => 3,
49
- :measure => 'Suppositorien',
50
- # :count => 10, :multi => 1, :dose => ''
51
- }
52
- )
53
-
54
- tst_fluorglukose = TestExample.new('Fluorglukose',
55
- 51908, 2, 16, "2-Fluorglukose (18-F), Injektionslösung",
56
- '0,1 - 80', 'GBq',
57
- 'fludeoxyglucosum(18-F) zum Kalibrierungszeitpunkt',
58
- 'fludeoxyglucosum(18-F) zum Kalibrierungszeitpunkt 0.1-8 GBq, dinatrii phosphas dihydricus, natrii dihydrogenophosphas dihydricus, natrii chloridum, antiox.: natrii thiosulfas 1.3-1.9 mg, aqua ad iniectabilia q.s. ad solutionem pro 1 ml.',
59
- { :selling_units => 1,
60
- :measure => 'GBq',
61
- # :count => 10, :multi => 1, :dose => ''
62
- }
63
- )
64
- tst_bicaNova = TestExample.new('bicaNova',
65
- 58277, 1, 1, "bicaNova 1,5 % Glucose, Peritonealdialyselösung",
66
- '1500 ml', '',
67
- 'natrii chloridum, natrii hydrogenocarbonas, calcii chloridum dihydricum, magnesii chloridum hexahydricum, glucosum anhydricum, natrium, calcium, magnesium, chloridum, hydrogenocarbonas, glucosum',
68
- 'I) et II) corresp.: natrii chloridum 5.5 g, natrii hydrogenocarbonas 3.36 g, calcii chloridum dihydricum 184 mg, magnesii chloridum hexahydricum 102 mg, glucosum anhydricum 15 g ut glucosum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 1000 ml.',
69
- { :selling_units => 1500,
70
- :measure => 'ml',
71
- # :count => 10, :multi => 1, :dose => ''
72
- }
73
- )
74
- tst_kamillin = TestExample.new('Kamillin Medipharm, Bad',
75
- 43454, 1, 101, "Kamillin Medipharm, Bad",
76
- '25 x 40', 'ml',
77
- 'matricariae extractum isopropanolicum liquidum',
78
- 'haemagglutininum influenzae A (H1N1) (Virus-Stamm A/California/7/2009 (H1N1)-like: reassortant virus NYMC X-179A) 15 µg, haemagglutininum influenzae A (H3N2) (Virus-Stamm A/Texas/50/2012 (H3N2)-like: reassortant virus NYMC X-223A) 15 µg, haemagglutininum influenzae B (Virus-Stamm B/Massachusetts/2/2012-like: B/Massachusetts/2/2012) 15 µg, natrii chloridum, kalii chloridum, dinatrii phosphas dihydricus, kalii dihydrogenophosphas, residui: formaldehydum max. 100 µg, octoxinolum-9 max. 500 µg, ovalbuminum max. 0.05 µg, saccharum nihil, neomycinum nihil, aqua ad iniectabilia q.s. ad suspensionem pro 0.5 ml.',
79
- { :selling_units => 25,
80
- :measure => 'ml',
81
- # :count => 10, :multi => 1, :dose => ''
82
- }
83
- )
84
- tst_infloran = TestExample.new('Test Infloran, capsule',
85
- 679, 2, 12, "Infloran, capsule",
86
- '2x10', 'Kapsel(n)',
87
- 'lactobacillus acidophilus cryodesiccatus, bifidobacterium infantis',
88
- 'lactobacillus acidophilus cryodesiccatus min. 10^9 CFU, bifidobacterium infantis min. 10^9 CFU, color.: E 127, E 132, E 104, excipiens pro capsula.',
89
- { :selling_units => 20,
90
- :measure => 'Kapsel(n)',
91
- # :count => 10, :multi => 1, :dose => ''
92
- }
93
- )
94
- tst_mutagrip = TestExample.new('Test Mutagrip (Fertigspritzen)',
95
- 373, 23, 10, "Mutagrip, Suspension zur Injektion",
96
- '10 x 0.5 ml', 'Fertigspritze(n)',
97
- 'ropivacainum',
98
- 'ropivacaini hydrochloridum 2 mg, natrii chloridum, aqua ad iniectabilia q.s. ad solutionem pro 1 ml.',
99
- { :selling_units => 10,
100
- :measure => 'Fertigspritze(n)',
101
- # :count => 10, :multi => 1, :dose => ''
102
- }
103
- )
104
- Tst_nutriflex = TestExample.new('Nutriflex Lipid plus ohne Elektrolyte, Infusionsemulsion 1250ml',
105
- 56089, 1, 1, 'Nutriflex Lipid plus, Infusionsemulsion, 1250ml',
106
- '5 x 1250', 'ml',
107
- 'glucosum anhydricum, isoleucinum, leucinum, lysinum anhydricum, methioninum, phenylalaninum, threoninum, tryptophanum, valinum, argininum, histidinum, alaninum, acidum asparticum, acidum glutamicum, glycinum, prolinum, serinum, aminoacida, carbohydrata, materia crassa, sojae oleum, triglycerida saturata media',
108
- "I) Glucoselösung: glucosum anhydricum 150 g ut glucosum monohydricum, acidum citricum anhydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.
109
- II) Fettemulsion: sojae oleum 25 g, triglycerida saturata media 25 g, lecithinum ex ovo, glycerolum, natrii oleas, aqua q.s. ad emulsionem.
110
- III) Aminosäurenlösung: isoleucinum 2.82 g, leucinum 3.76 g, lysinum anhydricum 2.73 g ut lysinum monohydricum, methioninum 2.35 g, phenylalaninum 4.21 g, threoninum 2.18 g, tryptophanum 0.68 g, valinum 3.12 g, argininum 3.24 g, histidinum 1.50 g, alaninum 5.82 g, acidum asparticum 1.80 g, acidum glutamicum 4.21 g, glycinum 1.98 g, prolinum 4.08 g, serinum 3.60 g, acidum citricum anhydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.
111
- .
112
- I) et II) et III) corresp.: aminoacida 48 g/l, carbohydrata 150 g/l, materia crassa 50 g/l, in emulsione recenter mixta 1250 ml.
113
- Corresp. 5300 kJ.",
114
- { # :selling_units => 5,
115
- # :measure => 'Infusionsemulsion',
116
- #:count => 25, :multi => 1
117
- }
118
- )
119
- tst_diamox = TestExample.new('Diamox. Tabletten',
120
- 21191, 1, 19, 'Diamox, comprimés',
121
- '1 x 25', 'Tablette(n)',
122
- 'acetazolamidum',
123
- 'acetazolamidum 250 mg, excipiens pro compresso.',
124
- { :selling_units => 25,
125
- :measure => 'Tablette(n)',
126
- #:count => 25, :multi => 1
127
- }
128
- )
129
-
130
- Tst_naropin = TestExample.new('Das ist eine Injektionslösung von einer Packung mit 5 x 100 ml',
131
- 54015, 01, 100, "Naropin 0,2 %, Infusionslösung / Injektionslösung",
132
- '1 x 5 x 100', 'ml',
133
- 'ropivacainum',
134
- 'ropivacaini hydrochloridum 2 mg, natrii chloridum, aqua ad iniectabilia q.s. ad solutionem pro 1 ml.',
135
- { # :selling_units => 5, TODO:
136
- # :measure => 'ml',
137
- #:count => 5, :multi => 1
138
- }
139
- )
140
-
141
-
142
- context 'should parse Solvens:' do
143
- text = 'Solvens: conserv.: alcohol benzylicus 18 mg, aqua ad iniectabilia q.s. ad solutionem pro 2 ml.'
144
- info = Calc.new('Solu-Cortef 100 mg, Injektions-/Infusionspräparat', nil, nil,
145
- 'hydrocortisonum',
146
- text
147
- )
148
- specify { expect(info.compositions.first.substances.first.name).to eq "Alcohol Benzylicus" }
149
- specify { expect(info.compositions.first.substances.size).to eq 1 }
46
+ line_1 = "I) Glucoselösung: glucosum anhydricum 150 g ut glucosum monohydricum, natrii dihydrogenophosphas dihydricus 2.34 g, zinci acetas dihydricus 6.58 mg, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
47
+ line_2 = "II) Fettemulsion: sojae oleum 25 g, triglycerida saturata media 25 g, lecithinum ex ovo 3 g, glycerolum, natrii oleas, aqua q.s. ad emulsionem pro 250 ml."
48
+ # line_3 = "III) Aminosäurenlösung: isoleucinum 2.34 g, leucinum 3.13 g, lysinum anhydricum 2.26 g ut lysini hydrochloridum, methioninum 1.96 g, aqua ad iniectabilia q.s. ad solutionem pro 400 ml."
49
+ # line_4 = "I) et II) et III) corresp.: aminoacida 32 g/l, acetas 32 mmol/l, acidum citricum monohydricum, in emulsione recenter mixta 1250 ml."
50
+ # line_5 = "Corresp. 4000 kJ."
51
+
52
+ tst_grains_de_valse = TestExample.new("Grains de Vals",
53
+ 55491, 1, 1, "Grains de Vals, comprimés ",
54
+ "20", "Tablette(n)",
55
+ "sennae folii extractum methanolicum siccum",
56
+ "sennae folii extractum methanolicum siccum 78-104 mg corresp. sennosidum B 12.5 mg, DER: 18:1, excipiens pro compresso.",
57
+ {selling_units: 20,
58
+ measure: "Tablette(n)"})
59
+ tst_cardio_pumal = TestExample.new("Cardio-Pulmo-Rénal Sérocytol",
60
+ 274, 1, 1, "Cardio-Pulmo-Rénal Sérocytol, suppositoire",
61
+ "3", "Suppositorien",
62
+ "globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)",
63
+ "globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins) 8 mg, propylenglycolum, conserv.: E 216, E 218, excipiens pro suppositorio.",
64
+ {selling_units: 3,
65
+ measure: "Suppositorien"})
66
+
67
+ tst_fluorglukose = TestExample.new("Fluorglukose",
68
+ 51908, 2, 16, "2-Fluorglukose (18-F), Injektionslösung",
69
+ "0,1 - 80", "GBq",
70
+ "fludeoxyglucosum(18-F) zum Kalibrierungszeitpunkt",
71
+ "fludeoxyglucosum(18-F) zum Kalibrierungszeitpunkt 0.1-8 GBq, dinatrii phosphas dihydricus, natrii dihydrogenophosphas dihydricus, natrii chloridum, antiox.: natrii thiosulfas 1.3-1.9 mg, aqua ad iniectabilia q.s. ad solutionem pro 1 ml.",
72
+ {selling_units: 1,
73
+ measure: "GBq"})
74
+ tst_bica_nova = TestExample.new("bicaNova",
75
+ 58277, 1, 1, "bicaNova 1,5 % Glucose, Peritonealdialyselösung",
76
+ "1500 ml", "",
77
+ "natrii chloridum, natrii hydrogenocarbonas, calcii chloridum dihydricum, magnesii chloridum hexahydricum, glucosum anhydricum, natrium, calcium, magnesium, chloridum, hydrogenocarbonas, glucosum",
78
+ "I) et II) corresp.: natrii chloridum 5.5 g, natrii hydrogenocarbonas 3.36 g, calcii chloridum dihydricum 184 mg, magnesii chloridum hexahydricum 102 mg, glucosum anhydricum 15 g ut glucosum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 1000 ml.",
79
+ {selling_units: 1500,
80
+ measure: "ml"})
81
+ tst_kamillin = TestExample.new("Kamillin Medipharm, Bad",
82
+ 43454, 1, 101, "Kamillin Medipharm, Bad",
83
+ "25 x 40", "ml",
84
+ "matricariae extractum isopropanolicum liquidum",
85
+ "haemagglutininum influenzae A (H1N1) (Virus-Stamm A/California/7/2009 (H1N1)-like: reassortant virus NYMC X-179A) 15 µg, haemagglutininum influenzae A (H3N2) (Virus-Stamm A/Texas/50/2012 (H3N2)-like: reassortant virus NYMC X-223A) 15 µg, haemagglutininum influenzae B (Virus-Stamm B/Massachusetts/2/2012-like: B/Massachusetts/2/2012) 15 µg, natrii chloridum, kalii chloridum, dinatrii phosphas dihydricus, kalii dihydrogenophosphas, residui: formaldehydum max. 100 µg, octoxinolum-9 max. 500 µg, ovalbuminum max. 0.05 µg, saccharum nihil, neomycinum nihil, aqua ad iniectabilia q.s. ad suspensionem pro 0.5 ml.",
86
+ {selling_units: 25,
87
+ measure: "ml"})
88
+ tst_infloran = TestExample.new("Test Infloran, capsule",
89
+ 679, 2, 12, "Infloran, capsule",
90
+ "2x10", "Kapsel(n)",
91
+ "lactobacillus acidophilus cryodesiccatus, bifidobacterium infantis",
92
+ "lactobacillus acidophilus cryodesiccatus min. 10^9 CFU, bifidobacterium infantis min. 10^9 CFU, color.: E 127, E 132, E 104, excipiens pro capsula.",
93
+ {selling_units: 20,
94
+ measure: "Kapsel(n)"})
95
+ tst_mutagrip = TestExample.new("Test Mutagrip (Fertigspritzen)",
96
+ 373, 23, 10, "Mutagrip, Suspension zur Injektion",
97
+ "10 x 0.5 ml", "Fertigspritze(n)",
98
+ "ropivacainum",
99
+ "ropivacaini hydrochloridum 2 mg, natrii chloridum, aqua ad iniectabilia q.s. ad solutionem pro 1 ml.",
100
+ {selling_units: 10,
101
+ measure: "Fertigspritze(n)"})
102
+ tst_diamox = TestExample.new("Diamox. Tabletten",
103
+ 21191, 1, 19, "Diamox, comprimés",
104
+ "1 x 25", "Tablette(n)",
105
+ "acetazolamidum",
106
+ "acetazolamidum 250 mg, excipiens pro compresso.",
107
+ {selling_units: 25,
108
+ measure: "Tablette(n)"})
109
+
110
+ tst_naropin = TestExample.new("Das ist eine Injektionslösung von einer Packung mit 5 x 100 ml",
111
+ 54015, 0o1, 100, "Naropin 0,2 %, Infusionslösung / Injektionslösung",
112
+ "1 x 5 x 100", "ml",
113
+ "ropivacainum",
114
+ "ropivacaini hydrochloridum 2 mg, natrii chloridum, aqua ad iniectabilia q.s. ad solutionem pro 1 ml.",
115
+ { # :selling_units => 5, TODO:
116
+ # :measure => 'ml',
117
+ #:count => 5, :multi => 1
118
+ })
119
+
120
+ context "should parse Solvens:" do
121
+ text = "Solvens: conserv.: alcohol benzylicus 18 mg, aqua ad iniectabilia q.s. ad solutionem pro 2 ml."
122
+ info = Oddb2xml::Calc.new("Solu-Cortef 100 mg, Injektions-/Infusionspräparat", nil, nil,
123
+ "hydrocortisonum",
124
+ text)
125
+ specify { expect(info.compositions.first.substances.first.name).to eq "Alcohol Benzylicus" }
126
+ specify { expect(info.compositions.first.substances.size).to eq 1 }
150
127
  end
151
128
 
152
129
  context "adapt ATC for epha 16105 C05BA" do
153
- specify { expect(Oddb2xml.add_epha_changes_for_ATC(16105, 'C05BA')).to eq 'C05BA01' }
130
+ specify { expect(Oddb2xml.add_epha_changes_for_ATC(16105, "C05BA")).to eq "C05BA01" }
154
131
  end
155
132
 
156
133
  context "adapt ATC for epha 161 C05BA" do
157
- specify { expect(Oddb2xml.add_epha_changes_for_ATC(161, 'C05BA')).to eq 'C05BA' }
134
+ specify { expect(Oddb2xml.add_epha_changes_for_ATC(161, "C05BA")).to eq "C05BA" }
158
135
  end
159
136
 
160
- context 'handle E substances correctly' do
137
+ context "handle E substances correctly" do
161
138
  e_200_examples =
162
- {
163
- 'Comprimé pelliculé: ondansetronum 4 mg ut ondansetroni hydrochloridum dihydricum, E 200, arom.: vanillinum, color.: E 104, excipiens pro compresso obducto.' =>
164
- 'conserv.',
165
- 'ginkgonis extractum siccum raffinatum et quantificatum 120 mg corresp. flavonglycosida ginkgo 26.4-32.4 mg et terpenlactona ginkgo 6.48-7.92 mg, DER: 35-67:1, antiox.: E 200, excipiens pro compresso obducto.' =>
166
- 'antiox.',
167
- 'lamotriginum 100 mg, aromatica, antiox.: E 310, E 320, E 321, conserv.: E 200, excipiens pro compresso.' =>
168
- 'conserv.',
169
- }
170
- e_200_examples.each{
171
- | txt, e_200_expected_attribut|
172
- context txt.split(' ').first do
139
+ {
140
+ "Comprimé pelliculé: ondansetronum 4 mg ut ondansetroni hydrochloridum dihydricum, E 200, arom.: vanillinum, color.: E 104, excipiens pro compresso obducto." =>
141
+ "conserv.",
142
+ "ginkgonis extractum siccum raffinatum et quantificatum 120 mg corresp. flavonglycosida ginkgo 26.4-32.4 mg et terpenlactona ginkgo 6.48-7.92 mg, DER: 35-67:1, antiox.: E 200, excipiens pro compresso obducto." =>
143
+ "antiox.",
144
+ "lamotriginum 100 mg, aromatica, antiox.: E 310, E 320, E 321, conserv.: E 200, excipiens pro compresso." =>
145
+ "conserv."
146
+ }
147
+ e_200_examples.each { |txt, e_200_expected_attribut|
148
+ context txt.split(" ").first do
173
149
  info = ParseUtil.parse_compositions(txt)
174
- e_200 = info.first.substances.find{ |x| x.name.match(/E 200/i) }
175
- specify { expect(info.first.excipiens.more_info).to eq nil }
176
- specify { expect(e_200.class).to eq ParseSubstance }
177
- specify { expect(e_200.more_info).to eq e_200_expected_attribut}
150
+ e_200 = info.first.substances.find { |x| x.name.match(/E 200/i) }
151
+ specify { expect(info.first.excipiens.more_info).to eq nil }
152
+ specify { expect(e_200.class).to eq ParseSubstance }
153
+ specify { expect(e_200.more_info).to eq e_200_expected_attribut }
178
154
  end
179
155
  }
180
156
  end
181
157
 
182
- context 'should return correct value for liquid' do
183
- pkg_size_L = '1 x 5 x 200'
184
- einheit_M = 'ml'
185
- name_C = 'Naropin 0,2 %, Infusionslösung / Injektionslösung'
186
- result = Calc.new(name_C, pkg_size_L, einheit_M, nil)
158
+ context "should return correct value for liquid" do
159
+ pkg_size_l = "1 x 5 x 200"
160
+ einheit_m = "ml"
161
+ name_c = "Naropin 0,2 %, Infusionslösung / Injektionslösung"
162
+ result = Oddb2xml::Calc.new(name_c, pkg_size_l, einheit_m, nil)
187
163
  specify { expect(result.selling_units).to eq 5 }
188
- specify { expect(result.measure).to eq 'ml' }
164
+ specify { expect(result.measure).to eq "ml" }
189
165
  end
190
166
 
191
- context 'should return correct value for W-Tropfen' do
192
- pkg_size_L = '10'
193
- einheit_M = 'ml'
194
- name_C = 'W-Tropfen'
195
- result = Calc.new(name_C, pkg_size_L, einheit_M, nil)
167
+ context "should return correct value for W-Tropfen" do
168
+ pkg_size_l = "10"
169
+ einheit_m = "ml"
170
+ name_c = "W-Tropfen"
171
+ result = Oddb2xml::Calc.new(name_c, pkg_size_l, einheit_m, nil)
196
172
  specify { expect(result.selling_units).to eq 10 }
197
- specify { expect(result.measure).to eq 'ml' }
173
+ specify { expect(result.measure).to eq "ml" }
198
174
  end
199
175
 
200
- context 'should return correct value for Diamox, comprimés' do
201
- pkg_size_L = '1 x 25'
202
- einheit_M = 'Tablette(n)'
203
- name_C = 'Diamox, comprimés'
176
+ context "should return correct value for Diamox, comprimés" do
177
+ pkg_size_l = "1 x 25"
178
+ einheit_m = "Tablette(n)"
179
+ name_c = "Diamox, comprimés"
204
180
 
205
- result = Calc.new(name_C, pkg_size_L, einheit_M, nil)
181
+ result = Oddb2xml::Calc.new(name_c, pkg_size_l, einheit_m, nil)
206
182
  specify { expect(result.selling_units).to eq 25 }
207
- specify { expect(result.measure).to eq 'Tablette(n)' }
183
+ specify { expect(result.measure).to eq "Tablette(n)" }
208
184
 
209
- res = Calc.report_conversion
185
+ res = Oddb2xml::Calc.report_conversion
210
186
  specify { expect(res.class).to eq Array }
211
187
  specify { expect(res.first.class).to eq String }
212
188
  end
213
189
 
214
- context 'should return correct value for Perindopril' do
215
- pkg_size_L = '90'
216
- einheit_M = 'Tablette(n)'
217
- name_C = 'comprimés pelliculés'
190
+ context "should return correct value for Perindopril" do
191
+ pkg_size_l = "90"
192
+ einheit_m = "Tablette(n)"
193
+ name_c = "comprimés pelliculés"
218
194
 
219
- result = Calc.new(name_C, pkg_size_L, einheit_M, nil)
195
+ result = Oddb2xml::Calc.new(name_c, pkg_size_l, einheit_m, nil)
220
196
  specify { expect(result.selling_units).to eq 90 }
221
- specify { expect(result.measure).to eq einheit_M }
197
+ specify { expect(result.measure).to eq einheit_m }
222
198
 
223
- res = Calc.report_conversion
199
+ res = Oddb2xml::Calc.report_conversion
224
200
  specify { expect(res.class).to eq Array }
225
201
  specify { expect(res.first.class).to eq String }
226
202
  end
227
203
 
228
-
229
- context 'should find galenic_group for Kaugummi' do
230
- result = Calc.get_galenic_group('Kaugummi')
231
- specify { expect(result.class).to eq GalenicGroup }
232
- specify { expect(result.description).to eq 'Kaugummi' }
204
+ context "should find galenic_group for Kaugummi" do
205
+ result = Oddb2xml::Calc.get_galenic_group("Kaugummi")
206
+ specify { expect(result.class).to eq Oddb2xml::GalenicGroup }
207
+ specify { expect(result.description).to eq "Kaugummi" }
233
208
  end
234
209
 
235
- context 'should find galenic_form for Infusionslösung / Injektionslösung' do
236
- value = 'Infusionslösung / Injektionslösung'
237
- result = Calc.get_galenic_form(value)
238
- specify { expect(result.class).to eq GalenicForm }
239
- specify { expect(result.description).to eq 'Infusionslösung/Injektionslösung' }
210
+ context "should find galenic_form for Infusionslösung / Injektionslösung" do
211
+ value = "Infusionslösung / Injektionslösung"
212
+ result = Oddb2xml::Calc.get_galenic_form(value)
213
+ specify { expect(result.class).to eq Oddb2xml::GalenicForm }
214
+ specify { expect(result.description).to eq "Infusionslösung/Injektionslösung" }
240
215
  end
241
216
 
242
- context 'should return galenic_group unknown for galenic_group Dummy' do
243
- result = Calc.get_galenic_group('Dummy')
244
- specify { expect(result.class).to eq GalenicGroup }
245
- specify { expect(result.oid).to eq 1 }
246
- specify { expect(result.descriptions['de']).to eq 'unbekannt' }
247
- specify { expect(result.description).to eq 'unbekannt' }
217
+ context "should return galenic_group unknown for galenic_group Dummy" do
218
+ result = Oddb2xml::Calc.get_galenic_group("Dummy")
219
+ specify { expect(result.class).to eq Oddb2xml::GalenicGroup }
220
+ specify { expect(result.oid).to eq 1 }
221
+ specify { expect(result.descriptions["de"]).to eq "unbekannt" }
222
+ specify { expect(result.description).to eq "unbekannt" }
248
223
  end
249
224
 
250
- class TestExample
251
- def url
252
- "http://ch.oddb.org/de/gcc/drug/reg/#{sprintf('%05d' % iksnr_A)}/seq/#{sprintf('%02d' % seqnr_B)}/pack/#{sprintf('%03d' % pack_K)}"
253
- end
254
- end
255
225
  [tst_fluorglukose,
256
- tst_kamillin,
257
- Tst_naropin,
258
- tst_diamox,
259
- tst_mutagrip,
260
- ].each {
261
- |tst|
262
- context "verify #{tst.iksnr_A} #{tst.name_C}: #{tst.url}" do
263
- info = Calc.new(tst.name_C, tst.package_size_L, tst.einheit_M, tst.active_substance_0, tst.composition_P)
264
- tst.values_to_compare.each do
265
- |key, value|
266
- context key do
267
- cmd = "expect(info.#{key}.to_s).to eq '#{value.to_s}'"
268
- specify { eval(cmd) }
269
- end
226
+ tst_kamillin,
227
+ tst_naropin,
228
+ tst_diamox,
229
+ tst_mutagrip].each { |tst|
230
+ context "verify #{tst.iksnr_a} #{tst.name_c}: #{tst.url}" do
231
+ # info must be here, as it is used via eval!!
232
+ info = Oddb2xml::Calc.new(tst.name_c, tst.package_size_L, tst.einheit_m, tst.active_substance_0, tst.composition_P)
233
+ tst.values_to_compare.each do |key, value|
234
+ context key do
235
+ cmd = "expect(info.#{key}.to_s).to eq '#{value}'"
236
+ specify { eval(cmd) }
270
237
  end
271
238
  end
239
+ end
272
240
  }
273
241
 
274
- context 'find correct result for Injektionslösung' do
275
- info = Calc.new(Tst_naropin.name_C, Tst_naropin.package_size_L, Tst_naropin.einheit_M, Tst_naropin.active_substance_0, Tst_naropin.composition_P)
276
- specify { expect(Tst_naropin.url).to eq 'http://ch.oddb.org/de/gcc/drug/reg/54015/seq/01/pack/100' }
277
- specify { expect(info.galenic_form.description).to eq 'Infusionslösung/Injektionslösung' }
278
- specify { expect(info.galenic_group.description).to eq 'Injektion/Infusion' }
279
- specify { expect(info.pkg_size).to eq '1 x 5 x 100' }
280
- skip { expect(info.measure).to eq '100 ml' }
242
+ context "find correct result for Injektionslösung" do
243
+ info = Oddb2xml::Calc.new(tst_naropin.name_c, tst_naropin.package_size_L, tst_naropin.einheit_m, tst_naropin.active_substance_0, tst_naropin.composition_P)
244
+ specify { expect(tst_naropin.url).to eq "http://ch.oddb.org/de/gcc/drug/reg/54015/seq/01/pack/100" }
245
+ specify { expect(info.galenic_form.description).to eq "Infusionslösung/Injektionslösung" }
246
+ specify { expect(info.galenic_group.description).to eq "Injektion/Infusion" }
247
+ specify { expect(info.pkg_size).to eq "1 x 5 x 100" }
248
+ skip { expect(info.measure).to eq "100 ml" }
281
249
  end
282
250
 
283
- context 'find correct result for Inflora, capsule' do
284
- info = Calc.new(tst_infloran.name_C, tst_infloran.package_size_L, tst_infloran.einheit_M, tst_infloran.active_substance_0, tst_infloran.composition_P)
285
- specify { expect(tst_infloran.url).to eq 'http://ch.oddb.org/de/gcc/drug/reg/00679/seq/02/pack/012' }
286
- specify { expect(info.galenic_form.description).to eq 'Kapseln' }
287
- specify { expect(info.galenic_group.description).to eq 'Tabletten' }
288
- specify { expect(info.pkg_size).to eq '2x10' }
289
- specify { expect(info.selling_units).to eq 20 }
290
- specify { expect(info.measure).to eq 'Kapsel(n)' }
251
+ context "find correct result for Inflora, capsule" do
252
+ info = Oddb2xml::Calc.new(tst_infloran.name_c, tst_infloran.package_size_L, tst_infloran.einheit_m, tst_infloran.active_substance_0, tst_infloran.composition_P)
253
+ specify { expect(tst_infloran.url).to eq "http://ch.oddb.org/de/gcc/drug/reg/00679/seq/02/pack/012" }
254
+ specify { expect(info.galenic_form.description).to eq "Kapseln" }
255
+ specify { expect(info.galenic_group.description).to eq "Tabletten" }
256
+ specify { expect(info.pkg_size).to eq "2x10" }
257
+ specify { expect(info.selling_units).to eq 20 }
258
+ specify { expect(info.measure).to eq "Kapsel(n)" }
291
259
  end
292
260
 
293
- context 'find correct result for Kamillin' do
294
- info = Calc.new(tst_kamillin.name_C, tst_kamillin.package_size_L, tst_kamillin.einheit_M, tst_kamillin.active_substance_0, tst_kamillin.composition_P)
295
- specify { expect(info.selling_units).to eq 25 }
261
+ context "find correct result for Kamillin" do
262
+ info = Oddb2xml::Calc.new(tst_kamillin.name_c, tst_kamillin.package_size_L, tst_kamillin.einheit_m, tst_kamillin.active_substance_0, tst_kamillin.composition_P)
263
+ specify { expect(info.selling_units).to eq 25 }
296
264
  end
297
265
 
298
- context 'find correct result for bicaNova' do
299
- info = Calc.new(tst_bicaNova.name_C, tst_bicaNova.package_size_L, tst_bicaNova.einheit_M, tst_bicaNova.active_substance_0, tst_bicaNova.composition_P)
300
- specify { expect(info.selling_units).to eq 1500 }
301
- specify { expect(info.measure).to eq 'ml' }
266
+ context "find correct result for bicaNova" do
267
+ info = Oddb2xml::Calc.new(tst_bica_nova.name_c, tst_bica_nova.package_size_L, tst_bica_nova.einheit_m, tst_bica_nova.active_substance_0, tst_bica_nova.composition_P)
268
+ specify { expect(info.selling_units).to eq 1500 }
269
+ specify { expect(info.measure).to eq "ml" }
302
270
  end
303
271
 
304
- context 'should return correct value for mutagrip' do
305
- pkg_size_L = '10 x 0.5 ml'
306
- einheit_M = 'Fertigspritze(n)'
307
- name_C = 'Suspension zur Injektion'
272
+ context "should return correct value for mutagrip" do
273
+ pkg_size_l = "10 x 0.5 ml"
274
+ einheit_m = "Fertigspritze(n)"
275
+ name_c = "Suspension zur Injektion"
308
276
 
309
- result = Calc.new(name_C, pkg_size_L, einheit_M, nil)
277
+ result = Oddb2xml::Calc.new(name_c, pkg_size_l, einheit_m, nil)
310
278
  specify { expect(result.selling_units).to eq 10 }
311
- specify { expect(result.measure).to eq einheit_M }
279
+ specify { expect(result.measure).to eq einheit_m }
312
280
 
313
- res = Calc.report_conversion
281
+ res = Oddb2xml::Calc.report_conversion
314
282
  specify { expect(res.class).to eq Array }
315
283
  specify { expect(res.first.class).to eq String }
316
284
  end
317
285
 
318
- context 'should return correct value for 5 Ampullen a 10 mk' do
319
- pkg_size_L = '5 Ampullen a 10 ml'
320
- einheit_M = 'Ampulle'
321
- name_C = 'Suspension zur Injektion'
286
+ context "should return correct value for 5 Ampullen a 10 mk" do
287
+ pkg_size_l = "5 Ampullen a 10 ml"
288
+ einheit_m = "Ampulle"
289
+ name_c = "Suspension zur Injektion"
322
290
 
323
- result = Calc.new(name_C, pkg_size_L, einheit_M, nil)
291
+ result = Oddb2xml::Calc.new(name_c, pkg_size_l, einheit_m, nil)
324
292
  specify { expect(result.selling_units).to eq 5 }
325
- specify { expect(result.measure).to eq einheit_M }
326
-
327
- res = Calc.report_conversion
293
+ specify { expect(result.measure).to eq einheit_m }
294
+
295
+ res = Oddb2xml::Calc.report_conversion
328
296
  specify { expect(res.class).to eq Array }
329
297
  specify { expect(res.first.class).to eq String }
330
298
  end
331
299
 
332
- context 'find correct result for Nutriflex' do
333
- info = Calc.new(Tst_nutriflex.name_C, Tst_nutriflex.package_size_L, Tst_nutriflex.einheit_M, Tst_nutriflex.active_substance_0, Tst_nutriflex.composition_P)
334
- specify { expect(info.selling_units).to eq 5 }
335
- specify { expect(info.galenic_form.description).to eq "Infusionsemulsion" }
300
+ context "find correct result for Nutriflex" do
301
+ info = Oddb2xml::Calc.new(Tst_nutriflex.name_c, Tst_nutriflex.package_size_L, Tst_nutriflex.einheit_m, Tst_nutriflex.active_substance_0, Tst_nutriflex.composition_P)
302
+ specify { expect(info.selling_units).to eq 5 }
303
+ specify { expect(info.galenic_form.description).to eq "Infusionsemulsion" }
336
304
  end
337
305
 
338
- context 'should handle CFU' do
339
- result = Calc.new(nil, nil, nil, 'lactobacillus acidophilus cryodesiccatus, bifidobacterium infantis',
340
- 'lactobacillus acidophilus cryodesiccatus min. 10^9 CFU, bifidobacterium infantis min. 10^9 CFU, color.: E 127, E 132, E 104, excipiens pro capsula.')
341
- specify { expect(result.compositions.first.substances.first.name).to eq 'Lactobacillus Acidophilus Cryodesiccatus' }
342
- specify { expect(result.compositions.first.substances.first.dose.to_s).to eq '10^9 CFU' }
306
+ context "should handle CFU" do
307
+ result = Oddb2xml::Calc.new(nil, nil, nil, "lactobacillus acidophilus cryodesiccatus, bifidobacterium infantis",
308
+ "lactobacillus acidophilus cryodesiccatus min. 10^9 CFU, bifidobacterium infantis min. 10^9 CFU, color.: E 127, E 132, E 104, excipiens pro capsula.")
309
+ specify { expect(result.compositions.first.substances.first.name).to eq "Lactobacillus Acidophilus Cryodesiccatus" }
310
+ specify { expect(result.compositions.first.substances.first.dose.to_s).to eq "10^9 CFU" }
343
311
  end
344
312
 
345
- context 'find correct result compositions' do
346
- result = Calc.new(nil, nil, nil, 'rutosidum trihydricum, aescinum', 'rutosidum trihydricum 20 mg, aescinum 25 mg, aromatica, excipiens pro compresso.')
347
- specify { expect(result.compositions.first.substances.first.name).to eq 'Rutosidum Trihydricum' }
348
- specify { expect(result.compositions.first.substances.first.qty.to_f).to eq 20}
349
- specify { expect(result.compositions.first.substances.first.unit).to eq 'mg'}
350
- specify { expect(result.compositions.first.substances[1].name).to eq 'Aescinum' }
351
- specify { expect(result.compositions.first.substances[1].qty.to_f).to eq 25}
352
- specify { expect(result.compositions.first.substances[1].unit).to eq 'mg'}
313
+ context "find correct result compositions" do
314
+ result = Oddb2xml::Calc.new(nil, nil, nil, "rutosidum trihydricum, aescinum", "rutosidum trihydricum 20 mg, aescinum 25 mg, aromatica, excipiens pro compresso.")
315
+ specify { expect(result.compositions.first.substances.first.name).to eq "Rutosidum Trihydricum" }
316
+ specify { expect(result.compositions.first.substances.first.qty.to_f).to eq 20 }
317
+ specify { expect(result.compositions.first.substances.first.unit).to eq "mg" }
318
+ specify { expect(result.compositions.first.substances[1].name).to eq "Aescinum" }
319
+ specify { expect(result.compositions.first.substances[1].qty.to_f).to eq 25 }
320
+ specify { expect(result.compositions.first.substances[1].unit).to eq "mg" }
353
321
  end
354
322
 
355
- context 'find correct result for Inflora, capsule' do
356
- info = Calc.new(tst_infloran.name_C, tst_infloran.package_size_L, tst_infloran.einheit_M, tst_infloran.active_substance_0, tst_infloran.composition_P)
323
+ context "find correct result for Inflora, capsule" do
324
+ info = Oddb2xml::Calc.new(tst_infloran.name_c, tst_infloran.package_size_L, tst_infloran.einheit_m, tst_infloran.active_substance_0, tst_infloran.composition_P)
357
325
  # specify { expect(tst_infloran.url).to eq 'http://ch.oddb.org/de/gcc/drug/reg/00679/seq/02/pack/012' }
358
326
  specify { expect(info.galenic_form.oid).to eq 24 }
359
- specify { expect(info.galenic_form.description).to eq 'Kapseln' }
360
- specify { expect(info.galenic_group.description).to eq 'Tabletten' }
361
- specify { expect(info.pkg_size).to eq '2x10' }
362
- specify { expect(info.selling_units).to eq 20 }
363
- specify { expect(info.measure).to eq 'Kapsel(n)' }
364
- bifidobacterium = info.compositions.first.substances.find{ |x| x.name.match(/Bifidobacterium/i) }
365
- specify { expect(bifidobacterium).not_to eq nil}
327
+ specify { expect(info.galenic_form.description).to eq "Kapseln" }
328
+ specify { expect(info.galenic_group.description).to eq "Tabletten" }
329
+ specify { expect(info.pkg_size).to eq "2x10" }
330
+ specify { expect(info.selling_units).to eq 20 }
331
+ specify { expect(info.measure).to eq "Kapsel(n)" }
332
+ bifidobacterium = info.compositions.first.substances.find { |x| x.name.match(/Bifidobacterium/i) }
333
+ specify { expect(bifidobacterium).not_to eq nil }
366
334
  if bifidobacterium
367
- specify { expect(bifidobacterium.name).to eq 'Bifidobacterium Infantis' }
368
- specify { expect(bifidobacterium.dose.to_s).to eq '10^9 CFU'}
369
- specify { expect(bifidobacterium.unit).to eq 'CFU'}
335
+ specify { expect(bifidobacterium.name).to eq "Bifidobacterium Infantis" }
336
+ specify { expect(bifidobacterium.dose.to_s).to eq "10^9 CFU" }
337
+ specify { expect(bifidobacterium.unit).to eq "CFU" }
370
338
  end
371
- e_127 = info.compositions.first.substances.find{ |x| x.name.match(/E 127/i) }
372
- specify { expect(e_127).not_to eq nil}
339
+ e_127 = info.compositions.first.substances.find { |x| x.name.match(/E 127/i) }
340
+ specify { expect(e_127).not_to eq nil }
373
341
  if e_127
374
- specify { expect(e_127.name).to eq 'E 127' }
375
- specify { expect(e_127.unit).to eq nil}
342
+ specify { expect(e_127.name).to eq "E 127" }
343
+ specify { expect(e_127.unit).to eq nil }
376
344
  end
377
345
  end
378
346
 
379
- context 'find correct result for 274 Cardio-Pulmo-Rénal Sérocytol, suppositoire' do
380
- info = Calc.new(tst_cardio_pumal.name_C, tst_cardio_pumal.package_size_L, tst_cardio_pumal.einheit_M, tst_cardio_pumal.active_substance_0, tst_cardio_pumal.composition_P)
381
- specify { expect(info.galenic_form.description).to eq 'suppositoire' }
382
- specify { expect(info.galenic_group.description).to eq 'unbekannt' }
383
- specify { expect(info.pkg_size).to eq '3' }
384
- specify { expect(info.selling_units).to eq 3 }
385
- specify { expect(info.column_c).to eq tst_cardio_pumal.name_C }
386
- specify { expect(info.name).to eq 'Cardio-Pulmo-Rénal Sérocytol'}
387
- specify { expect(info.measure).to eq 'Suppositorien' }
388
- globulina = info.compositions.first.substances.find{ |x| x.name.match(/porcins|globulina/i) }
389
- specify { expect(globulina).not_to eq nil}
347
+ context "find correct result for 274 Cardio-Pulmo-Rénal Sérocytol, suppositoire" do
348
+ info = Oddb2xml::Calc.new(tst_cardio_pumal.name_c, tst_cardio_pumal.package_size_L, tst_cardio_pumal.einheit_m, tst_cardio_pumal.active_substance_0, tst_cardio_pumal.composition_P)
349
+ specify { expect(info.galenic_form.description).to eq "suppositoire" }
350
+ specify { expect(info.galenic_group.description).to eq "unbekannt" }
351
+ specify { expect(info.pkg_size).to eq "3" }
352
+ specify { expect(info.selling_units).to eq 3 }
353
+ specify { expect(info.column_c).to eq tst_cardio_pumal.name_c }
354
+ specify { expect(info.name).to eq "Cardio-Pulmo-Rénal Sérocytol" }
355
+ specify { expect(info.measure).to eq "Suppositorien" }
356
+ globulina = info.compositions.first.substances.find { |x| x.name.match(/porcins|globulina/i) }
357
+ specify { expect(globulina).not_to eq nil }
390
358
  if globulina
391
- specify { expect(globulina.name.downcase).to eq 'Globulina Equina (immunisé Avec Coeur, Tissu Pulmonaire, Reins De Porcins)'.downcase }
392
- specify { expect(globulina.qty.to_f).to eq 8.0}
393
- specify { expect(globulina.unit).to eq 'mg'}
359
+ specify { expect(globulina.name.downcase).to eq "Globulina Equina (immunisé Avec Coeur, Tissu Pulmonaire, Reins De Porcins)".downcase }
360
+ specify { expect(globulina.qty.to_f).to eq 8.0 }
361
+ specify { expect(globulina.unit).to eq "mg" }
394
362
  end
395
- e_216 = info.compositions.first.substances.find{ |x| x.name.match(/E 216/i) }
396
- specify { expect(e_216).not_to eq nil}
363
+ e_216 = info.compositions.first.substances.find { |x| x.name.match(/E 216/i) }
364
+ specify { expect(e_216).not_to eq nil }
397
365
  if e_216
398
- specify { expect(e_216.name).to eq 'E 216' }
399
- specify { expect(e_216.unit).to eq nil}
400
- specify { expect(e_216.more_info).to eq 'conserv.'}
366
+ specify { expect(e_216.name).to eq "E 216" }
367
+ specify { expect(e_216.unit).to eq nil }
368
+ specify { expect(e_216.more_info).to eq "conserv." }
401
369
  end
402
- e_218 = info.compositions.first.substances.find{ |x| x.name.match(/E 218/i) }
403
- specify { expect(e_218).not_to eq nil}
404
- specify { expect(e_218).not_to eq nil}
405
- specify { expect(e_218.more_info).to eq 'conserv.'}
370
+ e_218 = info.compositions.first.substances.find { |x| x.name.match(/E 218/i) }
371
+ specify { expect(e_218).not_to eq nil }
372
+ specify { expect(e_218).not_to eq nil }
373
+ specify { expect(e_218.more_info).to eq "conserv." }
406
374
  end
407
375
 
408
- context 'find correct result compositions for 00613 Pentavac' do
376
+ context "find correct result compositions for 00613 Pentavac" do
409
377
  line_1 = "I) DTPa-IPV-Komponente (Suspension): toxoidum diphtheriae 30 U.I., toxoidum tetani 40 U.I., toxoidum pertussis 25 µg et haemagglutininum filamentosum 25 µg, virus poliomyelitis typus 1 inactivatum (D-Antigen) 40 U., virus poliomyelitis typus 2 inactivatum (D-Antigen) 8 U., virus poliomyelitis typus 3 inactivatum (D-Antigen) 32 U., aluminium ut aluminii hydroxidum hydricum ad adsorptionem, formaldehydum 10 µg, conserv.: phenoxyethanolum 2.5 µl, residui: neomycinum, streptomycinum, polymyxini B sulfas, medium199, aqua q.s. ad suspensionem pro 0.5 ml."
410
378
  line_2 = "II) Hib-Komponente (Lyophilisat): haemophilus influenzae Typ B polysaccharida T-conjugatum 10 µg, trometamolum, saccharum, pro praeparatione."
411
379
  txt = "#{line_1}\n#{line_2}"
412
380
  info = ParseUtil.parse_compositions(txt)
413
- specify { expect(info.first.label).to eq 'I' }
414
- specify { expect(info.size).to eq 2 }
415
- specify { expect(info.first.substances.size).to eq 14 }
416
- toxoidum = info.first.substances.find{ |x| x.name.match(/Toxoidum Diphtheriae/i) }
417
- specify { expect(toxoidum.class).to eq ParseSubstance }
381
+ specify { expect(info.first.label).to eq "I" }
382
+ specify { expect(info.size).to eq 2 }
383
+ specify { expect(info.first.substances.size).to eq 14 }
384
+ toxoidum = info.first.substances.find { |x| x.name.match(/Toxoidum Diphtheriae/i) }
385
+ specify { expect(toxoidum.class).to eq ParseSubstance }
418
386
  if toxoidum
419
- specify { expect(toxoidum.name).to eq 'Toxoidum Diphtheriae' }
420
- specify { expect(toxoidum.qty.to_f).to eq 30.0 }
421
- specify { expect(toxoidum.unit).to eq 'U.I./0.5 ml' }
387
+ specify { expect(toxoidum.name).to eq "Toxoidum Diphtheriae" }
388
+ specify { expect(toxoidum.qty.to_f).to eq 30.0 }
389
+ specify { expect(toxoidum.unit).to eq "U.I./0.5 ml" }
422
390
  end
423
391
  end
424
392
 
425
- context 'find correct result compositions for fluticasoni with chemical_dose' do
426
- info = ParseUtil.parse_compositions('fluticasoni-17 propionas 100 µg, lactosum monohydricum q.s. ad pulverem pro 25 mg.')
427
- specify { expect(info.size).to eq 1 }
428
- specify { expect(info.first.substances.size).to eq 2 }
429
- fluticasoni = info.first.substances.find{ |x| x.name.match(/Fluticasoni/i) }
430
- specify { expect(fluticasoni.name).to eq 'Fluticasoni-17 Propionas' }
431
- specify { expect(fluticasoni.qty.to_f).to eq 100.0 }
432
- specify { expect(fluticasoni.unit).to eq 'µg/25 mg' }
433
- specify { expect(fluticasoni.dose.to_s).to eq "100 µg/25 mg" }
434
- lactosum = info.first.substances.find{ |x| x.name.match(/Lactosum/i) }
393
+ context "find correct result compositions for fluticasoni with chemical_dose" do
394
+ info = ParseUtil.parse_compositions("fluticasoni-17 propionas 100 µg, lactosum monohydricum q.s. ad pulverem pro 25 mg.")
395
+ specify { expect(info.size).to eq 1 }
396
+ specify { expect(info.first.substances.size).to eq 2 }
397
+ fluticasoni = info.first.substances.find { |x| x.name.match(/Fluticasoni/i) }
398
+ specify { expect(fluticasoni.name).to eq "Fluticasoni-17 Propionas" }
399
+ specify { expect(fluticasoni.qty.to_f).to eq 100.0 }
400
+ specify { expect(fluticasoni.unit).to eq "µg/25 mg" }
401
+ specify { expect(fluticasoni.dose.to_s).to eq "100 µg/25 mg" }
402
+ lactosum = info.first.substances.find { |x| x.name.match(/Lactosum/i) }
435
403
  specify { expect(lactosum.name).to eq "Lactosum Monohydricum" }
436
- specify { expect(lactosum.dose).to eq nil }
404
+ specify { expect(lactosum.dose).to eq nil }
437
405
  end
438
406
 
439
- context 'find correct result compositions for stuff with percents' do
440
- txt = 'calcium carbonicum hahnemanni C7 5 %, chamomilla recutita D5 22.5 %, magnesii hydrogenophosphas trihydricus C5 50 %, passiflora incarnata D5 22.5 %, xylitolum, excipiens ad globulos.'
407
+ context "find correct result compositions for stuff with percents" do
408
+ txt = "calcium carbonicum hahnemanni C7 5 %, chamomilla recutita D5 22.5 %, magnesii hydrogenophosphas trihydricus C5 50 %, passiflora incarnata D5 22.5 %, xylitolum, excipiens ad globulos."
441
409
  info = ParseUtil.parse_compositions(txt)
442
- specify { expect(info.size).to eq 1 }
410
+ specify { expect(info.size).to eq 1 }
443
411
  specify { expect(info.first.substances.size).to eq 5 }
444
- recutita = info.first.substances.find{ |x| x.name.match(/recutita/i) }
445
- specify { expect(recutita.name).to eq 'Chamomilla Recutita D5' }
446
- specify { expect(recutita.qty.to_f).to eq 22.5 }
447
- specify { expect(recutita.unit).to eq '%' }
412
+ recutita = info.first.substances.find { |x| x.name.match(/recutita/i) }
413
+ specify { expect(recutita.name).to eq "Chamomilla Recutita D5" }
414
+ specify { expect(recutita.qty.to_f).to eq 22.5 }
415
+ specify { expect(recutita.unit).to eq "%" }
448
416
  end
449
417
 
450
- context 'find correct result compositions for procainum with chemical_dose' do
451
- txt = 'procainum 10 mg ut procaini hydrochloridum, phenazonum 50 mg, Antiox.: E 320, glycerolum q.s. ad solutionem pro 1 g.'
418
+ context "find correct result compositions for procainum with chemical_dose" do
419
+ txt = "procainum 10 mg ut procaini hydrochloridum, phenazonum 50 mg, Antiox.: E 320, glycerolum q.s. ad solutionem pro 1 g."
452
420
  info = ParseUtil.parse_compositions(txt)
453
- specify { expect(info.size).to eq 1 }
454
- specify { expect(info.first.substances.size).to eq 4 }
455
- procainum = info.first.substances.find{ |x| x.name.match(/procain/i) }
456
- specify { expect(procainum.name).to eq 'Procainum' }
457
- specify { expect(procainum.qty.to_f).to eq 10.0 }
458
- specify { expect(procainum.unit).to eq 'mg/g' }
421
+ specify { expect(info.size).to eq 1 }
422
+ specify { expect(info.first.substances.size).to eq 4 }
423
+ procainum = info.first.substances.find { |x| x.name.match(/procain/i) }
424
+ specify { expect(procainum.name).to eq "Procainum" }
425
+ specify { expect(procainum.qty.to_f).to eq 10.0 }
426
+ specify { expect(procainum.unit).to eq "mg/g" }
459
427
  end
460
428
 
461
- context 'find correct result compositions for poloxamerum' do
429
+ context "find correct result compositions for poloxamerum" do
462
430
  line_1 = "I): albuminum humanum colloidale 0.5 mg, stanni(II) chloridum dihydricum 0.2 mg, glucosum anhydricum, dinatrii phosphas monohydricus, natrii fytas (9:1), poloxamerum 238, q.s. ad pulverem pro vitro."
463
431
  line_2 = "II): pro usu: I) recenter radioactivatum 99m-technetio ut natrii pertechnetas."
464
432
  text = "#{line_1}\n#{line_2}"
465
- info = Calc.new('Nanocoll, Markierungsbesteck', nil, nil,
466
- 'albuminum humanum colloidale, stanni(II) chloridum dihydricum',
467
- text
468
- )
469
- specify { expect(info.compositions.size).to eq 2 }
433
+ info = Oddb2xml::Calc.new("Nanocoll, Markierungsbesteck", nil, nil,
434
+ "albuminum humanum colloidale, stanni(II) chloridum dihydricum",
435
+ text)
436
+ specify { expect(info.compositions.size).to eq 2 }
470
437
  specify { expect(info.compositions.first.substances.size).to eq 6 }
471
- poloxamerum = info.compositions.first.substances.find{ |x| x.name.match(/poloxamerum/i) }
472
- specify { expect(poloxamerum.name).to eq 'Poloxamerum 238' }
473
- specify { expect(poloxamerum.qty).to eq nil}
474
- specify { expect(poloxamerum.unit).to eq nil }
438
+ poloxamerum = info.compositions.first.substances.find { |x| x.name.match(/poloxamerum/i) }
439
+ specify { expect(poloxamerum.name).to eq "Poloxamerum 238" }
440
+ specify { expect(poloxamerum.qty).to eq nil }
441
+ specify { expect(poloxamerum.unit).to eq nil }
475
442
  end
476
443
 
477
- context 'find correct result for 61676 Phostal 3-Bäume A): ' do
444
+ context "find correct result for 61676 Phostal 3-Bäume A): " do
478
445
  text = "A): pollinis allergeni extractum 0.01 U.: betula pendula Roth 25 % et alnus glutinosa 25 % et corylus avellana 25 % et fraxinus excelsior 25 %, natrii chloridum, glycerolum, tricalcii phosphas, conserv.: phenolum 4.0 mg, aqua q.s. ad suspensionem pro 1 ml"
479
- info = Calc.new('Phostal 3-Bäume', nil, nil,
480
- 'pollinis allergeni extractum',
481
- text
482
- )
483
- specify { expect(info.compositions.size).to eq 1 }
484
- specify { expect(info.compositions.first.label).to eq 'A' }
446
+ info = Oddb2xml::Calc.new("Phostal 3-Bäume", nil, nil,
447
+ "pollinis allergeni extractum",
448
+ text)
449
+ specify { expect(info.compositions.size).to eq 1 }
450
+ specify { expect(info.compositions.first.label).to eq "A" }
485
451
  end
486
452
 
487
- context 'find correct result for 47837 Ecodurex' do
453
+ context "find correct result for 47837 Ecodurex" do
488
454
  text = "amiloridi hydrochloridum dihydricum 5.67 mg corresp. amiloridi hydrochloridum anhydricum 5 mg, hydrochlorothiazidum 50 mg, excipiens pro compresso."
489
- info = Calc.new('Ecodurex', nil, nil,
490
- 'amiloridi hydrochloridum anhydricum, hydrochlorothiazidum',
491
- text
492
- )
493
- specify { expect(info.compositions.size).to eq 1 }
494
- specify { expect(info.compositions.first.label).to eq nil }
495
- substance1 = info.compositions.first.substances.find{ |x| x.name.match(/hydrochlorothiazidum/i) }
496
- specify { expect(substance1.name).to eq 'Hydrochlorothiazidum' }
497
- substance3 = info.compositions.first.substances.find{ |x| x.name.match(/amiloridi hydrochloridum/i) }
498
- specify { expect(substance3.class).to eq ParseSubstance }
455
+ info = Oddb2xml::Calc.new("Ecodurex", nil, nil,
456
+ "amiloridi hydrochloridum anhydricum, hydrochlorothiazidum",
457
+ text)
458
+ specify { expect(info.compositions.size).to eq 1 }
459
+ specify { expect(info.compositions.first.label).to eq nil }
460
+ substance1 = info.compositions.first.substances.find { |x| x.name.match(/hydrochlorothiazidum/i) }
461
+ specify { expect(substance1.name).to eq "Hydrochlorothiazidum" }
462
+ substance3 = info.compositions.first.substances.find { |x| x.name.match(/amiloridi hydrochloridum/i) }
463
+ specify { expect(substance3.class).to eq ParseSubstance }
499
464
  if substance3
500
- specify { expect(substance3.name).to eq 'Amiloridi Hydrochloridum Dihydricum' }
501
- specify { expect(substance3.chemical_substance.name).to eq 'Amiloridi Hydrochloridum Anhydricum' }
502
- specify { expect(substance3.qty.to_f).to eq 5.67 }
503
- specify { expect(substance3.unit).to eq 'mg' }
504
- specify { expect(substance3.chemical_substance.qty.to_f).to eq 5}
505
- specify { expect(substance3.chemical_substance.unit).to eq 'mg' }
465
+ specify { expect(substance3.name).to eq "Amiloridi Hydrochloridum Dihydricum" }
466
+ specify { expect(substance3.chemical_substance.name).to eq "Amiloridi Hydrochloridum Anhydricum" }
467
+ specify { expect(substance3.qty.to_f).to eq 5.67 }
468
+ specify { expect(substance3.unit).to eq "mg" }
469
+ specify { expect(substance3.chemical_substance.qty.to_f).to eq 5 }
470
+ specify { expect(substance3.chemical_substance.unit).to eq "mg" }
506
471
  specify { expect(substance3.is_active_agent).to eq true }
507
472
  end
508
-
509
473
  end
510
474
 
511
- context 'find correct result for 45079 Dr. Reckeweg R 51 Thyreosan, gouttes homéopathiques' do
475
+ context "find correct result for 45079 Dr. Reckeweg R 51 Thyreosan, gouttes homéopathiques" do
512
476
  text = "atropa belladonna D30, iodum D30, lapis albus D12, lycopus virginicus D12, natrii chloridum D30 ana partes 0.1 ml, excipiens ad solutionem pro 1 ml, corresp. ethanolum 35 % V/V."
513
- info = Calc.new('Dr. Reckeweg R 51 Thyreosan, gouttes homéopathiques', nil, nil,
514
- 'atropa belladonna D30, iodum D30, lapis albus D12, lycopus virginicus D12, natrii chloridum D30',
515
- text
516
- )
517
- specify { expect(info.compositions.size).to eq 1 }
518
- specify { expect(info.compositions.first.label).to eq nil }
519
- substance1 = info.compositions.first.substances.find{ |x| x.name.match(/atropa belladonna/i) }
520
- specify { expect(substance1.name).to eq 'Atropa Belladonna D30' }
521
- substance2 = info.compositions.first.substances.find{ |x| x.name.match(/lycopus virginicus/i) }
522
- specify { expect(substance2.class).to eq ParseSubstance }
523
- substance3 = info.compositions.first.substances.find{ |x| x.name.match(/lapis albus/i) }
524
- specify { expect(substance3.class).to eq ParseSubstance }
477
+ info = Oddb2xml::Calc.new("Dr. Reckeweg R 51 Thyreosan, gouttes homéopathiques", nil, nil,
478
+ "atropa belladonna D30, iodum D30, lapis albus D12, lycopus virginicus D12, natrii chloridum D30",
479
+ text)
480
+ specify { expect(info.compositions.size).to eq 1 }
481
+ specify { expect(info.compositions.first.label).to eq nil }
482
+ substance1 = info.compositions.first.substances.find { |x| x.name.match(/atropa belladonna/i) }
483
+ specify { expect(substance1.name).to eq "Atropa Belladonna D30" }
484
+ substance2 = info.compositions.first.substances.find { |x| x.name.match(/lycopus virginicus/i) }
485
+ specify { expect(substance2.class).to eq ParseSubstance }
486
+ substance3 = info.compositions.first.substances.find { |x| x.name.match(/lapis albus/i) }
487
+ specify { expect(substance3.class).to eq ParseSubstance }
525
488
  if substance3
526
- specify { expect(substance3.name).to eq 'Lapis Albus D12' }
489
+ specify { expect(substance3.name).to eq "Lapis Albus D12" }
527
490
  end
528
491
  end
529
492
 
530
- context 'find correct result for 00417 Tollwut Impfstoff Mérieu' do
493
+ context "find correct result for 00417 Tollwut Impfstoff Mérieu" do
531
494
  text = "Praeparatio cryodesiccata: virus rabiei inactivatum (Stamm: Wistar Rabies PM/WI 38-1503-3M) min. 2.5 U.I., albuminum humanum, neomycini sulfas, residui: phenolsulfonphthaleinum.
532
495
  Solvens: aqua ad iniectabilia q.s. ad suspensionem pro 1 ml."
533
- info = Calc.new('Tollwut Impfstoff Mérieu', nil, nil,
534
- 'virus rabiei inactivatum (Stamm: Wistar Rabies PM/WI 38-1503-3M) ',
535
- text
536
- )
537
- specify { expect(info.compositions.size).to eq 2 }
538
- specify { expect(info.compositions.first.label).to eq "Praeparatio cryodesiccata:" }
539
- substance1 = info.compositions.first.substances.find{ |x| x.name.match(/virus rabiei inactivatu/i) }
540
- specify { expect(expect(substance1)).not_to be nil }
496
+ info = Oddb2xml::Calc.new("Tollwut Impfstoff Mérieu", nil, nil,
497
+ "virus rabiei inactivatum (Stamm: Wistar Rabies PM/WI 38-1503-3M) ",
498
+ text)
499
+ specify { expect(info.compositions.size).to eq 2 }
500
+ specify { expect(info.compositions.first.label).to eq "Praeparatio cryodesiccata:" }
501
+ substance1 = info.compositions.first.substances.find { |x| x.name.match(/virus rabiei inactivatu/i) }
502
+ specify { expect(expect(substance1)).not_to be nil }
541
503
  if substance1
542
- specify { expect(substance1.name).to eq 'Virus Rabiei Inactivatum (stamm: Wistar Rabies Pm/wi 38-1503-3m)' }
504
+ specify { expect(substance1.name).to eq "Virus Rabiei Inactivatum (stamm: Wistar Rabies Pm/wi 38-1503-3m)" }
543
505
  end
544
- substance2 = info.compositions.first.substances.find{ |x| x.name.match(/albuminum humanu/i) }
506
+ substance2 = info.compositions.first.substances.find { |x| x.name.match(/albuminum humanu/i) }
545
507
  if substance2
546
- specify { expect(substance2.name).to eq 'Albuminum Humanum' }
508
+ specify { expect(substance2.name).to eq "Albuminum Humanum" }
547
509
  end
548
- specify { expect(substance2.class).to eq ParseSubstance }
549
- substance3 = info.compositions.first.substances.find{ |x| x.name.match(/neomycini sulfas/i) }
550
- specify { expect(substance3.class).to eq ParseSubstance }
510
+ specify { expect(substance2.class).to eq ParseSubstance }
511
+ substance3 = info.compositions.first.substances.find { |x| x.name.match(/neomycini sulfas/i) }
512
+ specify { expect(substance3.class).to eq ParseSubstance }
551
513
  if substance3
552
- specify { expect(substance3.name).to eq 'Neomycini Sulfas' }
514
+ specify { expect(substance3.name).to eq "Neomycini Sulfas" }
553
515
  end
554
516
  end
555
517
 
556
518
  context "find correct result compositions for #{tst_grains_de_valse.composition_P} with chemical_dose" do
557
- info = Calc.new(tst_grains_de_valse.name_C, tst_grains_de_valse.package_size_L, tst_grains_de_valse.einheit_M, tst_grains_de_valse.active_substance_0, tst_grains_de_valse.composition_P)
558
- sennosidum = info.compositions.first.substances.find{ |x| x.name.match(/Senn/i) }
559
- specify { expect(sennosidum).not_to eq nil}
519
+ info = Oddb2xml::Calc.new(tst_grains_de_valse.name_c, tst_grains_de_valse.package_size_L, tst_grains_de_valse.einheit_m, tst_grains_de_valse.active_substance_0, tst_grains_de_valse.composition_P)
520
+ sennosidum = info.compositions.first.substances.find { |x| x.name.match(/Senn/i) }
521
+ specify { expect(sennosidum).not_to eq nil }
560
522
  if sennosidum
561
- specify { expect(sennosidum.name).to eq 'Sennae Folii Extractum Methanolicum Siccum' }
562
- specify { expect(sennosidum.dose.to_s).to eq '78-104 mg' }
563
- specify { expect(sennosidum.qty.to_f).to eq 78.0}
564
- specify { expect(sennosidum.unit).to eq 'mg'}
565
- specify { expect(sennosidum.chemical_substance.name).to eq 'Sennosidum B' }
566
- specify { expect(sennosidum.chemical_substance.qty.to_f).to eq 12.5 }
567
- specify { expect(sennosidum.chemical_substance.unit).to eq 'mg' }
523
+ specify { expect(sennosidum.name).to eq "Sennae Folii Extractum Methanolicum Siccum" }
524
+ specify { expect(sennosidum.dose.to_s).to eq "78-104 mg" }
525
+ specify { expect(sennosidum.qty.to_f).to eq 78.0 }
526
+ specify { expect(sennosidum.unit).to eq "mg" }
527
+ specify { expect(sennosidum.chemical_substance.name).to eq "Sennosidum B" }
528
+ specify { expect(sennosidum.chemical_substance.qty.to_f).to eq 12.5 }
529
+ specify { expect(sennosidum.chemical_substance.unit).to eq "mg" }
568
530
  end
569
531
  end
570
532
 
571
- context 'find correct result compositions for 56829 sequence 3 Iscador M 0,01 mg' do
533
+ context "find correct result compositions for 56829 sequence 3 Iscador M 0,01 mg" do
572
534
  comment_from_email_good_7_juni_2011 = %(
573
535
  Ausgedeutscht heisst das:
574
536
  Der Extrakt ist ein Auszug aus der Frischpflanze im Verhältnis 1:5, also ‚extractum 0.05 mg’ entspricht 0.01 mg frischem Mistelkraut.
575
537
  Es handelt sich um EINEN Wirkstoff, also „in Kombination“ ist falsch formuliert.
576
538
  Die HILFSSTOFFE sind Aqua ad iniectabilia und Natrii chloridum.
577
539
  )
578
- text = 'extractum aquosum liquidum fermentatum 0.05 mg ex viscum album (mali) recens 0.01 mg, natrii chloridum, aqua q.s. ad solutionem pro 1 ml.'
579
- info = Calc.new("Iscador M 0,01 mg, Injektionslösung", '2 x 7', 'Ampulle(n)',
580
- 'viscum album (mali) recens',
581
- text)
582
- specify { expect(info.pkg_size).to eq '2 x 7' }
540
+ puts comment_from_email_good_7_juni_2011 if $VERBOSE
541
+ text = "extractum aquosum liquidum fermentatum 0.05 mg ex viscum album (mali) recens 0.01 mg, natrii chloridum, aqua q.s. ad solutionem pro 1 ml."
542
+ info = Oddb2xml::Calc.new("Iscador M 0,01 mg, Injektionslösung", "2 x 7", "Ampulle(n)",
543
+ "viscum album (mali) recens",
544
+ text)
545
+ specify { expect(info.pkg_size).to eq "2 x 7" }
583
546
  specify { expect(info.selling_units).to eq 14 }
584
547
  specify { expect(info.compositions.first.substances.size).to eq 2 }
585
- viscum = info.compositions.first.substances.find{ |x| x.name.match(/viscum/i) }
586
- specify { expect(viscum).not_to eq nil}
587
- natrii = info.compositions.first.substances.find{ |x| x.name.match(/natrii chloridum/i) }
588
- specify { expect(natrii).not_to eq nil}
548
+ viscum = info.compositions.first.substances.find { |x| x.name.match(/viscum/i) }
549
+ specify { expect(viscum).not_to eq nil }
550
+ natrii = info.compositions.first.substances.find { |x| x.name.match(/natrii chloridum/i) }
551
+ specify { expect(natrii).not_to eq nil }
589
552
  if viscum
590
- specify { expect(viscum.name).to eq 'Extractum Aquosum Liquidum Fermentatum 0.05 Mg Ex Viscum Album (mali) Recens' }
591
- skip { expect(viscum.is_active_agent).to eq true } # TODO: Grenzfall. Active-Agent viscum album (mali) recens ist sub-string
592
- specify { expect(viscum.dose.to_s).to eq '0.01 mg/ml' }
593
- specify { expect(viscum.qty.to_f).to eq 0.01}
594
- specify { expect(viscum.unit).to eq 'mg/ml'}
595
- specify { expect(viscum.chemical_substance).to eq nil }
553
+ specify { expect(viscum.name).to eq "Extractum Aquosum Liquidum Fermentatum 0.05 Mg Ex Viscum Album (mali) Recens" }
554
+ skip { expect(viscum.is_active_agent).to eq true } # TODO: Grenzfall. Active-Agent viscum album (mali) recens ist sub-string
555
+ specify { expect(viscum.dose.to_s).to eq "0.01 mg/ml" }
556
+ specify { expect(viscum.qty.to_f).to eq 0.01 }
557
+ specify { expect(viscum.unit).to eq "mg/ml" }
558
+ specify { expect(viscum.chemical_substance).to eq nil }
596
559
  end
597
560
  end
598
- context 'find correct result compositions for 56829 sequence 23 Iscador Ag 0,01 mg' do
599
- text = 'extractum aquosum liquidum fermentatum 0.05 mg ex viscum album (mali) recens 0.01 mg, natrii chloridum, argenti carbonas (0,01 ug pro 100 mg herba recente), aqua q.s. ad solutionem pro 1 ml.'
600
- info = Calc.new("Iscador M c. Arg. 0,01 mg, Injektionslösung, anthroposophisches Arzneimittel", '2 x 7', 'Ampulle(n)',
601
- 'viscum album (mali) recens, argenti carbonas (0,01 ug pro 100 mg herba recente)',
602
- text)
603
- specify { expect(info.pkg_size).to eq '2 x 7' }
561
+ context "find correct result compositions for 56829 sequence 23 Iscador Ag 0,01 mg" do
562
+ text = "extractum aquosum liquidum fermentatum 0.05 mg ex viscum album (mali) recens 0.01 mg, natrii chloridum, argenti carbonas (0,01 ug pro 100 mg herba recente), aqua q.s. ad solutionem pro 1 ml."
563
+ info = Oddb2xml::Calc.new("Iscador M c. Arg. 0,01 mg, Injektionslösung, anthroposophisches Arzneimittel", "2 x 7", "Ampulle(n)",
564
+ "viscum album (mali) recens, argenti carbonas (0,01 ug pro 100 mg herba recente)",
565
+ text)
566
+ specify { expect(info.pkg_size).to eq "2 x 7" }
604
567
  specify { expect(info.selling_units).to eq 14 }
605
568
  specify { expect(info.compositions.first.substances.size).to eq 3 }
606
- viscum = info.compositions.first.substances.find{ |x| x.name.match(/viscum/i) }
607
- specify { expect(viscum).not_to eq nil}
569
+ viscum = info.compositions.first.substances.find { |x| x.name.match(/viscum/i) }
570
+ specify { expect(viscum).not_to eq nil }
608
571
  if viscum
609
- specify { expect(viscum.name).to eq 'Extractum Aquosum Liquidum Fermentatum 0.05 Mg Ex Viscum Album (mali) Recens' }
610
- specify { expect(viscum.dose.to_s).to eq '0.01 mg/ml' }
611
- specify { expect(viscum.qty.to_f).to eq 0.01}
612
- specify { expect(viscum.unit).to eq 'mg/ml'}
613
- specify { expect(viscum.chemical_substance).to eq nil }
572
+ specify { expect(viscum.name).to eq "Extractum Aquosum Liquidum Fermentatum 0.05 Mg Ex Viscum Album (mali) Recens" }
573
+ specify { expect(viscum.dose.to_s).to eq "0.01 mg/ml" }
574
+ specify { expect(viscum.qty.to_f).to eq 0.01 }
575
+ specify { expect(viscum.unit).to eq "mg/ml" }
576
+ specify { expect(viscum.chemical_substance).to eq nil }
614
577
  end
615
- argenti = info.compositions.first.substances.find{ |x| x.name.match(/Argenti/i) }
616
- specify { expect(argenti).not_to eq nil}
578
+ argenti = info.compositions.first.substances.find { |x| x.name.match(/Argenti/i) }
579
+ specify { expect(argenti).not_to eq nil }
617
580
  if argenti
618
- specify { expect(argenti.name).to eq 'Argenti Carbonas (0,01 Ug pro 100 Mg Herba Recente)' }
619
- skip { expect(argenti.dose.to_s).to eq '0.01 mg/ml' } # 100 mg/ml
620
- skip { expect(argenti.qty.to_f).to eq 0.01}
621
- skip { expect(argenti.unit).to eq 'mg/ml'}
622
- specify { expect(argenti.chemical_substance).to eq nil }
581
+ specify { expect(argenti.name).to eq "Argenti Carbonas (0,01 Ug pro 100 Mg Herba Recente)" }
582
+ skip { expect(argenti.dose.to_s).to eq "0.01 mg/ml" } # 100 mg/ml
583
+ skip { expect(argenti.qty.to_f).to eq 0.01 }
584
+ skip { expect(argenti.unit).to eq "mg/ml" }
585
+ specify { expect(argenti.chemical_substance).to eq nil }
623
586
  end
624
587
  end
625
588
  end
626
589
 
590
+ ODDB_CALC_XML = File.join(Oddb2xml::WORK_DIR, "oddb_calc.xml")
627
591
  describe Oddb2xml::Calc do
628
- Oddb_calc_xml = File.join(Oddb2xml::WorkDir, 'oddb_calc.xml')
629
-
630
592
  before(:all) do
631
- @savedDir = Dir.pwd
593
+ @saved_dir = Dir.pwd
632
594
  cleanup_directories_before_run
633
- FileUtils.makedirs(Oddb2xml::WorkDir)
634
- Dir.chdir(Oddb2xml::WorkDir)
635
- VCR.eject_cassette; VCR.insert_cassette('oddb2xml')
636
- @run_time_options = '--calc --skip-download'
595
+ FileUtils.makedirs(Oddb2xml::WORK_DIR)
596
+ Dir.chdir(Oddb2xml::WORK_DIR)
597
+ VCR.eject_cassette
598
+ VCR.insert_cassette("oddb2xml")
599
+ @run_time_options = "--calc --skip-download"
637
600
  @options = Oddb2xml::Options.parse(@run_time_options)
638
- @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(@options).run }
639
- expect(File.exists?(Oddb_calc_xml)).to eq true
640
- @doc = REXML::Document.new File.read(Oddb_calc_xml)
641
- @nokogiri = Nokogiri::XML(File.read(Oddb_calc_xml))
601
+ @res = buildr_capture(:stdout) { Oddb2xml::Cli.new(@options).run }
602
+ expect(File.exist?(ODDB_CALC_XML)).to eq true
603
+ @doc = REXML::Document.new File.read(ODDB_CALC_XML)
604
+ @nokogiri = Nokogiri::XML(File.read(ODDB_CALC_XML))
642
605
  end
643
606
 
644
607
  after(:all) do
645
- Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir)
608
+ Dir.chdir @saved_dir if @saved_dir && File.directory?(@saved_dir)
646
609
  end
647
610
 
648
611
  context "Verify elements from XSD" do
649
- attribute_tests = [
650
- ['ARTICLES', 'CREATION_DATETIME', Oddb2xml::DATE_REGEXP],
651
- ['ARTICLES', 'PROD_DATE', Oddb2xml::DATE_REGEXP],
652
- ['ARTICLES', 'VALID_DATE', Oddb2xml::DATE_REGEXP],
653
- ['ARTICLES/ARTICLE', 'SHA256', /[a-f0-9]{32}/],
654
- ]
655
-
656
- check_attributes(Oddb_calc_xml, attribute_tests)
657
-
658
- element_tests = [
659
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/EXCIPIENS', /.*pro Vitro.*/],
660
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/EXCIPIENS', /.Excipiens ad solutionem.*/],
661
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL', 'I'],
662
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL', 'Solvens'],
663
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION', 'Aminosäurenlösung'],
664
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION', 'Fettemulsion'],
665
- # ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/DOSE_TEXT', 'mg'],
666
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SALTS/SALT/SUBSTANCE_NAME', 'Ceftriaxonum Natricum'],
667
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/CORRESP', /4240 kJ pro 1 l/],
668
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/CORRESP', /I\) et II\) et III\) corresp.*/],
669
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/DOSE_TEXT', '10-50 mg'],
670
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/MORE_INFO', 'ratio: 1:2-2.8'],
671
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/SUBSTANCE_NAME', 'Levomenolum'],
672
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/IS_ACTIVE_AGENT', 'false'],
673
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/IS_ACTIVE_AGENT', 'true'],
674
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/MORE_INFO', 'conserv.'],
675
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/MORE_INFO', 'antiox.'],
676
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/MORE_INFO', 'Praeparatio sicca'],
677
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY', '100'],
678
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY', /4\.08/],
679
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME', 'E 124'],
680
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME', 'Lamivudinum'],
681
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT', 'mg'],
682
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT', 'mg'],
683
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT', 'µg'],
684
- ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT', /U\.I\.\/ml/],
685
- ['ARTICLES/ARTICLE/GALENIC_FORM', 'Infusionsemulsion'],
686
- ['ARTICLES/ARTICLE/GALENIC_FORM', 'Tropfen'],
687
- ['ARTICLES/ARTICLE/GALENIC_GROUP', 'Lösungsmittel'],
688
- ['ARTICLES/ARTICLE/GALENIC_GROUP', 'Tabletten'],
689
- ['ARTICLES/ARTICLE/GTIN', Oddb2xml::FRIDGE_GTIN],
690
- ['ARTICLES/ARTICLE/GTIN', Oddb2xml::ORPHAN_GTIN],
691
- ['ARTICLES/ARTICLE/MEASURE', 'Suppositorien'],
692
- ['ARTICLES/ARTICLE/MEASURE', /Ampulle\(n\)/],
693
- ['ARTICLES/ARTICLE/NAME', 'Apligraf'],
694
- ['ARTICLES/ARTICLE/NAME', 'Lansoyl, gelée'],
695
- ['ARTICLES/ARTICLE/PKG_SIZE', '1'],
696
- ['ARTICLES/ARTICLE/PKG_SIZE', '5 x 2500 ml'],
697
- ['ARTICLES/ARTICLE/PKG_SIZE', '75 mm'],
698
- ['ARTICLES/ARTICLE/SELLING_UNITS', '1'],
699
- ['ARTICLES/ARTICLE/SELLING_UNITS', '60'],
700
- ['ARTICLES/ARTICLE/SELLING_UNITS', 'unbekannt'],
701
- ]
702
- check_elements(Oddb_calc_xml, element_tests)
612
+ attribute_tests = [
613
+ ["ARTICLES", "CREATION_DATETIME", Oddb2xml::DATE_REGEXP],
614
+ ["ARTICLES", "PROD_DATE", Oddb2xml::DATE_REGEXP],
615
+ ["ARTICLES", "VALID_DATE", Oddb2xml::DATE_REGEXP],
616
+ ["ARTICLES/ARTICLE", "SHA256", /[a-f0-9]{32}/]
617
+ ]
618
+
619
+ check_attributes(ODDB_CALC_XML, attribute_tests)
620
+
621
+ element_tests = [
622
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/EXCIPIENS", /.*pro Vitro.*/],
623
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/EXCIPIENS", /.Excipiens ad solutionem.*/],
624
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL", "I"],
625
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL", "Solvens"],
626
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION", "Aminosäurenlösung"],
627
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION", "Fettemulsion"],
628
+ # ['ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/DOSE_TEXT', 'mg'],
629
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SALTS/SALT/SUBSTANCE_NAME", "Ceftriaxonum Natricum"],
630
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/CORRESP", /4240 kJ pro 1 l/],
631
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/CORRESP", /I\) et II\) et III\) corresp.*/],
632
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/DOSE_TEXT", "10-50 mg"],
633
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/MORE_INFO", "ratio: 1:2-2.8"],
634
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/SUBSTANCE_NAME", "Levomenolum"],
635
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/IS_ACTIVE_AGENT", "false"],
636
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/IS_ACTIVE_AGENT", "true"],
637
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/MORE_INFO", "conserv."],
638
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/MORE_INFO", "antiox."],
639
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/MORE_INFO", "Praeparatio sicca"],
640
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY", "100"],
641
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY", /4\.08/],
642
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME", "E 124"],
643
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME", "Lamivudinum"],
644
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT", "mg"],
645
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT", "mg"],
646
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT", "µg"],
647
+ ["ARTICLES/ARTICLE/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT", /U\.I\.\/ml/],
648
+ ["ARTICLES/ARTICLE/GALENIC_FORM", "Infusionsemulsion"],
649
+ ["ARTICLES/ARTICLE/GALENIC_FORM", "Tropfen"],
650
+ ["ARTICLES/ARTICLE/GALENIC_GROUP", "Lösungsmittel"],
651
+ ["ARTICLES/ARTICLE/GALENIC_GROUP", "Tabletten"],
652
+ ["ARTICLES/ARTICLE/GTIN", Oddb2xml::FRIDGE_GTIN],
653
+ ["ARTICLES/ARTICLE/GTIN", Oddb2xml::ORPHAN_GTIN],
654
+ ["ARTICLES/ARTICLE/MEASURE", "Suppositorien"],
655
+ ["ARTICLES/ARTICLE/MEASURE", /Ampulle\(n\)/],
656
+ ["ARTICLES/ARTICLE/NAME", "Apligraf"],
657
+ ["ARTICLES/ARTICLE/NAME", "Lansoyl, gelée"],
658
+ ["ARTICLES/ARTICLE/PKG_SIZE", "1"],
659
+ ["ARTICLES/ARTICLE/PKG_SIZE", "5 x 2500 ml"],
660
+ ["ARTICLES/ARTICLE/PKG_SIZE", "75 mm"],
661
+ ["ARTICLES/ARTICLE/SELLING_UNITS", "1"],
662
+ ["ARTICLES/ARTICLE/SELLING_UNITS", "60"],
663
+ ["ARTICLES/ARTICLE/SELLING_UNITS", "unbekannt"]
664
+ ]
665
+ check_elements(ODDB_CALC_XML, element_tests)
703
666
  end
704
667
  context "when passing #{@run_time_options}" do
705
- it 'should contain the new fields as per July 2015' do
668
+ it "should contain the new fields as per July 2015" do
706
669
  # xml.GEN_PRODUCTION gen_production
707
670
  # xml.INSULIN_CATEGORY insulin_category
708
671
  # xml.DRUG_INDEX drug_index
709
- expect(File.exists?(Oddb_calc_xml)).to eq true
672
+ expect(File.exist?(ODDB_CALC_XML)).to eq true
710
673
  end
711
674
 
712
- it 'should create a correct xml and a csv file' do
713
- src = File.expand_path(File.join(File.dirname(__FILE__), 'data', 'swissmedic_package-galenic.xlsx'))
714
- dest = File.join(Oddb2xml::WorkDir, 'swissmedic_package.xlsx')
715
- expected = [
716
- 'oddb_calc.xml',
717
- 'oddb_calc.csv',
675
+ it "should create a correct xml and a csv file" do
676
+ [
677
+ "oddb_calc.xml",
678
+ "oddb_calc.csv"
718
679
  ].each { |file|
719
- full = File.join(Oddb2xml::WorkDir, file)
720
- expect(File.exists?(full)).to eq true
721
- }
722
- oddb_calc_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb_calc.xsd'))
723
- expect(File.exists?(oddb_calc_xsd)).to eq true
680
+ full = File.join(Oddb2xml::WORK_DIR, file)
681
+ expect(File.exist?(full)).to eq true
682
+ }
683
+ oddb_calc_xsd = File.expand_path(File.join(File.dirname(__FILE__), "..", "oddb_calc.xsd"))
684
+ expect(File.exist?(oddb_calc_xsd)).to eq true
724
685
  xsd = Nokogiri::XML::Schema(File.read(oddb_calc_xsd))
725
- xsd.validate(@nokogiri).each do |error| expect(error).to be_nil end
686
+ xsd.validate(@nokogiri).each { |error| expect(error).to be_nil }
726
687
  end
727
688
 
728
- it 'should create correct entries for narotin' do
729
- gtin = '7680560890018'
730
- ean12 = '7680' + sprintf('%05d',Tst_nutriflex.iksnr_A) + sprintf('%03d',Tst_nutriflex.pack_K)
689
+ it "should create correct entries for narotin" do
690
+ gtin = "7680560890018"
691
+ ean12 = "7680" + sprintf("%05d", Tst_nutriflex.iksnr_a) + sprintf("%03d", Tst_nutriflex.pack_K)
731
692
  ean13 = (ean12 + Oddb2xml.calc_checksum(ean12))
732
693
  expect(ean13).to eq gtin
733
- Tst_nutriflex.values_to_compare.each{
734
- | key, value |
735
- result = XPath.match( @doc, "//ARTICLE[GTIN='#{gtin}']/#{key.to_s.upcase}").first.text
736
- puts "Testing key #{key.inspect} #{value.inspect} against #{result} seems to fail" unless result == value.to_s
737
- expect(result).to eq value.to_s
694
+ Tst_nutriflex.values_to_compare.each { |key, value|
695
+ result = REXML::XPath.match(@doc, "//ARTICLE[GTIN='#{gtin}']/#{key.to_s.upcase}").first.text
696
+ puts "Testing key #{key.inspect} #{value.inspect} against #{result} seems to fail" unless result == value.to_s
697
+ expect(result).to eq value.to_s
738
698
  }
739
699
  end
740
700
 
741
- it 'should create correct entries for 7680555940018' do
742
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").first.text).to eq 'I'
743
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION").first.text).to eq 'Glucoselösung'
744
- XPath.match( @doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").each{ |x| puts x.text }
745
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").last.text).to eq 'III'
746
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/CORRESP").last.text).to eq '4240 kJ pro 1 l'
701
+ it "should create correct entries for 7680555940018" do
702
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").first.text).to eq "I"
703
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL_DESCRIPTION").first.text).to eq "Glucoselösung"
704
+ REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").each { |x| puts x.text }
705
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/LABEL").last.text).to eq "III"
706
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680555940018']/COMPOSITIONS/COMPOSITION/CORRESP").last.text).to eq "4240 kJ pro 1 l"
747
707
  end
748
708
 
749
- it 'should create correct entries for Lidocaini' do
750
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680300150105']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME").first.text).to eq 'Lidocaini Hydrochloridum'
751
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680300150105']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT").first.text).to eq 'mg/ml'
709
+ it "should create correct entries for Lidocaini" do
710
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680300150105']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME").first.text).to eq "Lidocaini Hydrochloridum"
711
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680300150105']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/UNIT").first.text).to eq "mg/ml"
752
712
  end
753
713
 
754
- it 'should create correct entries for Levomenolum' do
755
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/SUBSTANCE_NAME").first.text).to eq 'Levomenolum'
756
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/MORE_INFO").first.text).to eq 'ratio: 1:2-2.8'
757
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/DOSE_TEXT").first.text).to eq '10-50 mg'
758
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/QTY").first).to eq nil
759
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/UNIT").first).to eq nil
760
- matri_name = 'Matricariae Extractum Isopropanolicum Liquidum'
761
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME").
762
- find{|x| x.text.eql?(matri_name)}.text).to eq matri_name
763
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/NAME").last.text).to eq 'Kamillin Medipharm, Bad'
764
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/GALENIC_FORM").last.text).to eq 'Bad'
765
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY").first.text).to eq '98.9'
714
+ it "should create correct entries for Levomenolum" do
715
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/SUBSTANCE_NAME").first.text).to eq "Levomenolum"
716
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/MORE_INFO").first.text).to eq "ratio: 1:2-2.8"
717
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/DOSE_TEXT").first.text).to eq "10-50 mg"
718
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/QTY").first).to eq nil
719
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/CHEMICAL_SUBSTANCE/UNIT").first).to eq nil
720
+ matri_name = "Matricariae Extractum Isopropanolicum Liquidum"
721
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SUBSTANCE_NAME")
722
+ .find { |x| x.text.eql?(matri_name) }.text).to eq matri_name
723
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/NAME").last.text).to eq "Kamillin Medipharm, Bad"
724
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/GALENIC_FORM").last.text).to eq "Bad"
725
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680434541015']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/QTY").first.text).to eq "98.9"
766
726
  end
767
727
 
768
- it 'should create correct entries for Magnesiumchlorid' do
769
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680458820202']/NAME").last.text).to eq 'Magnesiumchlorid 0,5 molar B. Braun, Zusatzampulle für Infusionslösungen'
770
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680458820202']/GALENIC_FORM").last.text).to match /Ampulle/i
728
+ it "should create correct entries for Magnesiumchlorid" do
729
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680458820202']/NAME").last.text).to eq "Magnesiumchlorid 0,5 molar B. Braun, Zusatzampulle für Infusionslösungen"
730
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680458820202']/GALENIC_FORM").last.text).to match(/Ampulle/i)
771
731
  end
772
732
 
773
- it 'should create correct entries for W-Tropfen' do
774
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/SUBSTANCE_NAME").first.text).to eq 'Excipiens ad solutionem'
775
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/QTY").first.text).to eq '1'
776
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/UNIT").first.text).to eq 'ml'
777
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680165980114']/NAME").first.text).to eq 'W-Tropfen'
778
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680165980114']/GALENIC_FORM").last.text).to eq 'Tropfen'
733
+ it "should create correct entries for W-Tropfen" do
734
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/SUBSTANCE_NAME").first.text).to eq "Excipiens ad solutionem"
735
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/QTY").first.text).to eq "1"
736
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680165980114']/COMPOSITIONS/COMPOSITION/EXCIPIENS/UNIT").first.text).to eq "ml"
737
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680165980114']/NAME").first.text).to eq "W-Tropfen"
738
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680165980114']/GALENIC_FORM").last.text).to eq "Tropfen"
779
739
  end
780
740
 
781
- it 'should create correct entries for Coeur-Vaisseaux Sérocytol' do
782
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680002770014']/NAME").first.text).to eq "Coeur-Vaisseaux Sérocytol, suppositoire"
741
+ it "should create correct entries for Coeur-Vaisseaux Sérocytol" do
742
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680002770014']/NAME").first.text).to eq "Coeur-Vaisseaux Sérocytol, suppositoire"
783
743
  end
784
744
 
785
- it 'should not have Alprostadilum' do
786
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680545250363']").first).to eq nil
745
+ it "should not have Alprostadilum" do
746
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680545250363']").first).to eq nil
787
747
  end
788
748
 
789
- it 'should create correct entries for Ceftriaxonum' do
790
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680446250592']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SALTS/SALT/SUBSTANCE_NAME").first.text).to eq 'Ceftriaxonum Natricum'
791
-
749
+ it "should create correct entries for Ceftriaxonum" do
750
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680446250592']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE/SALTS/SALT/SUBSTANCE_NAME").first.text).to eq "Ceftriaxonum Natricum"
792
751
  end
793
752
 
794
- it 'should create correct entries for Nutriflex' do
795
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680611860045']/NAME").first.text).to eq 'Nutriflex Omega special, Infusionsemulsion 2500 ml'
796
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680611860045']/GALENIC_FORM").first.text).to eq 'Infusionsemulsion'
797
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680611860045']/SELLING_UNITS").first.text).to eq '5'
753
+ it "should create correct entries for Nutriflex" do
754
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680611860045']/NAME").first.text).to eq "Nutriflex Omega special, Infusionsemulsion 2500 ml"
755
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680611860045']/GALENIC_FORM").first.text).to eq "Infusionsemulsion"
756
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680611860045']/SELLING_UNITS").first.text).to eq "5"
798
757
  end
799
758
 
800
- it 'should create correct entries for Apligraf' do
801
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680589430011']/NAME").first.text).to eq 'Apligraf'
802
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680589430011']/GALENIC_FORM").last.text).to eq 'Unbekannt' # TODO?? 'Scheibe(n)/disque(s)'
759
+ it "should create correct entries for Apligraf" do
760
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680589430011']/NAME").first.text).to eq "Apligraf"
761
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680589430011']/GALENIC_FORM").last.text).to eq "Unbekannt" # TODO?? 'Scheibe(n)/disque(s)'
803
762
  end
804
763
 
805
- it 'should create correct entries for Caverject' do
806
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680556740075']/NAME").first.text).to eq "Caverject DC 20, Injektionspräparat"
807
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680556740075']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE").size).to eq 5
808
- expect(XPath.match( @doc, "//ARTICLE[GTIN='7680556740075']/COMPOSITIONS/COMPOSITION/EXCIPIENS/SUBSTANCE_NAME").first.text).to eq "pro Vitro"
764
+ it "should create correct entries for Caverject" do
765
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680556740075']/NAME").first.text).to eq "Caverject DC 20, Injektionspräparat"
766
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680556740075']/COMPOSITIONS/COMPOSITION/SUBSTANCES/SUBSTANCE").size).to eq 5
767
+ expect(REXML::XPath.match(@doc, "//ARTICLE[GTIN='7680556740075']/COMPOSITIONS/COMPOSITION/EXCIPIENS/SUBSTANCE_NAME").first.text).to eq "pro Vitro"
809
768
  end
810
769
  end
811
770
  end