oddb2xml 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.standard.yml +2 -0
- data/Gemfile +3 -3
- data/History.txt +8 -0
- data/README.md +1 -1
- data/Rakefile +24 -23
- data/bin/check_artikelstamm +11 -11
- data/bin/compare_v5 +23 -23
- data/bin/oddb2xml +14 -13
- data/lib/oddb2xml.rb +1 -1
- data/lib/oddb2xml/builder.rb +1070 -1038
- data/lib/oddb2xml/calc.rb +232 -233
- data/lib/oddb2xml/chapter_70_hack.rb +38 -32
- data/lib/oddb2xml/cli.rb +252 -236
- data/lib/oddb2xml/compare.rb +70 -59
- data/lib/oddb2xml/compositions_syntax.rb +448 -430
- data/lib/oddb2xml/compressor.rb +20 -20
- data/lib/oddb2xml/downloader.rb +153 -127
- data/lib/oddb2xml/extractor.rb +302 -289
- data/lib/oddb2xml/options.rb +34 -35
- data/lib/oddb2xml/parslet_compositions.rb +263 -269
- data/lib/oddb2xml/semantic_check.rb +39 -33
- data/lib/oddb2xml/util.rb +163 -163
- data/lib/oddb2xml/version.rb +1 -1
- data/lib/oddb2xml/xml_definitions.rb +32 -33
- data/oddb2xml.gemspec +31 -32
- data/spec/artikelstamm_spec.rb +111 -110
- data/spec/builder_spec.rb +489 -505
- data/spec/calc_spec.rb +552 -593
- data/spec/check_artikelstamm_spec.rb +26 -26
- data/spec/cli_spec.rb +173 -174
- data/spec/compare_spec.rb +9 -11
- data/spec/composition_syntax_spec.rb +390 -409
- data/spec/compressor_spec.rb +48 -48
- data/spec/data/transfer.dat +1 -0
- data/spec/data_helper.rb +47 -49
- data/spec/downloader_spec.rb +247 -260
- data/spec/extractor_spec.rb +171 -159
- data/spec/galenic_spec.rb +233 -256
- data/spec/options_spec.rb +116 -119
- data/spec/parslet_spec.rb +833 -861
- data/spec/spec_helper.rb +154 -153
- data/test_options.rb +39 -42
- data/tools/win_fetch_cacerts.rb +2 -3
- metadata +19 -3
data/spec/options_spec.rb
CHANGED
@@ -1,195 +1,192 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
4
2
|
require "#{Dir.pwd}/lib/oddb2xml/options"
|
5
3
|
|
4
|
+
Oddb2xml::DEFAULT_OPTS = {
|
5
|
+
fi: false,
|
6
|
+
address: false,
|
7
|
+
artikelstamm: false,
|
8
|
+
nonpharma: false,
|
9
|
+
extended: false,
|
10
|
+
compress_ext: nil,
|
11
|
+
format: :xml,
|
12
|
+
calc: false,
|
13
|
+
tag_suffix: nil,
|
14
|
+
ean14: false,
|
15
|
+
skip_download: false,
|
16
|
+
log: false,
|
17
|
+
percent: nil,
|
18
|
+
use_ra11zip: nil
|
19
|
+
}
|
20
|
+
|
6
21
|
describe Oddb2xml::Options do
|
7
22
|
include ServerMockHelper
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:artikelstamm => false,
|
12
|
-
:nonpharma => false,
|
13
|
-
:extended => false,
|
14
|
-
:compress_ext => nil,
|
15
|
-
:format => :xml,
|
16
|
-
:calc => false,
|
17
|
-
:tag_suffix => nil,
|
18
|
-
:ean14 => false,
|
19
|
-
:skip_download=> false,
|
20
|
-
:log => false,
|
21
|
-
:percent => nil,
|
22
|
-
:use_ra11zip => nil,
|
23
|
-
}
|
24
|
-
context 'when no options is passed' do
|
25
|
-
test_opts = Oddb2xml::Options.parse('-a')
|
26
|
-
opts = Default_opts.clone
|
23
|
+
context "when no options is passed" do
|
24
|
+
test_opts = Oddb2xml::Options.parse("-a")
|
25
|
+
opts = Oddb2xml::DEFAULT_OPTS.clone
|
27
26
|
opts[:nonpharma] = true
|
28
27
|
specify { expect(test_opts).to eq opts }
|
29
28
|
end
|
30
29
|
|
31
|
-
context
|
32
|
-
test_opts = Oddb2xml::Options.parse(
|
33
|
-
specify { expect(test_opts[:compress_ext]).to eq(
|
34
|
-
expected =
|
35
|
-
expected[:compress_ext] =
|
30
|
+
context "when -c tar.gz option is given" do
|
31
|
+
test_opts = Oddb2xml::Options.parse("-c tar.gz")
|
32
|
+
specify { expect(test_opts[:compress_ext]).to eq("tar.gz") }
|
33
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
34
|
+
expected[:compress_ext] = "tar.gz"
|
36
35
|
specify { expect(test_opts).to eq expected }
|
37
36
|
end
|
38
37
|
|
39
|
-
context
|
40
|
-
test_opts = Oddb2xml::Options.parse(
|
41
|
-
expected =
|
42
|
-
expected[:compress_ext] =
|
38
|
+
context "when -c tar.gz option --skip-download is given" do
|
39
|
+
test_opts = Oddb2xml::Options.parse("-c tar.gz --skip-download")
|
40
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
41
|
+
expected[:compress_ext] = "tar.gz"
|
43
42
|
expected[:skip_download] = true
|
44
43
|
specify { expect(test_opts).to eq expected }
|
45
44
|
end
|
46
45
|
|
47
|
-
context
|
48
|
-
test_opts = Oddb2xml::Options.parse(
|
49
|
-
expected =
|
50
|
-
expected[:compress_ext] =
|
46
|
+
context "when -c tar.gz option --skip-download is given" do
|
47
|
+
test_opts = Oddb2xml::Options.parse("-c tar.gz --skip-download")
|
48
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
49
|
+
expected[:compress_ext] = "tar.gz"
|
51
50
|
expected[:skip_download] = true
|
52
51
|
specify { expect(test_opts).to eq expected }
|
53
52
|
end
|
54
53
|
|
55
|
-
context
|
56
|
-
test_opts = Oddb2xml::Options.parse(
|
57
|
-
expected =
|
58
|
-
expected[:nonpharma] =
|
54
|
+
context "when -a is given" do
|
55
|
+
test_opts = Oddb2xml::Options.parse("-a")
|
56
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
57
|
+
expected[:nonpharma] = true
|
59
58
|
specify { expect(test_opts).to eq expected }
|
60
59
|
end
|
61
60
|
|
62
|
-
context
|
63
|
-
test_opts = Oddb2xml::Options.parse(
|
64
|
-
expected =
|
65
|
-
expected[:nonpharma] =
|
61
|
+
context "when --append is given" do
|
62
|
+
test_opts = Oddb2xml::Options.parse("--append ")
|
63
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
64
|
+
expected[:nonpharma] = true
|
66
65
|
specify { expect(test_opts).to eq expected }
|
67
66
|
end
|
68
67
|
|
69
|
-
context
|
70
|
-
test_opts = Oddb2xml::Options.parse(
|
71
|
-
expected =
|
72
|
-
expected[:extended]
|
73
|
-
expected[:nonpharma] =
|
74
|
-
expected[:calc]
|
75
|
-
expected[:price]
|
68
|
+
context "when -e is given" do
|
69
|
+
test_opts = Oddb2xml::Options.parse("-e")
|
70
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
71
|
+
expected[:extended] = true
|
72
|
+
expected[:nonpharma] = true
|
73
|
+
expected[:calc] = true
|
74
|
+
expected[:price] = :zurrose
|
76
75
|
specify { expect(test_opts).to eq expected }
|
77
76
|
end
|
78
77
|
|
79
|
-
context
|
80
|
-
test_opts = Oddb2xml::Options.parse(
|
81
|
-
expected =
|
82
|
-
expected[:extended]
|
83
|
-
expected[:nonpharma] =
|
84
|
-
expected[:calc]
|
85
|
-
expected[:price]
|
86
|
-
expected[:percent]
|
78
|
+
context "when -e -I 80 is given" do
|
79
|
+
test_opts = Oddb2xml::Options.parse("-e -I 80")
|
80
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
81
|
+
expected[:extended] = true
|
82
|
+
expected[:nonpharma] = true
|
83
|
+
expected[:calc] = true
|
84
|
+
expected[:price] = :zurrose
|
85
|
+
expected[:percent] = 80
|
87
86
|
specify { expect(test_opts).to eq expected }
|
88
87
|
end
|
89
88
|
|
90
|
-
context
|
91
|
-
test_opts = Oddb2xml::Options.parse(
|
92
|
-
expected =
|
93
|
-
expected[:format]
|
89
|
+
context "when -f dat is given" do
|
90
|
+
test_opts = Oddb2xml::Options.parse("-f dat")
|
91
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
92
|
+
expected[:format] = :dat
|
94
93
|
specify { expect(test_opts).to eq expected }
|
95
94
|
end
|
96
95
|
|
97
|
-
context
|
98
|
-
test_opts = Oddb2xml::Options.parse(
|
99
|
-
expected =
|
100
|
-
expected[:format]
|
96
|
+
context "when -f dat -I 80 is given" do
|
97
|
+
test_opts = Oddb2xml::Options.parse("-f dat -I 80")
|
98
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
99
|
+
expected[:format] = :dat
|
101
100
|
expected[:percent] = 80
|
102
|
-
expected[:price]
|
101
|
+
expected[:price] = :zurrose
|
103
102
|
specify { expect(test_opts).to eq expected }
|
104
103
|
end
|
105
104
|
|
106
|
-
context
|
107
|
-
test_opts = Oddb2xml::Options.parse(
|
108
|
-
expected =
|
109
|
-
expected[:percent]
|
110
|
-
expected[:price]
|
105
|
+
context "when -I 80 is given" do
|
106
|
+
test_opts = Oddb2xml::Options.parse("-I 80")
|
107
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
108
|
+
expected[:percent] = 80
|
109
|
+
expected[:price] = :zurrose
|
111
110
|
specify { expect(test_opts).to eq expected }
|
112
111
|
end
|
113
112
|
|
114
|
-
context
|
115
|
-
test_opts = Oddb2xml::Options.parse(
|
116
|
-
expected =
|
117
|
-
expected[:fi]
|
113
|
+
context "when -o is given" do
|
114
|
+
test_opts = Oddb2xml::Options.parse("-o")
|
115
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
116
|
+
expected[:fi] = true
|
118
117
|
specify { expect(test_opts).to eq expected }
|
119
118
|
end
|
120
119
|
|
121
|
-
context
|
122
|
-
test_opts = Oddb2xml::Options.parse(
|
123
|
-
expected =
|
124
|
-
expected[:ean14]
|
120
|
+
context "when -i ean14 is given" do
|
121
|
+
test_opts = Oddb2xml::Options.parse("-i ean14")
|
122
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
123
|
+
expected[:ean14] = true
|
125
124
|
specify { expect(test_opts).to eq expected }
|
126
125
|
end
|
127
126
|
|
128
|
-
context
|
129
|
-
test_opts = Oddb2xml::Options.parse(
|
130
|
-
expected =
|
131
|
-
expected[:address]
|
127
|
+
context "when -x addr is given" do
|
128
|
+
test_opts = Oddb2xml::Options.parse("-x addr")
|
129
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
130
|
+
expected[:address] = true
|
132
131
|
specify { expect(test_opts).to eq expected }
|
133
132
|
end
|
134
133
|
|
135
|
-
context
|
136
|
-
test_opts = Oddb2xml::Options.parse(
|
137
|
-
expected =
|
138
|
-
expected[:price]
|
134
|
+
context "when -p zurrose is given" do
|
135
|
+
test_opts = Oddb2xml::Options.parse("-p zurrose")
|
136
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
137
|
+
expected[:price] = :zurrose
|
139
138
|
specify { expect(test_opts).to eq expected }
|
140
139
|
end
|
141
140
|
|
142
|
-
context
|
143
|
-
test_opts = Oddb2xml::Options.parse(
|
144
|
-
expected =
|
145
|
-
expected[:fi]
|
146
|
-
expected[:log]
|
141
|
+
context "when -o fi --log is given" do
|
142
|
+
test_opts = Oddb2xml::Options.parse("-o fi --log")
|
143
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
144
|
+
expected[:fi] = true
|
145
|
+
expected[:log] = true
|
147
146
|
specify { expect(test_opts).to eq expected }
|
148
147
|
end
|
149
148
|
|
150
|
-
context
|
151
|
-
args =
|
149
|
+
context "when -a nonpharma -p zurrose is given" do
|
150
|
+
args = "-a nonpharma -p zurrose"
|
152
151
|
test_opts = Oddb2xml::Options.parse(args) # .should raise
|
153
|
-
expected =
|
154
|
-
expected[:price]
|
155
|
-
expected[:nonpharma]
|
152
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
153
|
+
expected[:price] = :zurrose
|
154
|
+
expected[:nonpharma] = true
|
156
155
|
specify { expect(test_opts).to eq expected }
|
157
156
|
end
|
158
157
|
|
159
|
-
context
|
160
|
-
args =
|
158
|
+
context "when --artikelstamm is given" do
|
159
|
+
args = "--artikelstamm"
|
161
160
|
test_opts = Oddb2xml::Options.parse(args) # .should raise
|
162
|
-
expected =
|
163
|
-
expected[:price]
|
164
|
-
expected[:extended]
|
165
|
-
expected[:artikelstamm]
|
161
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
162
|
+
expected[:price] = :zurrose
|
163
|
+
expected[:extended] = true
|
164
|
+
expected[:artikelstamm] = true
|
166
165
|
specify { expect(test_opts).to eq expected }
|
167
166
|
end
|
168
167
|
|
169
|
-
context
|
170
|
-
test_opts = Oddb2xml::Options.parse(
|
171
|
-
specify { expect(test_opts[:compress_ext]).to eq(
|
172
|
-
expected =
|
173
|
-
expected[:compress_ext] =
|
168
|
+
context "when -c tar.gz option is given" do
|
169
|
+
test_opts = Oddb2xml::Options.parse("-c tar.gz")
|
170
|
+
specify { expect(test_opts[:compress_ext]).to eq("tar.gz") }
|
171
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
172
|
+
expected[:compress_ext] = "tar.gz"
|
174
173
|
specify { expect(test_opts).to eq expected }
|
175
174
|
end
|
176
175
|
|
177
|
-
context
|
178
|
-
test_opts = Oddb2xml::Options.parse(
|
179
|
-
expected =
|
180
|
-
expected[:use_ra11zip] =
|
176
|
+
context "when --use-ra11zip is given" do
|
177
|
+
test_opts = Oddb2xml::Options.parse(" --use-ra11zip some_other_zip")
|
178
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
179
|
+
expected[:use_ra11zip] = "some_other_zip"
|
181
180
|
# expected[:price] = :zurrose
|
182
181
|
# expected[:extended] = true
|
183
182
|
# expected[:artikelstamm] = true
|
184
183
|
specify { expect(test_opts).to eq expected }
|
185
184
|
end
|
186
185
|
|
187
|
-
context
|
188
|
-
test_opts = Oddb2xml::Options.parse(
|
189
|
-
expected =
|
190
|
-
expected[:tag_suffix]
|
186
|
+
context "when -t swiss is given" do
|
187
|
+
test_opts = Oddb2xml::Options.parse("-t swiss")
|
188
|
+
expected = Oddb2xml::DEFAULT_OPTS.clone
|
189
|
+
expected[:tag_suffix] = "swiss"
|
191
190
|
specify { expect(test_opts).to eq expected }
|
192
191
|
end
|
193
|
-
|
194
192
|
end
|
195
|
-
|
data/spec/parslet_spec.rb
CHANGED
@@ -1,204 +1,189 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'pp'
|
1
|
+
require "pp"
|
4
2
|
VERBOSE_MESSAGES = false
|
5
|
-
require
|
3
|
+
require "spec_helper"
|
6
4
|
require "#{Dir.pwd}/lib/oddb2xml/parslet_compositions"
|
7
|
-
require
|
5
|
+
require "parslet/rig/rspec"
|
8
6
|
|
9
7
|
hostname = Socket.gethostbyname(Socket.gethostname).first
|
10
|
-
|
11
|
-
puts "hostname is #{hostname}
|
8
|
+
RUN_ALL_COMPOSITION_TESTS = false # /travis|localhost/i.match(hostname) != nil # takes about five minutes to run!
|
9
|
+
puts "hostname is #{hostname} RUN_ALL_COMPOSITION_TESTS #{RUN_ALL_COMPOSITION_TESTS}"
|
12
10
|
# Testing whether 8937 composition lines can be parsed. Found 380 errors in 293 seconds
|
13
11
|
# 520 examples, 20 failures, 1 pending
|
14
12
|
|
15
|
-
RunFailingSpec = true
|
16
|
-
|
17
|
-
describe ParseComposition do
|
18
|
-
to_add = %(
|
19
|
-
VERBOSE_MESSAGES = true
|
20
|
-
pp composition; binding.pry
|
21
|
-
)
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
if RunFailingSpec
|
26
|
-
end
|
27
|
-
|
28
13
|
describe ParseComposition do
|
29
14
|
context "should handle 66540 Tektrotyd, Markierungsbesteck" do
|
30
15
|
string = "conserv.: E 216, E 218, excipiens pro suppositorio."
|
31
16
|
composition = ParseComposition.from_string(string)
|
32
|
-
active_agent = ["hynic-[d-phe(1)", "tyr(3)-octeotridum]trifluoroacetum", "acidum ethylendiamini-n,n'-diaceticum"]
|
17
|
+
# active_agent = ["hynic-[d-phe(1)", "tyr(3)-octeotridum]trifluoroacetum", "acidum ethylendiamini-n,n'-diaceticum"]
|
33
18
|
|
34
19
|
active_substance = "HYNIC-[D-Phe(1)"
|
35
20
|
composition_text = "II) Durchstechflasche 2: acidum ethylendiamini-N,N'-diaceticum 10 mg, dinatrii phosphas dodecahydricus, natrii hydroxidum, pro vitro."
|
36
21
|
composition = ParseUtil.parse_compositions(composition_text, active_substance).first
|
37
22
|
|
38
|
-
specify { expect(
|
39
|
-
specify { expect(
|
40
|
-
specify { expect(
|
41
|
-
specify { expect(
|
23
|
+
specify { expect(composition.substances.size).to eq 3 }
|
24
|
+
specify { expect(composition.label).to eq "II" }
|
25
|
+
specify { expect(composition.excipiens.name).to match(/pro vitro/i) }
|
26
|
+
specify { expect(composition.substances.first.name).to eq "Acidum Ethylendiamini-n,n'-diaceticum" }
|
42
27
|
end
|
43
28
|
|
44
29
|
context "should handle excipiens" do
|
45
30
|
string = "conserv.: E 216, E 218, excipiens pro suppositorio."
|
46
31
|
composition = ParseComposition.from_string(string)
|
47
|
-
specify { expect(
|
48
|
-
specify { expect(
|
49
|
-
specify { expect(
|
50
|
-
specify { expect(
|
32
|
+
specify { expect(composition.substances.size).to eq 2 }
|
33
|
+
specify { expect(composition.label).to eq nil }
|
34
|
+
specify { expect(composition.excipiens.name).to match(/excipiens pro suppositorio/i) }
|
35
|
+
specify { expect(composition.substances.first.name).to eq "E 216" }
|
51
36
|
end
|
52
37
|
|
53
|
-
context
|
54
|
-
# def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
|
55
|
-
active_substance =
|
56
|
-
composition_text =
|
38
|
+
context "Shire Subcuvia" do
|
39
|
+
# def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
|
40
|
+
active_substance = "immunoglobulinum humanum normale"
|
41
|
+
composition_text = "proteina 160 mg cum immunoglobulinum humanum normale min. 95 %, glycinum, natrii chloridum, aqua ad iniectabilia, q.s. ad solutionem pro 1 ml."
|
57
42
|
composition = ParseUtil.parse_compositions(composition_text, active_substance).first
|
58
43
|
specify { expect(composition.substances.size).to eq 4 }
|
59
44
|
specify { expect(composition.label).to eq nil }
|
60
45
|
specify { expect(composition.label_description).to eq nil }
|
61
|
-
specify { expect(composition.substances[0].name).to eq
|
62
|
-
specify { expect(composition.substances[1].name).to eq
|
46
|
+
specify { expect(composition.substances[0].name).to eq "Proteina" }
|
47
|
+
specify { expect(composition.substances[1].name).to eq "Cum Immunoglobulinum Humanum Normale" }
|
63
48
|
specify { expect(composition.substances[0].is_active_agent).to eq false }
|
64
49
|
specify { expect(composition.substances[1].is_active_agent).to eq true }
|
65
50
|
end
|
66
51
|
|
67
|
-
context
|
68
|
-
# def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
|
69
|
-
active_substance =
|
70
|
-
composition_text =
|
52
|
+
context "Shire Fosrenol" do
|
53
|
+
# def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
|
54
|
+
active_substance = "lanthanum"
|
55
|
+
composition_text = "lanthanum 500 mg ut lanthani (III) carbonas hydricum, excipiens pro compresso."
|
71
56
|
composition = ParseUtil.parse_compositions(composition_text, active_substance).first
|
72
57
|
specify { expect(composition.substances.size).to eq 1 }
|
73
58
|
specify { expect(composition.label).to eq nil }
|
74
59
|
specify { expect(composition.label_description).to eq nil }
|
75
60
|
specify { expect(composition.substances[0].is_active_agent).to eq true }
|
76
|
-
specify { expect(composition.substances[0].name).to eq
|
61
|
+
specify { expect(composition.substances[0].name).to eq "Lanthanum 500 Mg Ut Lanthani (iii) Carbonas Hydricum" }
|
77
62
|
end
|
78
63
|
|
79
64
|
context "should return label with description" do
|
80
65
|
string = "I) Glucoselösung: glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg, acidum citricum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
|
81
66
|
composition = ParseComposition.from_string(string)
|
82
67
|
specify { expect(composition.substances.size).to eq 3 }
|
83
|
-
specify { expect(composition.label).to eq
|
84
|
-
specify { expect(composition.label_description).to eq
|
68
|
+
specify { expect(composition.label).to eq "I" }
|
69
|
+
specify { expect(composition.label_description).to eq "Glucoselösung" }
|
85
70
|
end
|
86
71
|
|
87
72
|
context "should handle label-description for Cyclacur" do
|
88
73
|
# 37987 1 Cyclacur, Dragées
|
89
74
|
string = "I) Weisse Dragées: estradioli valeras 2 mg, excipiens pro compresso obducto."
|
90
75
|
composition = ParseComposition.from_string(string)
|
91
|
-
specify { expect(
|
92
|
-
specify { expect(
|
93
|
-
specify { expect(
|
94
|
-
specify { expect(
|
76
|
+
specify { expect(composition.substances.size).to eq 1 }
|
77
|
+
specify { expect(composition.label).to eq "I" }
|
78
|
+
specify { expect(composition.label_description).to eq "Weisse Dragées" }
|
79
|
+
specify { expect(composition.substances.first.name).to eq "Estradioli Valeras" }
|
95
80
|
end
|
96
81
|
|
97
82
|
context "should handle label-description for Moviprep" do
|
98
83
|
# 61631 1 Moviprep Orange, Pulver
|
99
84
|
string = "A): macrogolum 3350 100 g, natrii sulfas anhydricus 7.5 g, natrii chloridum 2.691 g, kalii chloridum 1.015 g, arom.: aspartamum et alia, excipiens ad pulverem pro charta."
|
100
85
|
composition = ParseComposition.from_string(string)
|
101
|
-
specify { expect(
|
102
|
-
specify { expect(
|
103
|
-
specify { expect(
|
104
|
-
specify { expect(
|
86
|
+
specify { expect(composition.substances.size).to eq 6 }
|
87
|
+
specify { expect(composition.label).to eq "A" }
|
88
|
+
specify { expect(composition.label_description).to eq nil }
|
89
|
+
specify { expect(composition.substances.first.name).to eq "Macrogolum 3350" }
|
105
90
|
end
|
106
91
|
|
107
92
|
context "should handle 'LA 2x%" do
|
108
93
|
# 48473 1 Wala Echinacea-Mundspray, anthroposophisches Arzneimittel
|
109
94
|
string = "echinacea pallida ex herba LA 20% TM 10 g"
|
110
95
|
composition = ParseComposition.from_string(string)
|
111
|
-
specify { expect(
|
112
|
-
specify { expect(
|
96
|
+
specify { expect(composition.substances.size).to eq 1 }
|
97
|
+
specify { expect(composition.substances.first.name).to eq "Echinacea Pallida Ex Herba La 20% Tm" }
|
113
98
|
end
|
114
99
|
|
115
100
|
context "should handle 'CRM 197" do
|
116
101
|
# 1 Prevenar 13, Suspension in Fertigspritzen
|
117
102
|
string = "proteinum corynebacteriae diphtheriae CRM 197 ca. 32 µg"
|
118
103
|
composition = ParseComposition.from_string(string)
|
119
|
-
specify { expect(
|
120
|
-
specify { expect(
|
104
|
+
specify { expect(composition.substances.size).to eq 1 }
|
105
|
+
specify { expect(composition.substances.first.name).to eq "Proteinum Corynebacteriae Diphtheriae Crm 197" }
|
121
106
|
end
|
122
107
|
|
123
108
|
context "should handle ', Corresp. '" do
|
124
109
|
# 65427 1 Adlers Bronchialpastillen, Pastillen
|
125
110
|
string = "liquiritiae extractum ethanolicum liquidum corresp. acidum glycyrrhizinicum 2.0-2.6 mg, DER: 1.8-2.1:1, Corresp. massa siccata 19.67 mg, droserae extractum ethanolicum liquidum, ratio: 0.6:1, Corresp. massa siccata 0.42 mg, plantaginis folii extractum ethanolicum liquidum, ratio: 0.51:1, Corresp. massa siccata 1.9 mg, aromatica, natrii cyclamas, excipiens pro pastillo"
|
126
111
|
composition = ParseComposition.from_string(string)
|
127
|
-
specify { expect(
|
128
|
-
specify { expect(
|
112
|
+
specify { expect(composition.substances.size).to eq 6 }
|
113
|
+
specify { expect(composition.substances.first.name).to eq "Liquiritiae Extractum Ethanolicum Liquidum" }
|
129
114
|
end
|
130
115
|
|
131
116
|
context "should handle ',,'" do
|
132
117
|
# 52433 1 Botox 100 Allergan-Einheiten, Pulver zur Herstellung einer Injektionslösung
|
133
118
|
string = "Praeparatio cryodesiccata: toxinum botulinicum A 100 U. Botox,, albuminum humanum, natrii chloridum, pro vitro."
|
134
119
|
composition = ParseComposition.from_string(string)
|
135
|
-
specify { expect(
|
136
|
-
specify { expect(
|
137
|
-
specify { expect(
|
120
|
+
specify { expect(composition.substances.size).to eq 3 }
|
121
|
+
specify { expect(composition.substances.first.name).to eq "Toxinum Botulinicum A" }
|
122
|
+
specify { expect(composition.excipiens.name).to match(/vitro/i) }
|
138
123
|
end
|
139
124
|
|
140
125
|
context "should handle corresp. excipiens" do
|
141
126
|
string = "petasina 8 mg corresp. excipiens pro compresso obducto"
|
142
127
|
composition = ParseComposition.from_string(string)
|
143
|
-
specify { expect(
|
144
|
-
specify { expect(
|
145
|
-
specify { expect(
|
128
|
+
specify { expect(composition.substances.size).to eq 1 }
|
129
|
+
specify { expect(composition.substances.first.name).to eq "Petasina" }
|
130
|
+
specify { expect(composition.excipiens.name).to match(/excipiens/i) }
|
146
131
|
end
|
147
132
|
|
148
133
|
context "should handle missing Label A:) in pollinis allergeni extractu" do
|
149
134
|
# 62573 2 Staloral 300 3 Bäume (300 IR/ml) , sublinguale Lösung
|
150
|
-
string =
|
135
|
+
string = "III): pro usu: I) et II) recenter radioactivatum 99m-technetio ut natrii pertechnetas"
|
151
136
|
composition = ParseComposition.from_string(string)
|
152
|
-
specify { expect(composition.source).to eq string}
|
153
|
-
specify { expect(
|
154
|
-
specify { expect(
|
155
|
-
specify { expect(
|
137
|
+
specify { expect(composition.source).to eq string }
|
138
|
+
specify { expect(composition.substances.size).to eq 0 }
|
139
|
+
specify { expect(composition.label).to eq nil }
|
140
|
+
specify { expect(composition.corresp).to eq "III): pro usu: I) et II) recenter radioactivatum 99m-technetio ut natrii pertechnetas" }
|
156
141
|
end
|
157
142
|
|
158
143
|
context "should handle Tela cum praeparatione" do
|
159
|
-
string =
|
144
|
+
string = "Tela cum praeparatione (Panel 1): niccoli sulfas 0.16 mg, alcoholes adipis lanae 0.81 mg, neomycini sulfas 0.49 mg, kalii dichromas 44 µg, Cain-mix: benzocainum 0.364 mg, cinchocaini hydrochloridum 73 µg, tetracaini hydrochloridum 73 µg, Parfum-Mix: amylcinnamaldehydum 15 µg, isoeugenolum 15 µg, cinnamaldehydum 34 µg, eugenolum 34 µg, alcohol cinnamylicus 54 µg, hydroxycitronellalum 54 µg, geraniolum 70 µg, evernia prunastri 70 µg, colophonium 0.97 mg, E 320, E 321, Paraben-Mix: E 218 0.16 mg, E 214 0.16 mg, E 216 0.16 mg, butylis parahydroxybenzoas 0.16 mg, benzylis parahydroxybenzoas 0.16 mg, Negativ-Kontrolle, balsamum peruvianum 0.65 mg, ethylendiamini dihydrochloridum 41 µg, cobalti dichloridum 16 µg, excipiens pro praeparatione"
|
160
145
|
composition = ParseComposition.from_string(string)
|
161
|
-
specify { expect(composition.source).to eq string}
|
162
|
-
specify { expect(
|
163
|
-
specify { expect(
|
146
|
+
specify { expect(composition.source).to eq string }
|
147
|
+
specify { expect(composition.substances.first.name).to eq "Niccoli Sulfas" }
|
148
|
+
specify { expect(composition.label).to eq "Tela cum praeparatione (Panel 1):" }
|
164
149
|
end
|
165
150
|
|
166
151
|
context "should handle '&' and 'deklr.'" do
|
167
|
-
string =
|
152
|
+
string = "TM: cardiospermum halicacabum 100 mg, cetearyl octanoat & isopropylmyristat deklar., alcohol benzylicus, aqua q.s. ad unguentum pro"
|
168
153
|
composition = ParseComposition.from_string(string)
|
169
|
-
specify { expect(
|
154
|
+
specify { expect(composition.substances.first.name).to eq "Tm: Cardiospermum Halicacabum" }
|
170
155
|
end
|
171
156
|
|
172
157
|
context "should handle '150 U.I. hFSH et 150 U.I. hLH'" do
|
173
|
-
string =
|
158
|
+
string = "Praeparatio cryodesiccata: menotropinum 150 U.I. hFSH et 150 U.I. hLH, gonadotropinum chorionicum 7-21 U.I. hCG, lactosum monohydricum, pro vitro"
|
174
159
|
composition = ParseComposition.from_string(string)
|
175
|
-
specify { expect(composition.source).to eq string}
|
176
|
-
specify { expect(
|
177
|
-
specify { expect(
|
160
|
+
specify { expect(composition.source).to eq string }
|
161
|
+
specify { expect(composition.substances.first.name).to eq "Menotropinum" }
|
162
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "150 U.I. hFSH et 150 U.I. hLH" }
|
178
163
|
end
|
179
164
|
|
180
165
|
context "should handle missing arom.: before excipiens" do
|
181
166
|
string = "nicotinum 4 mg ut nicotini resinas, aromatica, antiox.: E 321, arom.: excipiens pro praeparatione"
|
182
167
|
composition = ParseComposition.from_string(string)
|
183
|
-
specify { expect(composition.source).to eq string}
|
168
|
+
specify { expect(composition.source).to eq string }
|
184
169
|
specify { expect(composition.substances.size).to eq 3 }
|
185
|
-
specify { expect(
|
170
|
+
specify { expect(composition.substances.first.name).to eq "Nicotinum" }
|
186
171
|
end
|
187
172
|
|
188
173
|
context "should handle missing Label A:) in pollinis allergeni extractu" do
|
189
174
|
# 62573 2 Staloral 300 3 Bäume (300 IR/ml) , sublinguale Lösung
|
190
|
-
string =
|
175
|
+
string = "pollinis allergeni extractum (alnus glutinosa, betula alba, corylus avellana) 300 U.: excipiens ad solutionem pro 1 ml"
|
191
176
|
composition = ParseComposition.from_string(string)
|
192
|
-
specify { expect(composition.source).to eq string}
|
193
|
-
specify { expect(
|
194
|
-
specify { expect(
|
195
|
-
specify { expect(
|
177
|
+
specify { expect(composition.source).to eq string }
|
178
|
+
specify { expect(composition.substances.size).to eq 1 }
|
179
|
+
specify { expect(composition.substances.first.name).to eq "Pollinis Allergeni Extractum (alnus Glutinosa, Betula Alba, Corylus Avellana)" }
|
180
|
+
specify { expect(composition.label).to eq nil }
|
196
181
|
end
|
197
182
|
|
198
183
|
context "handle 39541 A. Vogel Entspannungs-Tropfen" do
|
199
184
|
string = "passiflorae herbae recentis tinctura, ratio: 1:12, corresp. ethanolum 65 % V/V"
|
200
185
|
composition = ParseComposition.from_string(string)
|
201
|
-
specify { expect(composition.substances.size).to eq
|
186
|
+
specify { expect(composition.substances.size).to eq 1 }
|
202
187
|
specify { expect(composition.substances.first.name).to eq "Passiflorae Herbae Recentis Tinctura" }
|
203
188
|
specify { expect(composition.substances.first.more_info).to eq "ratio: 1:12" }
|
204
189
|
end
|
@@ -206,142 +191,142 @@ describe ParseComposition do
|
|
206
191
|
context "handle II) Aprotininlösung:" do
|
207
192
|
string = "II) Aprotininlösung: aprotininum 1000 U.K.I., natrii chloridum, aqua q.s. ad solutionem, pro vitro 1 ml"
|
208
193
|
composition = ParseComposition.from_string(string)
|
209
|
-
specify { expect(composition.substances.size).to eq
|
194
|
+
specify { expect(composition.substances.size).to eq 2 }
|
210
195
|
specify { expect(composition.substances.first.name).to eq "Aprotininum" }
|
211
196
|
end
|
212
197
|
|
213
198
|
context "handle ut aqua ad" do
|
214
|
-
string =
|
199
|
+
string = "natrii oleas ut aqua ad iniectabilia q.s. ad emulsionem pro 250 ml"
|
215
200
|
composition = ParseComposition.from_string(string)
|
216
|
-
specify { expect(composition.source).to eq string}
|
217
|
-
specify { expect(
|
218
|
-
specify { expect(
|
201
|
+
specify { expect(composition.source).to eq string }
|
202
|
+
specify { expect(composition.substances.size).to eq 1 }
|
203
|
+
specify { expect(composition.substances.first.name).to eq "Natrii Oleas" }
|
219
204
|
end
|
220
205
|
|
221
|
-
context
|
206
|
+
context "find unit for aqua q.s. ad emulsionem pro 250 ml" do
|
222
207
|
string = "natrii oleas, aqua q.s. ad emulsionem pro 250 ml."
|
223
208
|
composition = ParseComposition.from_string(string)
|
224
|
-
specify { expect(composition.source).to eq string}
|
225
|
-
specify { expect(composition.substances.size).to eq
|
226
|
-
specify { expect(
|
227
|
-
specify { expect(
|
209
|
+
specify { expect(composition.source).to eq string }
|
210
|
+
specify { expect(composition.substances.size).to eq 1 }
|
211
|
+
specify { expect(composition.excipiens.dose.to_s).to eq "250 ml" }
|
212
|
+
specify { expect(composition.excipiens.name).to match(/emulsionem/i) }
|
228
213
|
end
|
229
214
|
|
230
215
|
context "should handle '150 U.I. hFSH et 150 U.I. hLH'" do
|
231
|
-
string =
|
216
|
+
string = "Praeparatio cryodesiccata: menotropinum 150 U.I. hFSH et 150 U.I. hLH, gonadotropinum chorionicum 7-21 U.I. hCG, lactosum monohydricum, pro vitro"
|
232
217
|
composition = ParseComposition.from_string(string)
|
233
|
-
specify { expect(composition.source).to eq string}
|
234
|
-
specify { expect(
|
235
|
-
specify { expect(
|
218
|
+
specify { expect(composition.source).to eq string }
|
219
|
+
specify { expect(composition.substances.first.name).to eq "Menotropinum" }
|
220
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "150 U.I. hFSH et 150 U.I. hLH" }
|
236
221
|
end
|
237
222
|
|
238
223
|
context "should handle per centum" do
|
239
|
-
string =
|
224
|
+
string = "acidum nitricum 70 per centum 537 mg, acidum aceticum glaciale 20.4 mg, acidum oxalicum dihydricum 58.6 mg, zinci nitras hexahydricus 6 mg, excipiens ad solutionem pro 1 ml"
|
240
225
|
composition = ParseComposition.from_string(string)
|
241
|
-
specify { expect(composition.source).to eq string}
|
242
|
-
specify { expect(
|
226
|
+
specify { expect(composition.source).to eq string }
|
227
|
+
specify { expect(composition.substances.first.name).to eq "Acidum Nitricum 70 Per Centum" }
|
243
228
|
end
|
244
229
|
|
245
230
|
context "should handle 'potenziert mit: excipiens pro compresso'" do
|
246
|
-
string =
|
231
|
+
string = "ambra grisea D6 30 mg, conium maculatum D3 30 mg, anamirta cocculus D4 210 mg, petroleum rectificatum D8 30 mg, potenziert mit: excipiens pro compresso"
|
247
232
|
composition = ParseComposition.from_string(string)
|
248
|
-
specify { expect(composition.source).to eq string}
|
233
|
+
specify { expect(composition.source).to eq string }
|
249
234
|
specify { expect(composition.label).to eq nil }
|
250
235
|
specify { expect(composition.label_description).to eq nil }
|
251
236
|
specify { expect(composition.galenic_form).to eq nil }
|
252
237
|
specify { expect(composition.route_of_administration).to eq nil }
|
253
|
-
specify { expect(
|
238
|
+
specify { expect(composition.substances.first.name).to eq "Ambra Grisea D6" }
|
254
239
|
end
|
255
240
|
|
256
241
|
context "allow ut followed by et" do
|
257
242
|
# 49417 1 Burgerstein EPA-Kapseln 500mg, Kapseln
|
258
243
|
string =
|
259
|
-
"piscis oleum 500 mg corresp. acida carboxylica omega-3 oligoinsaturata 150 mg ut acidum eicosapentaenoicum 90 mg et acidum docosahexaenoicum 60 mg, excipiens pro capsula."
|
244
|
+
"piscis oleum 500 mg corresp. acida carboxylica omega-3 oligoinsaturata 150 mg ut acidum eicosapentaenoicum 90 mg et acidum docosahexaenoicum 60 mg, excipiens pro capsula."
|
260
245
|
composition = ParseComposition.from_string(string)
|
261
|
-
specify { expect(composition.substances.first.name).to eq
|
262
|
-
specify { expect(composition.substances.first.chemical_substance.name).to eq
|
263
|
-
specify { expect(composition.substances.size).to eq 2
|
264
|
-
specify { expect(composition.substances.first.salts.size).to eq
|
265
|
-
specify { expect(composition.substances.first.chemical_substance.salts.size).to eq
|
266
|
-
specify { expect(composition.substances.first.chemical_substance.salts.first.name).to eq
|
246
|
+
specify { expect(composition.substances.first.name).to eq "Piscis Oleum" } # TODO:
|
247
|
+
specify { expect(composition.substances.first.chemical_substance.name).to eq "Acida Carboxylica Omega-3 Oligoinsaturata" } # TODO:
|
248
|
+
specify { expect(composition.substances.size).to eq 2 }
|
249
|
+
specify { expect(composition.substances.first.salts.size).to eq 0 }
|
250
|
+
specify { expect(composition.substances.first.chemical_substance.salts.size).to eq 1 }
|
251
|
+
specify { expect(composition.substances.first.chemical_substance.salts.first.name).to eq "Acidum Eicosapentaenoicum" }
|
267
252
|
end
|
268
253
|
|
269
|
-
context
|
254
|
+
context "find correct result Solvens (i.m.)" do
|
270
255
|
string = "Solvens (i.m.): aqua ad iniectabilia 2 ml pro vitro"
|
271
256
|
composition = ParseComposition.from_string(string)
|
272
|
-
specify { expect(composition.substances.size).to eq
|
273
|
-
specify { expect(composition.corresp).to eq
|
257
|
+
specify { expect(composition.substances.size).to eq 0 }
|
258
|
+
specify { expect(composition.corresp).to eq "aqua ad iniectabilia 2 ml pro vitro" }
|
274
259
|
end
|
275
260
|
|
276
261
|
context "allow substancename with 'ethanol.'" do
|
277
262
|
string = "mandragora ethanol. decoctum D1 30 mg"
|
278
263
|
composition = ParseComposition.from_string(string)
|
279
|
-
specify { expect(composition.substances.size).to eq 1
|
280
|
-
specify { expect(composition.substances.first.name).to eq
|
281
|
-
specify { expect(composition.substances.first.dose.to_s).to eq
|
264
|
+
specify { expect(composition.substances.size).to eq 1 }
|
265
|
+
specify { expect(composition.substances.first.name).to eq "Mandragora Ethanol. Decoctum D1" }
|
266
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "30 mg" }
|
282
267
|
end
|
283
268
|
|
284
269
|
context "allow substance complicated, calculated dose '6.0 +/-1.2 µg'" do
|
285
270
|
string =
|
286
|
-
"enzephalitidis japanensis virus antigenum (Stamm: SA-14-2) 6.0 +/-1.2 µg, aluminium ut aluminii oxidum hydricum, kalii dihydrogenophosphas, dinatrii phosphas anhydricus, natrii chloridum, aqua q.s. ad solutionem pro 0.5 ml"
|
271
|
+
"enzephalitidis japanensis virus antigenum (Stamm: SA-14-2) 6.0 +/-1.2 µg, aluminium ut aluminii oxidum hydricum, kalii dihydrogenophosphas, dinatrii phosphas anhydricus, natrii chloridum, aqua q.s. ad solutionem pro 0.5 ml"
|
287
272
|
composition = ParseComposition.from_string(string)
|
288
|
-
specify { expect(composition.substances.first.name).to eq
|
289
|
-
specify { expect(composition.substances.first.chemical_substance).to eq
|
290
|
-
specify { expect(composition.substances.first.dose.to_s).to eq
|
291
|
-
specify { expect(composition.substances.size).to eq 5
|
273
|
+
specify { expect(composition.substances.first.name).to eq "Enzephalitidis Japanensis Virus Antigenum (stamm: Sa-14-2)" }
|
274
|
+
specify { expect(composition.substances.first.chemical_substance).to eq nil }
|
275
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "6.0 +/-1.2 µg/0.5 ml" }
|
276
|
+
specify { expect(composition.substances.size).to eq 5 }
|
292
277
|
end
|
293
278
|
|
294
279
|
context "should handle 'aqua ad iniectabilia ad solutionem'" do
|
295
280
|
string = "aqua ad iniectabilia ad solutionem"
|
296
281
|
composition = ParseComposition.from_string(string)
|
297
|
-
specify { expect(composition.substances.size).to eq
|
298
|
-
specify { expect(composition.corresp).to match
|
282
|
+
specify { expect(composition.substances.size).to eq 0 }
|
283
|
+
specify { expect(composition.corresp).to match(/ad iniectabilia/) }
|
299
284
|
end
|
300
285
|
|
301
286
|
context "should handle Corresp. ca. 8370 kJ" do
|
302
287
|
string = "Corresp. ca. 8370 kJ"
|
303
288
|
composition = ParseComposition.from_string(string)
|
304
|
-
specify { expect(composition.substances.size).to eq
|
305
|
-
specify { expect(composition.corresp).to match
|
289
|
+
specify { expect(composition.substances.size).to eq 0 }
|
290
|
+
specify { expect(composition.corresp).to match(/8370 kJ/i) }
|
306
291
|
end
|
307
292
|
|
308
293
|
context "should handle Praeparatio sicca and polysorbatum" do
|
309
|
-
string =
|
294
|
+
string = "Praeparatio sicca cum solvens: praeparatio sicca: albiglutidum 66.95 mg, trehalosum dihydricum, mannitolum, dinatrii phosphas anhydricus, natrii dihydrogenophosphas monohydricus, polysorbatum 80, solvens: aqua ad iniectabilia 0.65 ml pro vitro"
|
310
295
|
composition = ParseComposition.from_string(string)
|
311
|
-
specify { expect(composition.source).to eq string}
|
312
|
-
specify { expect(
|
313
|
-
specify { expect(
|
296
|
+
specify { expect(composition.source).to eq string }
|
297
|
+
specify { expect(composition.substances.first.name).to eq "Albiglutidum" }
|
298
|
+
specify { expect(composition.label).to eq "Praeparatio sicca cum solvens: praeparatio sicca:" }
|
314
299
|
end
|
315
300
|
|
316
301
|
context "handle placebo compressa: excipiens pro compresso obducto" do
|
317
302
|
string = "II) placebo compressa: excipiens pro compresso obducto"
|
318
303
|
composition = ParseComposition.from_string(string)
|
319
|
-
specify { expect(composition.substances.size).to eq
|
320
|
-
specify { expect(composition.label).to eq
|
321
|
-
specify { expect(composition.label_description).to eq
|
304
|
+
specify { expect(composition.substances.size).to eq 0 }
|
305
|
+
specify { expect(composition.label).to eq "II" }
|
306
|
+
specify { expect(composition.label_description).to eq "placebo compressa" }
|
322
307
|
end
|
323
308
|
|
324
309
|
context "handle 46489 Polvac Gräser+Roggen" do
|
325
310
|
string = "A): pollinis allergeni extractum 300 U. (secali cereale cum 12 gramina: Arrhenatherum elatius, Cynosurus cristatus, Dactylis glomerata, Lolium spp., Poa pratensis, Anthoxanthum odoratum, Festuca pratensis, Agrostis tenuis, Bromus ssp., Alopecurus pratensis, Phleum pratense, Holcus lanatus), tyrosinum, natrii chloridum, glycerolum, conserv.: phenolum 2.5 mg, aqua ad iniectabilia q.s. ad solutionem pro 0.5 ml."
|
326
311
|
composition = ParseComposition.from_string(string)
|
327
|
-
specify { expect(composition.substances.size).to eq
|
328
|
-
tyrosinum = composition.substances.find{ |x| /Tyrosinum/i.match(x.name) }
|
312
|
+
specify { expect(composition.substances.size).to eq 5 }
|
313
|
+
tyrosinum = composition.substances.find { |x| /Tyrosinum/i.match(x.name) }
|
329
314
|
specify { expect(composition.substances.first.name).to eq "Pollinis Allergeni Extractum 300 U. (secali Cereale Cum 12 Gramina: Arrhenatherum Elatius, Cynosurus Cristatus, Dactylis Glomerata, Lolium Spp., Poa Pratensis, Anthoxanthum Odoratum, Festuca Pratensis, Agrostis Tenuis, Bromus Ssp., Alopecurus Pratensis, Phleum Pratense, Holcus Lanatus)" }
|
330
|
-
specify { expect(tyrosinum.name).to eq
|
331
|
-
specify { expect(composition.label).to eq
|
315
|
+
specify { expect(tyrosinum.name).to eq "Tyrosinum" }
|
316
|
+
specify { expect(composition.label).to eq "A" }
|
332
317
|
end
|
333
318
|
|
334
319
|
context "handle ratio" do
|
335
|
-
|
336
|
-
"digestio aquosa 500 mg ex dryopteris filix-mas ex herba recenti 40 mg, pteridium aquilinum ex herba recenti 40 mg, polypodium vulgare ex herba recenti 10 mg, Phyllitis scolopendrium ex herba recenti 10 mg, ratio: 1:4,1, extractum ethanolicum 400 mg ex salicis albae folium recens 20 mg, salicis purpureae folium recens 20 mg, salicis viminalis folium recens 40 mg, salicis vitellinae folium recens 20 mg, ratio: 1:3,1, excipiens ad solutionem pro 1 g, corresp. 10 guttae, corresp. ethanolum 25 % V/V"
|
320
|
+
string =
|
321
|
+
"digestio aquosa 500 mg ex dryopteris filix-mas ex herba recenti 40 mg, pteridium aquilinum ex herba recenti 40 mg, polypodium vulgare ex herba recenti 10 mg, Phyllitis scolopendrium ex herba recenti 10 mg, ratio: 1:4,1, extractum ethanolicum 400 mg ex salicis albae folium recens 20 mg, salicis purpureae folium recens 20 mg, salicis viminalis folium recens 40 mg, salicis vitellinae folium recens 20 mg, ratio: 1:3,1, excipiens ad solutionem pro 1 g, corresp. 10 guttae, corresp. ethanolum 25 % V/V"
|
337
322
|
composition = ParseComposition.from_string(string)
|
338
|
-
substance = composition.substances.find{ |x| /Scolopendrium/i.match(x.name) }
|
339
|
-
specify { expect(substance.name).to eq
|
340
|
-
specify { expect(substance.more_info).to eq
|
323
|
+
substance = composition.substances.find { |x| /Scolopendrium/i.match(x.name) }
|
324
|
+
specify { expect(substance.name).to eq "Phyllitis Scolopendrium Ex Herba Recenti" }
|
325
|
+
specify { expect(substance.more_info).to eq "ratio: 1:4,1" }
|
341
326
|
end
|
342
327
|
|
343
328
|
context "should skip lines containing I) et II)" do
|
344
|
-
string =
|
329
|
+
string = "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"
|
345
330
|
composition = ParseComposition.from_string(string)
|
346
331
|
specify { expect(composition.source).to eq string }
|
347
332
|
specify { expect(composition.substances.size).to eq 0 }
|
@@ -349,57 +334,56 @@ describe ParseComposition do
|
|
349
334
|
end
|
350
335
|
|
351
336
|
context "should handle dose with /" do
|
352
|
-
string =
|
337
|
+
string = "poly(dl-lactidum-co-glycolidum) 75/25"
|
353
338
|
composition = ParseComposition.from_string(string)
|
354
|
-
specify { expect(composition.source).to eq string}
|
355
|
-
specify { expect(
|
356
|
-
specify { expect(
|
339
|
+
specify { expect(composition.source).to eq string }
|
340
|
+
specify { expect(composition.substances.first.name).to eq "Poly(dl-lactidum-co-glycolidum)" }
|
341
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "75/25" }
|
357
342
|
end
|
358
343
|
|
359
344
|
context "should handle dose with +/-" do
|
360
|
-
string =
|
345
|
+
string = "enzephalitidis japanensis virus antigenum (Stamm: SA-14-2) 6.0 +/-1.2 µg, aluminium ut aluminii oxidum hydricum, kalii dihydrogenophosphas, dinatrii phosphas anhydricus, natrii chloridum, aqua q.s. ad solutionem pro 0.5 ml"
|
361
346
|
composition = ParseComposition.from_string(string)
|
362
|
-
specify { expect(composition.source).to eq string}
|
363
|
-
specify { expect(
|
364
|
-
specify { expect(
|
347
|
+
specify { expect(composition.source).to eq string }
|
348
|
+
specify { expect(composition.substances.first.name).to eq "Enzephalitidis Japanensis Virus Antigenum (stamm: Sa-14-2)" }
|
349
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "6.0 +/-1.2 µg/0.5 ml" }
|
365
350
|
end
|
366
351
|
|
367
352
|
context "should handle label Praeparatio cryodesiccata (Thrombin)" do
|
368
|
-
string =
|
353
|
+
string = "Praeparatio cryodesiccata (Thrombin): thrombinum humanum 500 U.I., natrii chloridum, natrii citras dihydricus, pro vitro"
|
369
354
|
composition = ParseComposition.from_string(string)
|
370
|
-
specify { expect(composition.source).to eq string}
|
371
|
-
specify { expect(
|
372
|
-
specify { expect(
|
355
|
+
specify { expect(composition.source).to eq string }
|
356
|
+
specify { expect(composition.substances.first.name).to eq "Thrombinum Humanum" }
|
357
|
+
specify { expect(composition.label).to eq "Praeparatio cryodesiccata (Thrombin):" }
|
373
358
|
end
|
374
|
-
|
375
359
|
end
|
376
360
|
|
377
361
|
describe ParseComposition do
|
378
362
|
context "allow 2,2'-methylen-bis(6-tert.-butyl-4-methyl-phenolum)" do
|
379
363
|
string = "2,2'-methylen-bis(6-tert.-butyl-4-methyl-phenolum)"
|
380
364
|
composition = ParseComposition.from_string(string)
|
381
|
-
specify { expect(composition.substances.first.name).to eq
|
365
|
+
specify { expect(composition.substances.first.name).to eq "2,2'-methylen-bis(6-tert.-butyl-4-methyl-phenolum)" }
|
382
366
|
specify { expect(composition.substances.size).to eq 1 }
|
383
367
|
end
|
384
368
|
|
385
369
|
context "allow substancename with 90 % " do
|
386
370
|
string =
|
387
|
-
"acidum nitricum 70 per centum 580.66 mg, acidum aceticum glaciale 41.08 mg, acidum oxalicum dihydricum 57.32 mg, acidum lacticum 90 % 4.55 mg, cupri(II) nitras trihydricus 0.048 mg, excipiens ad solutionem pro 1 ml"
|
388
|
-
|
371
|
+
"acidum nitricum 70 per centum 580.66 mg, acidum aceticum glaciale 41.08 mg, acidum oxalicum dihydricum 57.32 mg, acidum lacticum 90 % 4.55 mg, cupri(II) nitras trihydricus 0.048 mg, excipiens ad solutionem pro 1 ml"
|
372
|
+
composition = ParseComposition.from_string(string)
|
389
373
|
specify { expect(composition.substances.size).to eq 5 }
|
390
|
-
substance = composition.substances.find{ |x| /lacticum/i.match(x.name) }
|
391
|
-
specify { expect(composition.substances.first.name).to eq
|
392
|
-
specify { expect(composition.substances.first.dose.to_s).to eq
|
393
|
-
specify { expect(substance.name).to eq
|
394
|
-
specify { expect(substance.dose.to_s).to eq
|
374
|
+
substance = composition.substances.find { |x| /lacticum/i.match(x.name) }
|
375
|
+
specify { expect(composition.substances.first.name).to eq "Acidum Nitricum 70 Per Centum" }
|
376
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "580.66 mg/ml" }
|
377
|
+
specify { expect(substance.name).to eq "Acidum Lacticum 90 %" }
|
378
|
+
specify { expect(substance.dose.to_s).to eq "4.55 mg/ml" }
|
395
379
|
end
|
396
380
|
|
397
381
|
context "allow substance with two corresp" do
|
398
382
|
string = "magnesii aspartas dihydricus 3.895 g corresp. magnesium 292 mg corresp. 12 mmol, arom.: bergamottae aetheroleum et alia, natrii cyclamas, saccharinum natricum, excipiens ad granulatum pro charta"
|
399
383
|
composition = ParseComposition.from_string(string)
|
400
384
|
context "with correct names" do
|
401
|
-
skip { expect(composition.substances.first.name).to eq
|
402
|
-
skip { expect(composition.substances.first.chemical_substance.name).to eq
|
385
|
+
skip { expect(composition.substances.first.name).to eq "Magnesii Aspartas Dihydricus" }
|
386
|
+
skip { expect(composition.substances.first.chemical_substance.name).to eq "Magnesium" }
|
403
387
|
end
|
404
388
|
specify { expect(composition.substances.size).to eq 6 }
|
405
389
|
end
|
@@ -414,707 +398,699 @@ describe ParseComposition do
|
|
414
398
|
string = "sennosida 20 mg corresp. sennosida A + B calcica 12 mg, excipiens pro compresso obducto"
|
415
399
|
composition = ParseComposition.from_string(string)
|
416
400
|
specify { expect(composition.substances.size).to eq 1 }
|
417
|
-
specify { expect(composition.substances.first.name).to eq
|
418
|
-
specify { expect(composition.substances.first.chemical_substance.name).to eq
|
401
|
+
specify { expect(composition.substances.first.name).to eq "Sennosida" }
|
402
|
+
specify { expect(composition.substances.first.chemical_substance.name).to eq "Sennosida A + B Calcica" }
|
419
403
|
end
|
420
404
|
|
421
405
|
context "allow substances separted by ', et'" do
|
422
406
|
string = "extractum spissum ex: echinaceae purpureae herbae recentis tinctura 1140 mg, ratio: 1:12, et echinaceae purpureae radicis recentis tinctura 60 mg, ratio: 1:11, excipiens pro compresso"
|
423
407
|
composition = ParseComposition.from_string(string)
|
424
408
|
specify { expect(composition.substances.size).to eq 2 }
|
425
|
-
specify { expect(composition.substances.first.name).to eq
|
426
|
-
specify { expect(composition.substances.last.name).to eq
|
409
|
+
specify { expect(composition.substances.first.name).to eq "Echinaceae Purpureae Herbae Recentis Tinctura" }
|
410
|
+
specify { expect(composition.substances.last.name).to eq "Echinaceae Purpureae Radicis Recentis Tinctura" }
|
427
411
|
end
|
428
412
|
|
429
|
-
context
|
413
|
+
context "find kalium 40 mmol/l" do
|
430
414
|
string = "kalium 40 mmol/l, chloridum 194 mmol/l, natrium 154 mmol/l, aqua ad iniectabilia q.s. ad solutionem pro 1000 ml"
|
431
415
|
composition = ParseComposition.from_string(string)
|
432
416
|
specify { expect(composition.substances.size).to eq 3 }
|
433
|
-
specify { expect(composition.substances.first.name).to eq
|
417
|
+
specify { expect(composition.substances.first.name).to eq "Kalium" }
|
434
418
|
specify { expect(composition.substances.first.dose.to_s).to eq "40 mmol/l/1000 ml" }
|
435
419
|
end
|
436
420
|
|
437
|
-
context
|
421
|
+
context "find corresp doses pro vase." do
|
438
422
|
string = "farfarae folii recentis succus ratio: 1:0.68-0.95"
|
439
423
|
composition = ParseComposition.from_string(string)
|
440
424
|
specify { expect(composition.substances.size).to eq 1 }
|
441
|
-
specify { expect(composition.substances.last.name).to eq
|
425
|
+
specify { expect(composition.substances.last.name).to eq "Farfarae Folii Recentis Succus" }
|
442
426
|
specify { expect(composition.substances.last.more_info).to eq "ratio: 1:0.68-0.95" }
|
443
427
|
end
|
444
428
|
|
445
|
-
context
|
429
|
+
context "find corresp doses pro vase." do
|
446
430
|
string = "doses pro vase 30/60"
|
447
431
|
composition = ParseComposition.from_string(string)
|
448
|
-
specify { expect(composition.substances.size).to eq
|
449
|
-
specify { expect(composition.corresp).to match
|
432
|
+
specify { expect(composition.substances.size).to eq 0 }
|
433
|
+
specify { expect(composition.corresp).to match(/pro vase/i) }
|
450
434
|
end
|
451
435
|
|
452
|
-
|
453
|
-
|
454
|
-
string = "sal ems 100 % m/m, corresp. ca., natrium 308.7 mg/g"
|
436
|
+
context "find corresp. ca." do
|
437
|
+
string = "sal ems 100 % m/m, corresp. ca., natrium 308.7 mg/g"
|
455
438
|
composition = ParseComposition.from_string(string)
|
456
439
|
specify { expect(composition.substances.size).to eq 1 }
|
457
|
-
specify { expect(composition.substances.last.name).to eq
|
440
|
+
specify { expect(composition.substances.last.name).to eq "Sal Ems" }
|
458
441
|
end
|
459
442
|
|
460
|
-
context
|
443
|
+
context "find correct result Solvens (i.m.)" do
|
461
444
|
string = "Solvens (i.v.): aqua ad iniectabilia 5 ml, corresp. 20 mg, pro 5 ml"
|
462
445
|
composition = ParseComposition.from_string(string)
|
463
|
-
specify { expect(composition.substances.first).to eq
|
446
|
+
specify { expect(composition.substances.first).to eq nil }
|
464
447
|
end
|
465
448
|
|
466
|
-
context
|
467
|
-
string
|
449
|
+
context "find correct result for dose 1 Mio U.I." do
|
450
|
+
string = "phenoxymethylpenicillinum kalicum 1 Mio U.I., conserv.: E 200, excipiens pro compresso obducto"
|
468
451
|
composition = ParseComposition.from_string(string)
|
469
452
|
specify { expect(composition.substances.size).to eq 2 }
|
470
|
-
specify { expect(composition.substances.first.name).to eq
|
471
|
-
specify { expect(composition.substances.first.dose.to_s).to eq
|
472
|
-
specify { expect(composition.substances.last.name).to eq
|
453
|
+
specify { expect(composition.substances.first.name).to eq "Phenoxymethylpenicillinum Kalicum" }
|
454
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "1 Mio U.I." }
|
455
|
+
specify { expect(composition.substances.last.name).to eq "E 200" }
|
473
456
|
end
|
474
457
|
|
475
|
-
context
|
476
|
-
string
|
458
|
+
context "find dose with max." do
|
459
|
+
string = "residui: formaldehydum max. 100 µg"
|
477
460
|
composition = ParseComposition.from_string(string)
|
478
|
-
specify { expect(composition.substances.size).to eq
|
479
|
-
specify { expect(composition.substances.last.name).to eq
|
461
|
+
specify { expect(composition.substances.size).to eq 1 }
|
462
|
+
specify { expect(composition.substances.last.name).to eq "Formaldehydum" }
|
480
463
|
end
|
481
464
|
|
482
|
-
context
|
483
|
-
composition = ParseComposition.from_string(
|
465
|
+
context "handle Corresp. 4000 kJ." do
|
466
|
+
composition = ParseComposition.from_string("Corresp. 4000 kJ.")
|
484
467
|
specify { expect(composition.substances.size).to eq 0 }
|
485
|
-
specify { expect(composition.corresp).to eq
|
468
|
+
specify { expect(composition.corresp).to eq "4000 kJ" }
|
486
469
|
end
|
487
470
|
|
488
|
-
context
|
489
|
-
string =
|
471
|
+
context "handle dose dose with g/dm²" do
|
472
|
+
string = "Tela cum unguento 14 g/dm²"
|
490
473
|
composition = ParseComposition.from_string(string)
|
491
474
|
specify { expect(composition.substances.size).to eq 1 }
|
492
|
-
specify { expect(composition.substances.first.dose.to_s).to eq
|
493
|
-
specify { expect(composition.substances.first.name).to eq
|
475
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "14 g/dm²" }
|
476
|
+
specify { expect(composition.substances.first.name).to eq "Tela Cum Unguento" }
|
494
477
|
end
|
495
478
|
|
496
|
-
context
|
497
|
-
string =
|
479
|
+
context "handle dose 2*10^9 CFU," do
|
480
|
+
string = "saccharomyces boulardii cryodesiccatus 250 mg corresp. cellulae vivae 2*10^9 CFU, excipiens pro capsula"
|
498
481
|
composition = ParseComposition.from_string(string)
|
499
482
|
specify { expect(composition.substances.size).to eq 1 }
|
500
|
-
specify { expect(composition.substances.first.chemical_substance.dose.to_s).to eq
|
501
|
-
specify { expect(composition.substances.first.name).to eq
|
483
|
+
specify { expect(composition.substances.first.chemical_substance.dose.to_s).to eq "2*10^9 CFU" }
|
484
|
+
specify { expect(composition.substances.first.name).to eq "Saccharomyces Boulardii Cryodesiccatus" }
|
502
485
|
end
|
503
486
|
|
504
|
-
context
|
487
|
+
context "handle dose followed by ratio" do
|
505
488
|
# 43996 1 Keppur, Salbe
|
506
489
|
string = "symphyti radicis recentis extractum ethanolicum liquidum 280 mg ratio: 1:3-4"
|
507
490
|
composition = ParseComposition.from_string(string)
|
508
491
|
specify { expect(composition.substances.size).to eq 1 }
|
509
|
-
specify { expect(composition.substances.first.name).to eq
|
492
|
+
specify { expect(composition.substances.first.name).to eq "Symphyti Radicis Recentis Extractum Ethanolicum Liquidum" }
|
510
493
|
end
|
511
494
|
|
512
|
-
context
|
513
|
-
string
|
495
|
+
context "find correct result Überzug: E 132" do
|
496
|
+
string = "olanzapinum 15 mg, Überzug: E 132, excipiens pro compresso obducto."
|
514
497
|
composition = ParseComposition.from_string(string)
|
515
498
|
specify { expect(composition.substances.size).to eq 2 }
|
516
|
-
specify { expect(composition.substances.first.name).to eq
|
517
|
-
specify { expect(composition.substances.last.name).to eq
|
518
|
-
specify { expect(composition.substances.last.more_info).to eq
|
499
|
+
specify { expect(composition.substances.first.name).to eq "Olanzapinum" }
|
500
|
+
specify { expect(composition.substances.last.name).to eq "E 132" }
|
501
|
+
specify { expect(composition.substances.last.more_info).to eq "Überzug" }
|
519
502
|
end
|
520
503
|
|
521
504
|
context "should handle ut followed by corresp. " do
|
522
505
|
# 65302 1 Exviera 250 mg, Filmtabletten
|
523
|
-
string =
|
506
|
+
string = "dasabuvirum 250 mg ut dasabuvirum natricum corresp. dasabuvirum natricum monohydricum 270.26 mg, excipiens pro compresso obducto"
|
524
507
|
composition = ParseComposition.from_string(string)
|
525
508
|
specify { expect(composition.label).to eq nil }
|
526
509
|
specify { expect(composition.label_description).to eq nil }
|
527
|
-
specify { expect(composition.substances.size).to eq 1
|
528
|
-
specify { expect(composition.substances.first.name).to eq
|
510
|
+
specify { expect(composition.substances.size).to eq 1 }
|
511
|
+
specify { expect(composition.substances.first.name).to eq "Dasabuvirum" }
|
529
512
|
specify { expect(composition.substances.first.salts.size).to eq 1 }
|
530
|
-
specify { expect(composition.substances.first.salts.first.name).to eq
|
531
|
-
specify { expect(composition.substances.first.salts.first.chemical_substance.name).to eq
|
513
|
+
specify { expect(composition.substances.first.salts.first.name).to eq "Dasabuvirum Natricum" }
|
514
|
+
specify { expect(composition.substances.first.salts.first.chemical_substance.name).to eq "Dasabuvirum Natricum Monohydricum" }
|
532
515
|
end
|
533
516
|
|
534
|
-
context
|
535
|
-
string
|
517
|
+
context "find correct result for ut excipiens" do
|
518
|
+
string = "drospirenonum 3 mg, ethinylestradiolum 20 µg ut excipiens pro compresso obducto"
|
536
519
|
composition = ParseComposition.from_string(string)
|
537
520
|
specify { expect(composition.substances.size).to eq 2 }
|
538
|
-
specify { expect(composition.substances.last.name).to eq
|
521
|
+
specify { expect(composition.substances.last.name).to eq "Ethinylestradiolum" }
|
539
522
|
end
|
540
523
|
|
541
|
-
context
|
524
|
+
context "find correct result compositions for DER: followed by corresp." do
|
542
525
|
# 16863 1 Salvia Wild, Tropfen
|
543
|
-
string
|
526
|
+
string = "salviae extractum ethanolicum liquidum, DER: 1:4.2-5.0 corresp. ethanolum 40 % V/V"
|
544
527
|
composition = ParseComposition.from_string(string)
|
545
528
|
specify { expect(composition.substances.size).to eq 2 }
|
546
|
-
specify { expect(composition.substances[1].name).to eq
|
529
|
+
specify { expect(composition.substances[1].name).to eq "DER: 1:4.2-5.0" }
|
547
530
|
end
|
548
531
|
|
549
|
-
|
550
|
-
context 'find correct result compositions for 00613 Pentavac' do
|
532
|
+
context "find correct result compositions for 00613 Pentavac" do
|
551
533
|
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."
|
552
534
|
line_2 = "II) Hib-Komponente (Lyophilisat): haemophilus influenzae Typ B polysaccharida T-conjugatum 10 µg, trometamolum, saccharum, pro praeparatione."
|
553
535
|
txt = "#{line_1}\n#{line_2}"
|
554
|
-
composition = ParseComposition.from_string(line_1)
|
555
|
-
composition = ParseComposition.from_string(line_2)
|
536
|
+
# composition = ParseComposition.from_string(line_1)
|
537
|
+
# composition = ParseComposition.from_string(line_2)
|
556
538
|
info = ParseUtil.parse_compositions(txt)
|
557
539
|
|
558
|
-
specify { expect(info.first.label).to eq
|
559
|
-
specify { expect(info.size).to eq
|
560
|
-
specify { expect(info.first.substances.size).to eq
|
561
|
-
toxoidum =
|
562
|
-
specify { expect(toxoidum.class).to eq
|
540
|
+
specify { expect(info.first.label).to eq "I" }
|
541
|
+
specify { expect(info.size).to eq 2 }
|
542
|
+
specify { expect(info.first.substances.size).to eq 14 }
|
543
|
+
toxoidum = info.first.substances.find { |x| x.name.match(/Toxoidum Diphtheriae/i) }
|
544
|
+
specify { expect(toxoidum.class).to eq ParseSubstance }
|
563
545
|
if toxoidum
|
564
|
-
specify { expect(toxoidum.name).to eq
|
565
|
-
specify { expect(toxoidum.qty.to_f).to eq
|
566
|
-
specify { expect(toxoidum.unit).to eq
|
546
|
+
specify { expect(toxoidum.name).to eq "Toxoidum Diphtheriae" }
|
547
|
+
specify { expect(toxoidum.qty.to_f).to eq 30.0 }
|
548
|
+
specify { expect(toxoidum.unit).to eq "U.I./0.5 ml" }
|
567
549
|
end
|
568
550
|
end
|
569
551
|
|
570
|
-
context
|
571
|
-
string =
|
552
|
+
context "find correct result compositions for fluticasoni with chemical_dose" do
|
553
|
+
string = "fluticasoni-17 propionas 100 µg, lactosum monohydricum q.s. ad pulverem pro 25 mg."
|
572
554
|
composition = ParseComposition.from_string(string)
|
573
555
|
specify { expect(composition.substances.size).to eq 2 }
|
574
|
-
fluticasoni =
|
575
|
-
specify { expect(fluticasoni.name).to eq
|
576
|
-
specify { expect(fluticasoni.qty.to_f).to eq
|
577
|
-
specify { expect(fluticasoni.unit).to eq
|
578
|
-
specify { expect(fluticasoni.dose.to_s).to eq
|
579
|
-
lactosum =
|
556
|
+
fluticasoni = composition.substances.find { |x| x.name.match(/Fluticasoni/i) }
|
557
|
+
specify { expect(fluticasoni.name).to eq "Fluticasoni-17 Propionas" }
|
558
|
+
specify { expect(fluticasoni.qty.to_f).to eq 100.0 }
|
559
|
+
specify { expect(fluticasoni.unit).to eq "µg/25 mg" }
|
560
|
+
specify { expect(fluticasoni.dose.to_s).to eq "100 µg/25 mg" }
|
561
|
+
lactosum = composition.substances.find { |x| x.name.match(/Lactosum/i) }
|
580
562
|
specify { expect(lactosum.name).to eq "Lactosum Monohydricum" }
|
581
|
-
skip { expect(lactosum.dose.to_s).to eq
|
563
|
+
skip { expect(lactosum.dose.to_s).to eq "25 mg" }
|
582
564
|
end
|
583
565
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
566
|
+
context "find correct result Solvens (i.m.)" do
|
567
|
+
string = "Solvens (i.m.): aqua ad iniectabilia 2 ml pro vitro"
|
568
|
+
composition = ParseComposition.from_string(string)
|
569
|
+
specify { expect(composition.substances.size).to eq 0 }
|
570
|
+
specify { expect(composition.corresp).to eq "aqua ad iniectabilia 2 ml pro vitro" }
|
571
|
+
end
|
590
572
|
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
573
|
+
context "should handle Iscador" do
|
574
|
+
# 56829 sequence 3 Iscador M
|
575
|
+
string = "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."
|
576
|
+
composition = ParseComposition.from_string(string)
|
577
|
+
viscum = composition.substances.find { |x| x.name.match(/viscum/i) }
|
578
|
+
specify { expect(viscum.name).to eq "Extractum Aquosum Liquidum Fermentatum 0.05 Mg Ex Viscum Album (mali) Recens" }
|
579
|
+
specify { expect(viscum.qty).to eq 0.01 } # 0.0001 mg/ml
|
580
|
+
specify { expect(viscum.unit).to eq "mg/ml" } # 0.0001 mg/ml
|
581
|
+
specify { expect(viscum.dose.qty).to eq 0.01 } # 0.0001 mg/ml
|
582
|
+
specify { expect(viscum.dose.unit).to eq "mg/ml" } # 0.0001 mg/ml
|
583
|
+
specify { expect(viscum.dose.to_s).to eq "0.01 mg/ml" } # 0.0001 mg/ml
|
584
|
+
specify { expect(composition.source).to eq string }
|
585
|
+
end
|
604
586
|
|
605
|
-
context
|
587
|
+
context "find correct result compositions for poloxamerum" do
|
606
588
|
# 47657 1 Nanocoll, Markierungsbesteck
|
607
589
|
string = "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."
|
608
590
|
composition = ParseComposition.from_string(string)
|
609
591
|
specify { expect(composition.substances.size).to eq 6 }
|
610
|
-
poloxamerum =
|
611
|
-
specify { expect(poloxamerum.name).to eq
|
612
|
-
specify { expect(poloxamerum.qty.to_f).to eq
|
613
|
-
specify { expect(poloxamerum.unit).to eq
|
592
|
+
poloxamerum = composition.substances.find { |x| x.name.match(/poloxamerum/i) }
|
593
|
+
specify { expect(poloxamerum.name).to eq "Poloxamerum 238" }
|
594
|
+
specify { expect(poloxamerum.qty.to_f).to eq 0.0 }
|
595
|
+
specify { expect(poloxamerum.unit).to eq nil }
|
614
596
|
end
|
615
597
|
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
598
|
+
context "should handle DER followed by corresp" do
|
599
|
+
# 54024 1 Nieren- und Blasendragées S
|
600
|
+
string = "DER: 4-5:1, corresp. arbutinum 24-30 mg"
|
601
|
+
composition = ParseComposition.from_string(string)
|
602
|
+
specify { expect(composition.source).to eq string }
|
603
|
+
specify { expect(composition.label).to eq nil }
|
604
|
+
specify { expect(composition.label_description).to eq nil }
|
605
|
+
specify { expect(composition.substances.size).to eq 1 }
|
606
|
+
specify { expect(composition.substances.first.name).to eq "DER: 4-5:1" }
|
607
|
+
specify { expect(composition.substances.first.chemical_substance.name).to eq "Arbutinum" }
|
608
|
+
end
|
627
609
|
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
610
|
+
context "should handle 'A): macrogolum 3350 100 g'" do
|
611
|
+
# 57900 1 Moviprep, Pulver
|
612
|
+
string = "A): macrogolum 3350 100 g, natrii sulfas anhydricus 7.5 g"
|
613
|
+
composition = ParseComposition.from_string(string)
|
614
|
+
specify { expect(composition.source).to eq string }
|
615
|
+
specify { expect(composition.label).to eq "A" }
|
616
|
+
specify { expect(composition.label_description).to eq nil }
|
617
|
+
specify { expect(composition.substances.size).to eq 2 }
|
618
|
+
specify { expect(composition.substances.first.name).to eq "Macrogolum 3350" }
|
619
|
+
specify { expect(composition.substances.first.qty).to eq 100 }
|
620
|
+
specify { expect(composition.substances.first.unit).to eq "g" }
|
621
|
+
end
|
640
622
|
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
623
|
+
context "should able to handle a simple ratio" do
|
624
|
+
string = "allii sativi maceratum oleosum 270 mg, ratio: 1:10, excipiens pro capsula."
|
625
|
+
composition = ParseComposition.from_string(string)
|
626
|
+
specify { expect(composition.source).to eq string }
|
627
|
+
specify { expect(composition.substances.size).to eq 1 }
|
628
|
+
specify { expect(composition.substances.first.name).to eq "Allii Sativi Maceratum Oleosum" }
|
629
|
+
specify { expect(composition.substances.first.more_info).to eq "ratio: 1:10" }
|
630
|
+
end
|
649
631
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
632
|
+
context "should able to handle multiple ratio" do
|
633
|
+
# 25273 1 Schoenenberger naturreiner Heilpflanzensaft, Thymian
|
634
|
+
string = "thymi herbae recentis extractum aquosum liquidum, ratio: 1:1.5-2.4."
|
635
|
+
composition = ParseComposition.from_string(string)
|
636
|
+
specify { expect(composition.source).to eq string }
|
637
|
+
specify { expect(composition.substances.size).to eq 1 }
|
638
|
+
specify { expect(composition.substances.first.name).to eq "Thymi Herbae Recentis Extractum Aquosum Liquidum" }
|
639
|
+
specify { expect(composition.substances.first.more_info).to eq "ratio: 1:1.5-2.4" }
|
640
|
+
end
|
659
641
|
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
642
|
+
context "should handles lines containing V): mannitolum 40 mg pro dosi" do
|
643
|
+
string = "V): mannitolum 40 mg pro dosi"
|
644
|
+
composition = ParseComposition.from_string(string)
|
645
|
+
specify { expect(composition.source).to eq string }
|
646
|
+
specify { expect(composition.label).to eq "V" }
|
647
|
+
specify { expect(composition.substances.size).to eq 1 }
|
648
|
+
end
|
667
649
|
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
650
|
+
context "should treat correctly CFU units" do
|
651
|
+
# 56015 Perskindol Cool avec consoude, gel
|
652
|
+
string = "lactobacillus acidophilus cryodesiccatus min. 10^9 CFU"
|
653
|
+
composition = ParseComposition.from_string(string)
|
654
|
+
specify { expect(composition.substances.first.name).to eq "Lactobacillus Acidophilus Cryodesiccatus" }
|
655
|
+
specify { expect(composition.substances.first.qty).to eq "10^9" }
|
656
|
+
specify { expect(composition.substances.first.unit).to eq "CFU" }
|
657
|
+
end
|
676
658
|
|
677
|
-
|
659
|
+
context "should pass several () inside a name" do
|
678
660
|
composition = nil
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
composition = ParseComposition.from_string(string)
|
692
|
-
}
|
693
|
-
composition = ParseComposition.from_string(strings.last + ' 15 µg')
|
694
|
-
specify { expect(composition.substances.first.name.downcase).to eq strings.last.downcase }
|
695
|
-
specify { expect(composition.substances.first.qty).to eq 15 }
|
696
|
-
specify { expect(composition.substances.first.unit).to eq 'µg' }
|
697
|
-
end
|
698
|
-
|
699
|
-
context "should emit correct unit when excipiens contains pro X ml" do
|
700
|
-
string = 'glatiramerum acetas 20 mg corresp. glatiramerum 18 mg, mannitolum, aqua ad iniectabilia q.s. ad solutionem pro 0.5 ml.'
|
661
|
+
strings = [
|
662
|
+
"a(eine klammer) und nachher",
|
663
|
+
"(eine klammer) und nachher",
|
664
|
+
"haemagglutininum influenzae A (eine klammer)",
|
665
|
+
"haemagglutininum influenzae A (eine klammer) und nachher",
|
666
|
+
"haemagglutininum influenzae A (H1N1) (in Klammer)",
|
667
|
+
"haemagglutininum influenzae A (H1N1) or (H5N3) (in Klammer) more",
|
668
|
+
"haemagglutininum influenzae A (H1N1) eins (second) even more",
|
669
|
+
"ab (H1N1)-like: dummy",
|
670
|
+
"Virus-Stamm A/California/7/2009 (H1N1)-like: reassortant virus NYMC X-179A",
|
671
|
+
"haemagglutininum influenzae A (H1N1) (Virus-Stamm A/California/7/2009 (H1N1)-like: reassortant virus NYMC X-179A)"
|
672
|
+
].each { |string|
|
701
673
|
composition = ParseComposition.from_string(string)
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
specify { expect(composition.substances.first.chemical_substance.unit).to eq 'mg/0.5 ml' }
|
709
|
-
end
|
674
|
+
}
|
675
|
+
composition = ParseComposition.from_string(strings.last + " 15 µg")
|
676
|
+
specify { expect(composition.substances.first.name.downcase).to eq strings.last.downcase }
|
677
|
+
specify { expect(composition.substances.first.qty).to eq 15 }
|
678
|
+
specify { expect(composition.substances.first.unit).to eq "µg" }
|
679
|
+
end
|
710
680
|
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
681
|
+
context "should emit correct unit when excipiens contains pro X ml" do
|
682
|
+
string = "glatiramerum acetas 20 mg corresp. glatiramerum 18 mg, mannitolum, aqua ad iniectabilia q.s. ad solutionem pro 0.5 ml."
|
683
|
+
composition = ParseComposition.from_string(string)
|
684
|
+
specify { expect(composition.substances.first.name).to eq "Glatiramerum Acetas" }
|
685
|
+
specify { expect(composition.substances.first.qty).to eq 20 }
|
686
|
+
specify { expect(composition.substances.first.unit).to eq "mg/0.5 ml" }
|
687
|
+
specify { expect(composition.substances.first.chemical_substance.unit).to eq "mg/0.5 ml" }
|
688
|
+
specify { expect(composition.substances.first.chemical_substance.name).to eq "Glatiramerum" }
|
689
|
+
specify { expect(composition.substances.first.chemical_substance.qty).to eq 18 }
|
690
|
+
specify { expect(composition.substances.first.chemical_substance.unit).to eq "mg/0.5 ml" }
|
691
|
+
end
|
718
692
|
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
# TODO: specify { expect(composition.substances.first.dose.to_s).to eq '9 g/L 5 ml' }
|
727
|
-
end
|
693
|
+
context "should handle substance with a range" do
|
694
|
+
string = "glyceroli monostearas 40-55"
|
695
|
+
composition = ParseComposition.from_string(string)
|
696
|
+
specify { expect(composition.substances.size).to eq 1 }
|
697
|
+
specify { expect(composition.substances.first.name).to eq "Glyceroli Monostearas" }
|
698
|
+
specify { expect(composition.substances.first.dose.to_s).to eq "40-55" }
|
699
|
+
end
|
728
700
|
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
specify { expect(substance.unit).to eq 'mg' }
|
739
|
-
specify { expect(composition.substances.first.name).to eq 'Calcium' } # TODO:
|
740
|
-
# TODO: specify { expect(composition.substances.first.dose.to_s).to eq '9 g/L 5 ml' }
|
741
|
-
end
|
701
|
+
context "should handle mineralia with alia" do
|
702
|
+
string = "mineralia: calcium 160 ut alia: ginseng extractum 50 mg"
|
703
|
+
composition = ParseComposition.from_string(string)
|
704
|
+
specify { expect(composition.substances.size).to eq 2 }
|
705
|
+
specify { expect(composition.substances.first.salts.size).to eq 0 }
|
706
|
+
specify { expect(composition.substances.first.name).to eq "Calcium" } # TODO:
|
707
|
+
specify { expect(composition.substances.last.name).to eq "Ginseng Extractum" } # TODO:
|
708
|
+
# TODO: specify { expect(composition.substances.first.dose.to_s).to eq '9 g/L 5 ml' }
|
709
|
+
end
|
742
710
|
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
711
|
+
context "should handle mineralia" do
|
712
|
+
string = "mineralia: calcium 160 mg ut magnesium 120 mg ut ferrum 5.6 mg ut cuprum 1 mg ut manganum 1.4 mg ut iodum 60 µg ut molybdenum 60 µg"
|
713
|
+
composition = ParseComposition.from_string(string)
|
714
|
+
specify { expect(composition.substances.size).to eq 1 }
|
715
|
+
specify { expect(composition.substances.first.more_info).to eq "mineralia" }
|
716
|
+
specify { expect(composition.substances.first.salts.size).to eq 6 }
|
717
|
+
substance = composition.substances.first.salts.find { |x| /Magnesium/i.match(x.name) }
|
718
|
+
specify { expect(substance.name).to eq "Magnesium" }
|
719
|
+
specify { expect(substance.qty).to eq 120.0 }
|
720
|
+
specify { expect(substance.unit).to eq "mg" }
|
721
|
+
specify { expect(composition.substances.first.name).to eq "Calcium" } # TODO:
|
722
|
+
# TODO: specify { expect(composition.substances.first.dose.to_s).to eq '9 g/L 5 ml' }
|
723
|
+
end
|
750
724
|
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
specify { expect(globulina.is_active_agent).to eq true }
|
759
|
-
specify { expect(globulina.qty).to eq 8 }
|
760
|
-
specify { expect(globulina.unit).to eq 'mg' }
|
761
|
-
end
|
725
|
+
context "should handle Solvens line" do
|
726
|
+
string = "Solvens: natrii chloridi solutio 9 g/L 5 ml."
|
727
|
+
composition = ParseComposition.from_string(string)
|
728
|
+
specify { expect(composition.substances.size).to eq 0 }
|
729
|
+
specify { expect(composition.corresp).to eq "natrii chloridi solutio 9 g/L 5 ml" }
|
730
|
+
skip { expect(composition.excipiens.substance.name).to eq "Natrii Chloridi Solutio" }
|
731
|
+
end
|
762
732
|
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
733
|
+
context "should parse a complex composition" do
|
734
|
+
composition = ParseUtil.parse_compositions(
|
735
|
+
"globulina equina (immunisé avec coeur) 8 mg",
|
736
|
+
"globulina equina (immunisé avec coeur)"
|
737
|
+
).first
|
738
|
+
specify { expect(composition.substances.size).to eq 1 }
|
739
|
+
globulina = composition.substances.find { |x| /globulina/i.match(x.name) }
|
740
|
+
specify { expect(globulina.name).to eq "Globulina Equina (immunisé Avec Coeur)" }
|
741
|
+
specify { expect(globulina.is_active_agent).to eq true }
|
742
|
+
specify { expect(globulina.qty).to eq 8 }
|
743
|
+
specify { expect(globulina.unit).to eq "mg" }
|
744
|
+
end
|
745
|
+
|
746
|
+
context "should parse globulina equina (immunise" do
|
747
|
+
composition = ParseUtil.parse_compositions(
|
748
|
+
"globulina equina (immunisé avec coeur, Tissu Pulmonaire, Reins De Porcins) 8 mg",
|
749
|
+
"globulina equina (immunisé avec coeur, Tissu Pulmonaire, Reins De Porcins)"
|
750
|
+
).first
|
751
|
+
specify { expect(composition.substances.size).to eq 1 }
|
752
|
+
globulina = composition.substances.find { |x| /globulina/i.match(x.name) }
|
753
|
+
specify { expect(globulina.name).to eq "Globulina Equina (immunisé Avec Coeur, Tissu Pulmonaire, Reins De Porcins)" }
|
754
|
+
specify { expect(globulina.is_active_agent).to eq true }
|
755
|
+
specify { expect(globulina.qty).to eq 8 }
|
756
|
+
specify { expect(globulina.unit).to eq "mg" }
|
757
|
+
end
|
774
758
|
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
759
|
+
context "should return correct composition for containing '(acarus siro)" do
|
760
|
+
string = "acari allergeni extractum (acarus siro) 50'000 U., conserv.: phenolum, excipiens ad solutionem pro 1 ml."
|
761
|
+
composition = ParseComposition.from_string(string)
|
762
|
+
specify { expect(composition.source).to eq string }
|
763
|
+
specify { expect(composition.substances.size).to eq 2 } # got only 1
|
764
|
+
specify { expect(composition.substances.first.more_info).to eq nil }
|
765
|
+
specify { expect(composition.substances.first.name).to eq "Acari Allergeni Extractum (acarus Siro)" }
|
766
|
+
specify { expect(composition.substances.last.name).to eq "Phenolum" } # was Acari Allergeni Extractum (acarus Siro)
|
767
|
+
specify { expect(composition.substances.last.more_info).to match "conserv" }
|
768
|
+
end
|
785
769
|
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
770
|
+
context "should return correct composition for containing 'A): acari allergeni extractum 50 U' (IKSNR 60606)" do
|
771
|
+
# Novo-Helisen Depot D. farinae/D. pteronyssinus Kombipackung 1-3, Injektionssuspension
|
772
|
+
string =
|
773
|
+
"A): acari allergeni extractum 50 U.: dermatophagoides farinae 50 % et dermatophagoides pteronyssinus 50 %, aluminium ut aluminii hydroxidum hydricum ad adsorptionem, natrii chloridum, conserv.: phenolum 4.0 mg, aqua q.s. ad suspensionem pro 1 ml."
|
774
|
+
composition = ParseComposition.from_string(string)
|
775
|
+
composition.label_description
|
776
|
+
specify { expect(composition.label).to eq "A" }
|
777
|
+
specify { expect(composition.label_description).to eq "acari allergeni extractum 50 U." }
|
778
|
+
specify { expect(composition.source).to eq string }
|
779
|
+
specify { expect(composition.substances.size).to eq 5 }
|
780
|
+
pteronyssinus = composition.substances.find { |x| /pteronyssinus/i.match(x.name) }
|
781
|
+
specify { expect(composition.substances.first.name).to eq "Dermatophagoides Farinae" }
|
782
|
+
specify { expect(pteronyssinus.name).to eq "Dermatophagoides Pteronyssinus" }
|
783
|
+
specify { expect(pteronyssinus.more_info).to eq nil }
|
784
|
+
end
|
801
785
|
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
786
|
+
context "should return correct composition for containing 'virus rabiei inactivatum" do
|
787
|
+
string = "Praeparatio cryodesiccata: virus rabiei inactivatum (Stamm: Wistar Rabies PM/WI 38-1503-3M) min. 2.5 U.I."
|
788
|
+
composition = ParseComposition.from_string(string)
|
789
|
+
specify { expect(composition.source).to eq string }
|
790
|
+
specify { expect(composition.substances.size).to eq 1 }
|
791
|
+
specify { expect(composition.substances.first.name).to eq "Virus Rabiei Inactivatum (stamm: Wistar Rabies Pm/wi 38-1503-3m)" }
|
792
|
+
specify { expect(composition.substances.first.qty).to eq 2.5 }
|
793
|
+
specify { expect(composition.substances.first.unit).to eq "U.I." }
|
794
|
+
specify { expect(composition.label).to eq "Praeparatio cryodesiccata:" }
|
795
|
+
end
|
812
796
|
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
797
|
+
context "should return correct composition for containing Histamin Equivalent Pric. (e.g IKSNR 58566)" do
|
798
|
+
# 58566 1 Soluprick SQ Phleum pratense, Lösung
|
799
|
+
string = "pollinis allergeni extractum (Phleum pratense) 10 U., natrii chloridum, phenolum, glycerolum, aqua ad iniectabilia q.s. ad solutionem pro 1 ml, U = Histamin Equivalent Prick."
|
800
|
+
composition = ParseComposition.from_string(string)
|
801
|
+
specify { expect(composition.source).to eq string }
|
802
|
+
specify { expect(composition.substances.size).to eq 4 }
|
803
|
+
specify { expect(composition.substances.first.name).to eq "Pollinis Allergeni Extractum (phleum Pratense)" }
|
804
|
+
end
|
821
805
|
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
806
|
+
context "should handle aqua ad iniectabilia" do
|
807
|
+
string = "any_substance, aqua ad iniectabilia q.s. ad solutionem pro 5 ml"
|
808
|
+
composition = ParseComposition.from_string(string)
|
809
|
+
# substance = composition.substances.last
|
810
|
+
specify { expect(composition.excipiens.name).to eq "aqua ad iniectabilia q.s. ad solutionem" }
|
811
|
+
specify { expect(composition.excipiens.chemical_substance).to eq nil }
|
812
|
+
specify { expect(composition.excipiens.qty).to eq 5.0 }
|
813
|
+
specify { expect(composition.excipiens.unit).to eq "ml" }
|
814
|
+
end
|
831
815
|
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
816
|
+
context "should return correct substance for 'excipiens ad solutionem pro 1 ml corresp. ethanolum 59.5 % V/V'" do
|
817
|
+
string = "any_substance, excipiens ad solutionem pro 1 ml corresp. ethanolum 59.5 % V/V"
|
818
|
+
composition = ParseComposition.from_string(string)
|
819
|
+
# substance = composition.substances.first
|
820
|
+
# TODO: what should we report here? dose = pro 1 ml or 59.5 % V/V, chemical_substance = ethanolum?
|
821
|
+
# or does it only make sense as part of a composition?
|
822
|
+
skip { expect(composition.excipiens.name).to eq "Ethanolum" }
|
823
|
+
specify { expect(composition.excipiens.cdose).to eq nil }
|
824
|
+
skip { expect(composition.excipiens.qty).to eq 59.5 }
|
825
|
+
skip { expect(composition.excipiens.unit).to eq "% V/V" }
|
826
|
+
end
|
843
827
|
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
828
|
+
context "should return correct composition for 'excipiens ad emulsionem'" do
|
829
|
+
string = 'something, excipiens ad emulsionem pro 1 g"'
|
830
|
+
composition = ParseComposition.from_string(string)
|
831
|
+
# substance = composition.substances.first
|
832
|
+
specify { expect(composition.source).to eq string }
|
833
|
+
specify { expect(composition.substances.size).to eq 1 }
|
834
|
+
end
|
851
835
|
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
836
|
+
context "should return correct substance for 'aqua q.s. ad suspensionem pro 0.5 ml'" do
|
837
|
+
string = "natrii dihydrogenophosphas dihydricus, aqua q.s. ad suspensionem pro 0.5 ml."
|
838
|
+
composition = ParseComposition.from_string(string)
|
839
|
+
specify { expect(composition.excipiens.name).to match(/aqua|excipiens/) }
|
840
|
+
specify { expect(composition.excipiens.qty).to eq 0.5 }
|
841
|
+
specify { expect(composition.excipiens.unit).to eq "ml" }
|
842
|
+
end
|
859
843
|
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
844
|
+
context "should return correct substance for 'excipiens ad solutionem pro 3 ml corresp. 50 µg'" do
|
845
|
+
string = "any_substance, excipiens ad solutionem pro 3 ml corresp. 50 µg"
|
846
|
+
composition = ParseComposition.from_string(string)
|
847
|
+
specify { expect(composition.excipiens.name).to match(/Excipiens/i) }
|
848
|
+
specify { expect(composition.excipiens.qty).to eq 3.0 }
|
849
|
+
specify { expect(composition.excipiens.unit).to eq "ml" }
|
850
|
+
specify { expect(composition.excipiens.cdose.qty).to eq 50.0 }
|
851
|
+
specify { expect(composition.excipiens.cdose.unit).to eq "µg" }
|
852
|
+
end
|
869
853
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
854
|
+
context "should return correct substance for 'excipiens ad pulverem pro 1000 mg'" do
|
855
|
+
string = "any_substance, excipiens ad pulverem pro 1000 mg"
|
856
|
+
CompositionTransformer.clear_substances
|
857
|
+
composition = ParseComposition.from_string(string)
|
858
|
+
specify { expect(composition.excipiens.name).to match(/Excipiens/) }
|
859
|
+
specify { expect(composition.excipiens.qty).to eq 1000.0 }
|
860
|
+
specify { expect(composition.excipiens.unit).to eq "mg" }
|
861
|
+
end
|
878
862
|
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
863
|
+
context "should pass with 'etinoli 7900 U.I'" do
|
864
|
+
string = "retinoli 7900 U.I."
|
865
|
+
composition = ParseComposition.from_string(string)
|
866
|
+
specify { expect(composition.source).to eq string }
|
867
|
+
specify { expect(composition.substances.size).to eq 1 }
|
868
|
+
specify { expect(composition.substances.first.qty).to eq 7900.0 }
|
869
|
+
specify { expect(composition.substances.first.unit).to eq "U.I." }
|
870
|
+
specify { expect(composition.substances.first.name).to eq "Retinoli" }
|
871
|
+
end
|
888
872
|
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
873
|
+
context "should return correct composition for containing 'absinthii herba 1.2 g pro charta" do
|
874
|
+
string = "absinthii herba 1.2 g pro charta"
|
875
|
+
composition = ParseComposition.from_string(string)
|
876
|
+
specify { expect(composition.source).to eq string }
|
877
|
+
specify { expect(composition.substances.size).to eq 1 }
|
878
|
+
specify { expect(composition.substances.first.name).to eq "Absinthii Herba" }
|
879
|
+
end
|
896
880
|
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
881
|
+
context "should return correct composition for containing 'ad pulverem'" do
|
882
|
+
string = "pimpinellae radix 15 % ad pulverem"
|
883
|
+
composition = ParseComposition.from_string(string)
|
884
|
+
specify { expect(composition.source).to eq string }
|
885
|
+
specify { expect(composition.substances.size).to eq 1 }
|
886
|
+
specify { expect(composition.substances.first.name).to eq "Pimpinellae Radix" }
|
887
|
+
end
|
904
888
|
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
889
|
+
context "should return correct composition for 'DER: 6:1'" do
|
890
|
+
string = "DER: 6:1"
|
891
|
+
composition = ParseComposition.from_string(string)
|
892
|
+
specify { expect(composition.source).to eq string }
|
893
|
+
specify { expect(composition.substances.size).to eq 1 }
|
894
|
+
specify { expect(composition.substances.first.name).to eq string }
|
895
|
+
end
|
912
896
|
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
897
|
+
context "should return correct composition for containing ' ut procaini hydrochloridum" do
|
898
|
+
string =
|
899
|
+
"procainum 10 mg ut procaini hydrochloridum"
|
900
|
+
composition = ParseComposition.from_string(string)
|
901
|
+
specify { expect(composition.source).to eq string }
|
902
|
+
specify { expect(composition.substances.size).to eq 1 }
|
903
|
+
specify { expect(composition.substances.first.name).to eq "Procainum" }
|
904
|
+
specify { expect(composition.substances.first.salts.first.name).to eq "Procaini Hydrochloridum" }
|
905
|
+
end
|
922
906
|
|
923
|
-
|
924
|
-
|
925
|
-
#"absinthii herba 15 %, anisi fructus 15 %, carvi fructus 15 %, foeniculi fructus 15 %, iuniperi pseudofructus 10 %, millefolii herba 15 %, pimpinellae radix 15 % ad pulverem.\n"
|
926
|
-
"pimpinellae radix 15 % ad pulverem.\n"
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
907
|
+
context "should return correct composition for containing 'ad pulverem'" do
|
908
|
+
string =
|
909
|
+
# "absinthii herba 15 %, anisi fructus 15 %, carvi fructus 15 %, foeniculi fructus 15 %, iuniperi pseudofructus 10 %, millefolii herba 15 %, pimpinellae radix 15 % ad pulverem.\n"
|
910
|
+
"pimpinellae radix 15 % ad pulverem.\n"
|
911
|
+
composition = ParseComposition.from_string(string)
|
912
|
+
specify { expect(composition.source).to eq string }
|
913
|
+
specify { expect(composition.substances.size).to eq 1 }
|
914
|
+
specify { expect(composition.substances.first.name).to eq "Pimpinellae Radix" }
|
915
|
+
specify { expect(composition.substances.first.qty).to eq 15.0 }
|
916
|
+
specify { expect(composition.substances.first.unit).to eq "%" }
|
917
|
+
end
|
934
918
|
|
935
|
-
|
936
|
-
|
937
|
-
"abrus precatorius C6, aconitum napellus C6, atropa belladonna C6, calendula officinalis C6, chelidonium majus C6, viburnum opulus C6 ana partes, excipiens ad globulos.\n"
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
919
|
+
context "should return correct composition for containing 'excipiens ad globulos" do
|
920
|
+
string =
|
921
|
+
"abrus precatorius C6, aconitum napellus C6, atropa belladonna C6, calendula officinalis C6, chelidonium majus C6, viburnum opulus C6 ana partes, excipiens ad globulos.\n"
|
922
|
+
composition = ParseComposition.from_string(string)
|
923
|
+
specify { expect(composition.source).to eq string }
|
924
|
+
specify { expect(composition.substances.size).to eq 6 }
|
925
|
+
specify { expect(composition.substances.first.name).to eq "Abrus Precatorius C6" }
|
926
|
+
end
|
943
927
|
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
928
|
+
context "should return correct composition for containing 'arom.: E 104'" do
|
929
|
+
string = "gentianae radix 12 mg, primulae flos 36 mg, rumicis acetosae herba 36 mg, sambuci flos 36 mg, verbenae herba 36 mg, color.: E 104 et E 132, excipiens pro compresso obducto."
|
930
|
+
composition = ParseComposition.from_string(string)
|
931
|
+
specify { expect(composition.source).to eq string }
|
932
|
+
specify { expect(composition.substances.size).to eq 7 }
|
933
|
+
e104 = composition.substances.find { |x| x.name.eql?("E 104") }
|
950
934
|
|
951
|
-
|
952
|
-
|
953
|
-
|
935
|
+
specify { expect(e104.name).to eq "E 104" }
|
936
|
+
specify { expect(composition.substances.first.name).to eq "Gentianae Radix" }
|
937
|
+
end
|
954
938
|
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
939
|
+
context "should return correct composition for containing 'color.: E 160(a)'" do
|
940
|
+
string = "color.: E 160(a), E 171"
|
941
|
+
composition = ParseComposition.from_string(string)
|
942
|
+
specify { expect(composition.source).to eq string }
|
943
|
+
specify { expect(composition.substances.size).to eq 2 }
|
944
|
+
specify { expect(composition.substances.first.name).to eq "E 160(a)" }
|
945
|
+
specify { expect(composition.substances.last.name).to eq "E 171" }
|
946
|
+
end
|
963
947
|
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
# specify { expect(substance.name).to eq 'Urtica Dioica' } # TODO: is this okay?
|
969
|
-
|
970
|
-
|
948
|
+
context "should parse a Praeparatio with a label/galenic form?" do
|
949
|
+
string = "Praeparatio cryodesiccata: pollinis allergeni extractum 25'000 U.: urtica dioica"
|
950
|
+
composition = ParseComposition.from_string(string)
|
951
|
+
# substance = composition.substances.first
|
952
|
+
# specify { expect(substance.name).to eq 'Urtica Dioica' } # TODO: is this okay?
|
953
|
+
specify { expect(composition.label).to eq "Praeparatio cryodesiccata:" }
|
954
|
+
end
|
971
955
|
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
956
|
+
context "should return correct substance for equis F(ab')2" do
|
957
|
+
string = "viperis antitoxinum equis F(ab')2"
|
958
|
+
composition = ParseComposition.from_string(string)
|
959
|
+
substance = composition.substances.first
|
960
|
+
specify { expect(substance.name).to eq "Viperis Antitoxinum Equis F(ab')" }
|
961
|
+
end
|
978
962
|
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
963
|
+
context "should return correct substance for with two et substances corresp" do
|
964
|
+
string = "viperis antitoxinum equis F(ab')2 corresp. Vipera aspis > 1000 LD50 mus et Vipera berus > 500 LD50 mus et Vipera ammodytes > 1000 LD50 mus"
|
965
|
+
composition = ParseComposition.from_string(string)
|
966
|
+
substance = composition.substances.last
|
967
|
+
specify { expect(substance.name).to eq "Vipera Ammodytes > 1000 Ld50 Mus" }
|
968
|
+
end
|
985
969
|
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
970
|
+
context "should return correct substance for 'pyrazinamidum 500 mg'" do
|
971
|
+
string = "pyrazinamidum 500 mg"
|
972
|
+
CompositionTransformer.clear_substances
|
973
|
+
composition = ParseComposition.from_string(string)
|
974
|
+
substance = composition.substances.first
|
975
|
+
specify { expect(substance.name).to eq "Pyrazinamidum" }
|
976
|
+
specify { expect(substance.qty).to eq 500.0 }
|
977
|
+
specify { expect(substance.unit).to eq "mg" }
|
978
|
+
end
|
995
979
|
|
996
|
-
|
997
|
-
|
980
|
+
context "should return correct substance for given with et and corresp. (IKSNR 11879)" do
|
981
|
+
string = "calcii lactas pentahydricus 25 mg et calcii hydrogenophosphas anhydricus 300 mg corresp. calcium 100 mg"
|
998
982
|
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
983
|
+
composition = ParseComposition.from_string(string)
|
984
|
+
specify { expect(composition.substances.size).to eq 2 }
|
985
|
+
# calcii = composition.substances.find { |x| /calcii/i.match(x.name) }
|
986
|
+
pentahydricus = composition.substances.find { |x| /pentahydricus/i.match(x.name) }
|
987
|
+
anhydricus = composition.substances.find { |x| /anhydricus/i.match(x.name) }
|
988
|
+
specify { expect(pentahydricus.name).to eq "Calcii Lactas Pentahydricus" }
|
989
|
+
specify { expect(pentahydricus.qty).to eq 25.0 }
|
990
|
+
specify { expect(pentahydricus.unit).to eq "mg" }
|
991
|
+
specify { expect(anhydricus.name).to eq "Calcii Hydrogenophosphas Anhydricus" }
|
992
|
+
specify { expect(anhydricus.qty).to eq 300.0 }
|
993
|
+
specify { expect(anhydricus.unit).to eq "mg" }
|
994
|
+
specify { expect(anhydricus.chemical_substance.name).to eq "Calcium" }
|
995
|
+
specify { expect(anhydricus.chemical_substance.qty).to eq 100.0 }
|
996
|
+
specify { expect(anhydricus.chemical_substance.unit).to eq "mg" }
|
997
|
+
end
|
998
|
+
|
999
|
+
context "should return correct substances for Nutriflex IKSNR 42847" do
|
1000
|
+
line_1 = "I) Glucoselösung: glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg, acidum citricum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
|
1001
|
+
line_2 = "."
|
1002
|
+
# line_4 = "."
|
1003
|
+
# line_5 = "I) et II) corresp.: aminoacida 70 g, nitrogenia 10 g, natrium 40.5 mmol, kalium 25.7 mmol, calcium 4.1 mmol, magnesium 5 mmol, chloridum 49.5 mmol, phosphas 14.7 mmol, acetas 22 mmol, in solutione recenter reconstituta 1000 ml."
|
1004
|
+
# line_6 = "Corresp. 5190 kJ pro 1 l."
|
1005
|
+
# tst = "glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg, acidum citricum monohydricum"
|
1006
|
+
# tst2 = "glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg"
|
1007
|
+
# tst_ut = "glucosum anhydricum 240 g ut glucosum monohydricum"
|
1008
|
+
composition = ParseComposition.from_string(line_2)
|
1009
|
+
# line_3 = "II) Aminosäurelösung: aminoacida: isoleucinum 4.11 g, leucinum 5.48 g, lysinum anhydricum 3.98 g ut lysinum monohydricum, methioninum 3.42 g, phenylalaninum 6.15 g, threoninum 3.18 g, tryptophanum 1 g, valinum 4.54 g, argininum 4.73 g, histidinum 2.19 g ut histidini hydrochloridum monohydricum, alaninum 8.49 g, acidum asparticum 2.63 g, acidum glutamicum 6.14 g, glycinum 2.89 g, prolinum 5.95 g, serinum 5.25 g, mineralia: magnesii acetas tetrahydricus 1.08 g, natrii acetas trihydricus 1.63 g, kalii dihydrogenophosphas 2 g, kalii hydroxidum 620 mg, natrii hydroxidum 1.14 g, acidum citricum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
|
1010
|
+
# line_3 = "II) Aminosäurelösung: aminoacida: isoleucinum 4.11 g, leucinum 5.48 g"
|
1011
|
+
line_3 = "aminoacida: isoleucinum 4.11 g, leucinum 5.48 g"
|
1012
|
+
composition = ParseComposition.from_string(line_3)
|
1013
|
+
composition = ParseComposition.from_string(line_1)
|
1014
1014
|
|
1015
|
-
|
1016
|
-
|
1017
|
-
.
|
1018
|
-
|
1019
|
-
.
|
1020
|
-
|
1021
|
-
Corresp. 5190 kJ pro 1 l."
|
1022
|
-
line_1 = "I) Glucoselösung: glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg, acidum citricum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
|
1023
|
-
line_2 = "."
|
1024
|
-
line_3 = "II) Aminosäurelösung: aminoacida: isoleucinum 4.11 g, leucinum 5.48 g, lysinum anhydricum 3.98 g ut lysinum monohydricum, methioninum 3.42 g, phenylalaninum 6.15 g, threoninum 3.18 g, tryptophanum 1 g, valinum 4.54 g, argininum 4.73 g, histidinum 2.19 g ut histidini hydrochloridum monohydricum, alaninum 8.49 g, acidum asparticum 2.63 g, acidum glutamicum 6.14 g, glycinum 2.89 g, prolinum 5.95 g, serinum 5.25 g, mineralia: magnesii acetas tetrahydricus 1.08 g, natrii acetas trihydricus 1.63 g, kalii dihydrogenophosphas 2 g, kalii hydroxidum 620 mg, natrii hydroxidum 1.14 g, acidum citricum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
|
1025
|
-
line_4 = "."
|
1026
|
-
line_5 = "I) et II) corresp.: aminoacida 70 g, nitrogenia 10 g, natrium 40.5 mmol, kalium 25.7 mmol, calcium 4.1 mmol, magnesium 5 mmol, chloridum 49.5 mmol, phosphas 14.7 mmol, acetas 22 mmol, in solutione recenter reconstituta 1000 ml."
|
1027
|
-
line_6 = "Corresp. 5190 kJ pro 1 l."
|
1028
|
-
tst = 'glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg, acidum citricum monohydricum'
|
1029
|
-
tst2 = 'glucosum anhydricum 240 g ut glucosum monohydricum, calcii chloridum dihydricum 600 mg'
|
1030
|
-
tst_ut = 'glucosum anhydricum 240 g ut glucosum monohydricum'
|
1031
|
-
composition = ParseComposition.from_string(line_2)
|
1032
|
-
line_3 = "II) Aminosäurelösung: aminoacida: isoleucinum 4.11 g, leucinum 5.48 g, lysinum anhydricum 3.98 g ut lysinum monohydricum, methioninum 3.42 g, phenylalaninum 6.15 g, threoninum 3.18 g, tryptophanum 1 g, valinum 4.54 g, argininum 4.73 g, histidinum 2.19 g ut histidini hydrochloridum monohydricum, alaninum 8.49 g, acidum asparticum 2.63 g, acidum glutamicum 6.14 g, glycinum 2.89 g, prolinum 5.95 g, serinum 5.25 g, mineralia: magnesii acetas tetrahydricus 1.08 g, natrii acetas trihydricus 1.63 g, kalii dihydrogenophosphas 2 g, kalii hydroxidum 620 mg, natrii hydroxidum 1.14 g, acidum citricum monohydricum, aqua ad iniectabilia q.s. ad solutionem pro 500 ml."
|
1033
|
-
line_3 = "II) Aminosäurelösung: aminoacida: isoleucinum 4.11 g, leucinum 5.48 g"
|
1034
|
-
line_3 = "aminoacida: isoleucinum 4.11 g, leucinum 5.48 g"
|
1035
|
-
composition = ParseComposition.from_string(line_3)
|
1036
|
-
composition = ParseComposition.from_string(line_1)
|
1037
|
-
|
1038
|
-
composition = ParseComposition.from_string(line_1)
|
1039
|
-
specify { expect(composition.substances.size).to eq 3 }
|
1040
|
-
specify { expect(composition.label).to eq 'I' }
|
1041
|
-
specify { expect(composition.label_description).to eq 'Glucoselösung' }
|
1042
|
-
dihydricum = composition.substances.find{ |x| /dihydricum/i.match(x.name) }
|
1043
|
-
monohydricum = composition.substances.find{ |x| /monohydricum/i.match(x.name) }
|
1044
|
-
|
1045
|
-
specify { expect(dihydricum.name).to eq 'Calcii Chloridum Dihydricum' }
|
1046
|
-
specify { expect(dihydricum.chemical_substance).to eq nil }
|
1047
|
-
specify { expect(dihydricum.qty).to eq 600.0}
|
1048
|
-
specify { expect(dihydricum.unit).to eq 'mg/500 ml' }
|
1049
|
-
|
1050
|
-
specify { expect(monohydricum.name).to eq 'Acidum Citricum Monohydricum' }
|
1051
|
-
specify { expect(monohydricum.chemical_substance).to eq nil }
|
1052
|
-
specify { expect(monohydricum.cdose).to eq nil }
|
1053
|
-
specify { expect(monohydricum.qty).to eq nil}
|
1054
|
-
specify { expect(monohydricum.unit).to eq nil }
|
1055
|
-
end
|
1015
|
+
composition = ParseComposition.from_string(line_1)
|
1016
|
+
specify { expect(composition.substances.size).to eq 3 }
|
1017
|
+
specify { expect(composition.label).to eq "I" }
|
1018
|
+
specify { expect(composition.label_description).to eq "Glucoselösung" }
|
1019
|
+
dihydricum = composition.substances.find { |x| /dihydricum/i.match(x.name) }
|
1020
|
+
monohydricum = composition.substances.find { |x| /monohydricum/i.match(x.name) }
|
1056
1021
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
].each {
|
1062
|
-
|string|
|
1063
|
-
composition = ParseComposition.from_string(string)
|
1064
|
-
substance = composition.substances.first
|
1065
|
-
specify { expect(substance.name).to eq '9,11-linolicum' }
|
1066
|
-
specify { expect(substance.chemical_substance).to eq nil }
|
1067
|
-
CompositionTransformer.clear_substances
|
1068
|
-
composition = ParseComposition.from_string(string)
|
1069
|
-
}
|
1070
|
-
|
1071
|
-
specify { expect(substance.qty).to eq 3.25}
|
1072
|
-
specify { expect(substance.unit).to eq 'mg' }
|
1073
|
-
end
|
1022
|
+
specify { expect(dihydricum.name).to eq "Calcii Chloridum Dihydricum" }
|
1023
|
+
specify { expect(dihydricum.chemical_substance).to eq nil }
|
1024
|
+
specify { expect(dihydricum.qty).to eq 600.0 }
|
1025
|
+
specify { expect(dihydricum.unit).to eq "mg/500 ml" }
|
1074
1026
|
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
specify { expect(composition.substances.first.salts.size).to eq 1}
|
1082
|
-
if composition.substances.first
|
1083
|
-
salt = composition.substances.first.salts.first
|
1084
|
-
specify { expect(salt.name).to eq 'Zuclopenthixoli Dihydrochloridum' }
|
1085
|
-
specify { expect(salt.qty).to eq nil}
|
1086
|
-
specify { expect(salt.unit).to eq nil }
|
1087
|
-
end
|
1088
|
-
end
|
1027
|
+
specify { expect(monohydricum.name).to eq "Acidum Citricum Monohydricum" }
|
1028
|
+
specify { expect(monohydricum.chemical_substance).to eq nil }
|
1029
|
+
specify { expect(monohydricum.cdose).to eq nil }
|
1030
|
+
specify { expect(monohydricum.qty).to eq nil }
|
1031
|
+
specify { expect(monohydricum.unit).to eq nil }
|
1032
|
+
end
|
1089
1033
|
|
1090
|
-
|
1091
|
-
|
1034
|
+
context "should return correct substance for 9,11-linolicum " do
|
1035
|
+
substance = nil
|
1036
|
+
composition = nil
|
1037
|
+
["9,11-linolicum",
|
1038
|
+
"9,11-linolicum 3.25 mg"].each { |string|
|
1092
1039
|
composition = ParseComposition.from_string(string)
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
specify { expect(pentahydricus.qty).to eq 25.0}
|
1098
|
-
specify { expect(pentahydricus.unit).to eq 'mg' }
|
1099
|
-
specify { expect(anhydricus.name).to eq 'Calcii Hydrogenophosphas Anhydricus' }
|
1100
|
-
specify { expect(anhydricus.qty).to eq 300.0 }
|
1101
|
-
specify { expect(anhydricus.unit).to eq 'mg' }
|
1102
|
-
end
|
1103
|
-
|
1104
|
-
context "should return correct substance for 'Xenonum(133-xe) 74 -740 Mb'" do
|
1105
|
-
string = "Xenonum(133-Xe) 74 -740 MBq"
|
1040
|
+
substance = composition.substances.first
|
1041
|
+
specify { expect(substance.name).to eq "9,11-linolicum" }
|
1042
|
+
specify { expect(substance.chemical_substance).to eq nil }
|
1043
|
+
CompositionTransformer.clear_substances
|
1106
1044
|
composition = ParseComposition.from_string(string)
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
specify { expect(substance.qty).to eq 3.25 }
|
1048
|
+
specify { expect(substance.unit).to eq "mg" }
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
context "should return correct substance ut (IKSNR 44744)" do
|
1052
|
+
string = "zuclopenthixolum 2 mg ut zuclopenthixoli dihydrochloridum, excipiens pro compresso obducto."
|
1053
|
+
composition = ParseComposition.from_string(string)
|
1054
|
+
specify { expect(composition.substances.size).to eq 1 }
|
1055
|
+
specify { expect(composition.substances.first.name).to eq "Zuclopenthixolum" }
|
1056
|
+
specify { expect(composition.substances.first.qty).to eq 2.0 }
|
1057
|
+
specify { expect(composition.substances.first.salts.size).to eq 1 }
|
1058
|
+
if composition.substances.first
|
1059
|
+
salt = composition.substances.first.salts.first
|
1060
|
+
specify { expect(salt.name).to eq "Zuclopenthixoli Dihydrochloridum" }
|
1061
|
+
specify { expect(salt.qty).to eq nil }
|
1062
|
+
specify { expect(salt.unit).to eq nil }
|
1111
1063
|
end
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
context "should return correct substance for given with et (IKSNR 11879)" do
|
1067
|
+
string = "calcii lactas pentahydricus 25 mg et calcii hydrogenophosphas anhydricus 300 mg"
|
1068
|
+
composition = ParseComposition.from_string(string)
|
1069
|
+
specify { expect(composition.substances.size).to eq 2 }
|
1070
|
+
pentahydricus = composition.substances.find { |x| /pentahydricus/i.match(x.name) }
|
1071
|
+
anhydricus = composition.substances.find { |x| /anhydricus/i.match(x.name) }
|
1072
|
+
specify { expect(pentahydricus.name).to eq "Calcii Lactas Pentahydricus" }
|
1073
|
+
specify { expect(pentahydricus.qty).to eq 25.0 }
|
1074
|
+
specify { expect(pentahydricus.unit).to eq "mg" }
|
1075
|
+
specify { expect(anhydricus.name).to eq "Calcii Hydrogenophosphas Anhydricus" }
|
1076
|
+
specify { expect(anhydricus.qty).to eq 300.0 }
|
1077
|
+
specify { expect(anhydricus.unit).to eq "mg" }
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
context "should return correct substance for 'Xenonum(133-xe) 74 -740 Mb'" do
|
1081
|
+
string = "Xenonum(133-Xe) 74 -740 MBq"
|
1082
|
+
composition = ParseComposition.from_string(string)
|
1083
|
+
substance = composition.substances.first
|
1084
|
+
specify { expect(substance.name).to eq "Xenonum(133-xe)" }
|
1085
|
+
specify { expect(substance.qty).to eq "74-740" }
|
1086
|
+
specify { expect(substance.unit).to eq "MBq" }
|
1087
|
+
end
|
1112
1088
|
|
1113
1089
|
context "should return correct substance for 'pyrazinamidum'" do
|
1114
1090
|
string = "pyrazinamidum"
|
1115
1091
|
composition = ParseComposition.from_string(string)
|
1116
|
-
|
1117
|
-
specify { expect(substance.name).to eq
|
1092
|
+
substance = composition.substances.first
|
1093
|
+
specify { expect(substance.name).to eq "Pyrazinamidum" }
|
1118
1094
|
specify { expect(substance.qty).to eq nil }
|
1119
1095
|
specify { expect(substance.unit).to eq nil }
|
1120
1096
|
end
|
@@ -1131,97 +1107,97 @@ Corresp. 5190 kJ pro 1 l."
|
|
1131
1107
|
context "should return correct substance for 'retinoli palmitas 7900 U.I.'" do
|
1132
1108
|
string = "retinoli palmitas 7900 U.I."
|
1133
1109
|
composition = ParseComposition.from_string(string)
|
1134
|
-
|
1135
|
-
specify { expect(substance.name).to eq
|
1136
|
-
specify { expect(substance.qty).to eq 7900.0}
|
1137
|
-
specify { expect(substance.unit).to eq
|
1110
|
+
substance = composition.substances.first
|
1111
|
+
specify { expect(substance.name).to eq "Retinoli Palmitas" }
|
1112
|
+
specify { expect(substance.qty).to eq 7900.0 }
|
1113
|
+
specify { expect(substance.unit).to eq "U.I." }
|
1138
1114
|
end
|
1139
1115
|
|
1140
1116
|
context "should return correct substance for 'toxoidum pertussis 8 µg'" do
|
1141
1117
|
string = "toxoidum pertussis 8 µg"
|
1142
1118
|
composition = ParseComposition.from_string(string)
|
1143
|
-
|
1144
|
-
specify { expect(substance.name).to eq
|
1145
|
-
specify { expect(substance.qty).to eq 8.0}
|
1146
|
-
specify { expect(substance.unit).to eq
|
1119
|
+
substance = composition.substances.first
|
1120
|
+
specify { expect(substance.name).to eq "Toxoidum Pertussis" }
|
1121
|
+
specify { expect(substance.qty).to eq 8.0 }
|
1122
|
+
specify { expect(substance.unit).to eq "µg" }
|
1147
1123
|
end
|
1148
1124
|
|
1149
1125
|
context "should return correct substance Rote Filmtablett 54819 Beriplast" do
|
1150
|
-
string = "A) Rote Filmtablette: estradiolum 1 mg ut estradiolum hemihydricum, excipiens pro compresso obducto"
|
1126
|
+
# string = "A) Rote Filmtablette: estradiolum 1 mg ut estradiolum hemihydricum, excipiens pro compresso obducto"
|
1151
1127
|
string = "estradiolum 1 mg ut estradiolum hemihydricum, excipiens pro compresso obducto"
|
1152
1128
|
composition = ParseComposition.from_string(string)
|
1153
1129
|
substance = composition.substances.first
|
1154
1130
|
specify { expect(composition.substances.size).to eq 1 }
|
1155
1131
|
# specify { expect(composition.substances.last.name).to eq 'Obducto' }
|
1156
|
-
specify { expect(substance.name).to eq
|
1157
|
-
specify { expect(composition.substances.first.salts.first.name).to eq
|
1132
|
+
specify { expect(substance.name).to eq "Estradiolum" }
|
1133
|
+
specify { expect(composition.substances.first.salts.first.name).to eq "Estradiolum Hemihydricum" }
|
1158
1134
|
specify { expect(substance.cdose.to_s).to eq "" }
|
1159
|
-
specify { expect(substance.qty).to eq 1.0}
|
1160
|
-
specify { expect(substance.unit).to eq
|
1135
|
+
specify { expect(substance.qty).to eq 1.0 }
|
1136
|
+
specify { expect(substance.unit).to eq "mg" }
|
1161
1137
|
end
|
1162
1138
|
|
1163
1139
|
context "should return correct composition for containing ut IKSNR 613" do
|
1164
|
-
string =
|
1140
|
+
string = "aluminium ut aluminii hydroxidum hydricum ad adsorptionem"
|
1165
1141
|
composition = ParseComposition.from_string(string)
|
1166
1142
|
specify { expect(composition.source).to eq string }
|
1167
1143
|
specify { expect(composition.label).to eq nil }
|
1168
1144
|
specify { expect(composition.substances.size).to eq 1 }
|
1169
|
-
specify { expect(composition.substances.first.name).to eq
|
1170
|
-
specify { expect(composition.substances.first.salts.first.name).to eq
|
1145
|
+
specify { expect(composition.substances.first.name).to eq "Aluminium" }
|
1146
|
+
specify { expect(composition.substances.first.salts.first.name).to eq "Aluminii Hydroxidum Hydricum Ad Adsorptionem" }
|
1171
1147
|
end
|
1172
1148
|
|
1173
1149
|
context "should return correct substance for 'toxoidum pertussis 25 µg et haemagglutininum filamentosum 25 µg'" do
|
1174
1150
|
string = "toxoidum pertussis 25 µg et haemagglutininum filamentosum 15 µg"
|
1175
1151
|
composition = ParseComposition.from_string(string)
|
1176
1152
|
toxoidum = composition.substances.first
|
1177
|
-
specify { expect(toxoidum.name).to eq
|
1178
|
-
specify { expect(toxoidum.qty).to eq 25.0}
|
1179
|
-
specify { expect(toxoidum.unit).to eq
|
1153
|
+
specify { expect(toxoidum.name).to eq "Toxoidum Pertussis" }
|
1154
|
+
specify { expect(toxoidum.qty).to eq 25.0 }
|
1155
|
+
specify { expect(toxoidum.unit).to eq "µg" }
|
1180
1156
|
specify { expect(toxoidum.chemical_substance).to eq nil }
|
1181
1157
|
haemagglutininum = composition.substances.last
|
1182
|
-
specify { expect(haemagglutininum.name).to eq
|
1183
|
-
specify { expect(haemagglutininum.qty).to eq 15.0}
|
1184
|
-
specify { expect(haemagglutininum.unit).to eq
|
1158
|
+
specify { expect(haemagglutininum.name).to eq "Haemagglutininum Filamentosum" }
|
1159
|
+
specify { expect(haemagglutininum.qty).to eq 15.0 }
|
1160
|
+
specify { expect(haemagglutininum.unit).to eq "µg" }
|
1185
1161
|
end
|
1186
1162
|
|
1187
1163
|
context "should return correct composition for containing parenthesis in substance name abd 40 U. (e.g IKSNR 613)" do
|
1188
|
-
string =
|
1164
|
+
string = "virus poliomyelitis typus 1 inactivatum (D-Antigen) 40 U."
|
1189
1165
|
composition = ParseComposition.from_string(string)
|
1190
1166
|
specify { expect(composition.source).to eq string }
|
1191
1167
|
specify { expect(composition.substances.size).to eq 1 }
|
1192
|
-
specify { expect(composition.substances.first.name).to eq
|
1168
|
+
specify { expect(composition.substances.first.name).to eq "Virus Poliomyelitis Typus 1 Inactivatum (d-antigen)" }
|
1193
1169
|
end
|
1194
1170
|
|
1195
1171
|
context "should return correct composition for containing parenthesis in substance name (e.g IKSNR 613)" do
|
1196
|
-
string =
|
1197
|
-
string =
|
1172
|
+
string = "virus poliomyelitis typus inactivatum (D-Antigen)"
|
1173
|
+
string = "virus poliomyelitis typus 1 inactivatum (d-antigen)"
|
1198
1174
|
composition = ParseComposition.from_string(string)
|
1199
1175
|
specify { expect(composition.source).to eq string }
|
1200
1176
|
specify { expect(composition.substances.size).to eq 1 }
|
1201
|
-
specify { expect(composition.substances.first.name).to eq
|
1177
|
+
specify { expect(composition.substances.first.name).to eq "Virus Poliomyelitis Typus 1 Inactivatum (d-antigen)" }
|
1202
1178
|
end
|
1203
1179
|
|
1204
1180
|
context "should return correct composition for containing residui (e.g IKSNR 613)" do
|
1205
|
-
string =
|
1181
|
+
string = "residui: neomycinum, streptomycinum"
|
1206
1182
|
composition = ParseComposition.from_string(string)
|
1207
1183
|
specify { expect(composition.source).to eq string }
|
1208
1184
|
specify { expect(composition.substances.size).to eq 2 }
|
1209
|
-
specify { expect(composition.substances.first.more_info).to eq
|
1210
|
-
specify { expect(composition.substances.first.name).to eq
|
1211
|
-
specify { expect(composition.substances.last.name).to
|
1185
|
+
specify { expect(composition.substances.first.more_info).to eq "residui" }
|
1186
|
+
specify { expect(composition.substances.first.name).to eq "Neomycinum" }
|
1187
|
+
specify { expect(composition.substances.last.name).to eq "Streptomycinum" }
|
1212
1188
|
end
|
1213
1189
|
|
1214
1190
|
context "should return correct composition for 'conserv.: E 217, E 219' IKSNR 613" do
|
1215
|
-
# string = '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.'
|
1191
|
+
# string = '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.'
|
1216
1192
|
string =
|
1217
|
-
|
1193
|
+
"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."
|
1218
1194
|
composition = ParseComposition.from_string(string)
|
1219
1195
|
specify { expect(composition.source).to eq string }
|
1220
|
-
specify { expect(composition.label).to eq
|
1196
|
+
specify { expect(composition.label).to eq "I" }
|
1221
1197
|
end
|
1222
1198
|
|
1223
1199
|
context "should return correct composition for 'conserv.: E 217, E 219'" do
|
1224
|
-
string =
|
1200
|
+
string = "conserv.: E 217, E 219"
|
1225
1201
|
composition = ParseComposition.from_string(string)
|
1226
1202
|
specify { expect(composition.source).to eq string }
|
1227
1203
|
specify { expect(composition.label).to eq nil }
|
@@ -1229,29 +1205,29 @@ Corresp. 5190 kJ pro 1 l."
|
|
1229
1205
|
|
1230
1206
|
context "should parse more complicated example" do
|
1231
1207
|
string =
|
1232
|
-
"I) DTPa-IPV-Komponente (Suspension): toxoidum diphtheriae 30 U.I., toxoidum pertussis 25 µg et haemagglutininum filamentosum 25 µg"
|
1208
|
+
"I) DTPa-IPV-Komponente (Suspension): toxoidum diphtheriae 30 U.I., toxoidum pertussis 25 µg et haemagglutininum filamentosum 25 µg"
|
1233
1209
|
composition = ParseComposition.from_string(string)
|
1234
1210
|
specify { expect(composition.source).to eq string }
|
1235
1211
|
|
1236
|
-
specify { expect(composition.label).to eq
|
1237
|
-
specify { expect(composition.label_description).to eq
|
1212
|
+
specify { expect(composition.label).to eq "I" }
|
1213
|
+
specify { expect(composition.label_description).to eq "DTPa-IPV-Komponente (Suspension)" }
|
1238
1214
|
|
1239
1215
|
specify { expect(composition.galenic_form).to eq nil }
|
1240
1216
|
specify { expect(composition.route_of_administration).to eq nil }
|
1241
1217
|
|
1242
|
-
toxoidum = composition.substances.find{|x| /toxoidum diphther/i.match(x.name)}
|
1243
|
-
specify { expect(toxoidum.name).to eq
|
1218
|
+
toxoidum = composition.substances.find { |x| /toxoidum diphther/i.match(x.name) }
|
1219
|
+
specify { expect(toxoidum.name).to eq "Toxoidum Diphtheriae" }
|
1244
1220
|
specify { expect(toxoidum.qty).to eq 30 }
|
1245
|
-
specify { expect(toxoidum.unit).to eq
|
1221
|
+
specify { expect(toxoidum.unit).to eq "U.I." }
|
1246
1222
|
|
1247
|
-
haema = composition.substances.find{|x| /Haemagglutininum/i.match(x.name)}
|
1248
|
-
specify { expect(haema.name).to eq
|
1223
|
+
haema = composition.substances.find { |x| /Haemagglutininum/i.match(x.name) }
|
1224
|
+
specify { expect(haema.name).to eq "Haemagglutininum Filamentosum" }
|
1249
1225
|
specify { expect(haema.qty).to eq 25 }
|
1250
|
-
specify { expect(haema.unit).to eq
|
1226
|
+
specify { expect(haema.unit).to eq "µg" }
|
1251
1227
|
end
|
1252
1228
|
|
1253
1229
|
context "should return correct composition for 'minoxidilum'" do
|
1254
|
-
string =
|
1230
|
+
string = "minoxidilum 2.5 mg, pyrazinamidum 500 mg"
|
1255
1231
|
composition = ParseComposition.from_string(string)
|
1256
1232
|
specify { expect(composition.source).to eq string }
|
1257
1233
|
specify { expect(composition.label).to eq nil }
|
@@ -1259,35 +1235,35 @@ Corresp. 5190 kJ pro 1 l."
|
|
1259
1235
|
specify { expect(composition.galenic_form).to eq nil }
|
1260
1236
|
specify { expect(composition.route_of_administration).to eq nil }
|
1261
1237
|
substance = composition.substances.first
|
1262
|
-
specify { expect(substance.name).to eq
|
1238
|
+
specify { expect(substance.name).to eq "Minoxidilum" }
|
1263
1239
|
specify { expect(substance.qty).to eq 2.5 }
|
1264
|
-
specify { expect(substance.unit).to eq
|
1240
|
+
specify { expect(substance.unit).to eq "mg" }
|
1265
1241
|
end
|
1266
1242
|
|
1267
1243
|
context "should return correct composition for 'terra'" do
|
1268
|
-
string =
|
1244
|
+
string = "terra"
|
1269
1245
|
composition = ParseComposition.from_string(string)
|
1270
1246
|
specify { expect(composition.source).to eq string }
|
1271
1247
|
specify { expect(composition.label).to eq nil }
|
1272
1248
|
specify { expect(composition.label_description).to eq nil }
|
1273
1249
|
specify { expect(composition.galenic_form).to eq nil }
|
1274
1250
|
specify { expect(composition.route_of_administration).to eq nil }
|
1275
|
-
specify { expect(
|
1251
|
+
specify { expect(composition.substances.first.name).to eq "Terra" }
|
1276
1252
|
end
|
1277
1253
|
|
1278
1254
|
context "should return correct composition for 'terra silicea spec..'" do
|
1279
|
-
string =
|
1255
|
+
string = "terra silicea spec. 810 mg, excipiens pro compresso"
|
1280
1256
|
composition = ParseComposition.from_string(string)
|
1281
|
-
specify { expect(composition.source).to eq string}
|
1257
|
+
specify { expect(composition.source).to eq string }
|
1282
1258
|
specify { expect(composition.label).to eq nil }
|
1283
1259
|
specify { expect(composition.label_description).to eq nil }
|
1284
1260
|
specify { expect(composition.galenic_form).to eq nil }
|
1285
1261
|
specify { expect(composition.route_of_administration).to eq nil }
|
1286
|
-
specify { expect(
|
1262
|
+
specify { expect(composition.substances.first.name).to eq "Terra Silicea Spec." }
|
1287
1263
|
end
|
1288
1264
|
|
1289
1265
|
context "should return correct composition for 'minoxidilum'" do
|
1290
|
-
string =
|
1266
|
+
string = "minoxidilum 2.5 mg"
|
1291
1267
|
composition = ParseComposition.from_string(string)
|
1292
1268
|
specify { expect(composition.source).to eq string }
|
1293
1269
|
specify { expect(composition.label).to eq nil }
|
@@ -1295,13 +1271,13 @@ Corresp. 5190 kJ pro 1 l."
|
|
1295
1271
|
specify { expect(composition.galenic_form).to eq nil }
|
1296
1272
|
specify { expect(composition.route_of_administration).to eq nil }
|
1297
1273
|
substance = composition.substances.first
|
1298
|
-
specify { expect(substance.name).to eq
|
1274
|
+
specify { expect(substance.name).to eq "Minoxidilum" }
|
1299
1275
|
specify { expect(substance.qty).to eq 2.5 }
|
1300
|
-
specify { expect(substance.unit).to eq
|
1276
|
+
specify { expect(substance.unit).to eq "mg" }
|
1301
1277
|
end
|
1302
1278
|
|
1303
1279
|
context "should return correct composition for 'minoxidilum'" do
|
1304
|
-
string =
|
1280
|
+
string = "minoxidilum"
|
1305
1281
|
composition = ParseComposition.from_string(string)
|
1306
1282
|
specify { expect(composition.source).to eq string }
|
1307
1283
|
specify { expect(composition.label).to eq nil }
|
@@ -1309,13 +1285,13 @@ Corresp. 5190 kJ pro 1 l."
|
|
1309
1285
|
specify { expect(composition.galenic_form).to eq nil }
|
1310
1286
|
specify { expect(composition.route_of_administration).to eq nil }
|
1311
1287
|
substance = composition.substances.first
|
1312
|
-
specify { expect(substance.name).to eq
|
1288
|
+
specify { expect(substance.name).to eq "Minoxidilum" }
|
1313
1289
|
specify { expect(substance.qty).to eq nil }
|
1314
1290
|
specify { expect(substance.unit).to eq nil }
|
1315
1291
|
end
|
1316
1292
|
|
1317
1293
|
context "should return correct composition for 'minoxidilum excipiens'" do
|
1318
|
-
string =
|
1294
|
+
string = "minoxidilum 2.5 mg, excipiens pro compresso."
|
1319
1295
|
composition = ParseComposition.from_string(string)
|
1320
1296
|
specify { expect(composition.source).to eq string }
|
1321
1297
|
specify { expect(composition.label).to eq nil }
|
@@ -1324,112 +1300,108 @@ Corresp. 5190 kJ pro 1 l."
|
|
1324
1300
|
specify { expect(composition.route_of_administration).to eq nil }
|
1325
1301
|
|
1326
1302
|
substance = composition.substances.first
|
1327
|
-
specify { expect(substance.name).to eq
|
1303
|
+
specify { expect(substance.name).to eq "Minoxidilum" }
|
1328
1304
|
specify { expect(substance.qty).to eq 2.5 }
|
1329
|
-
specify { expect(substance.unit).to eq
|
1330
|
-
skip
|
1305
|
+
specify { expect(substance.unit).to eq "mg" }
|
1306
|
+
skip "what is the correct name for excipiens?" # { expect(composition.substances.last.name).to eq 'Excipiens Pro Compresso' }
|
1331
1307
|
end
|
1332
1308
|
|
1333
|
-
context
|
1334
|
-
line_1 =
|
1335
|
-
line_2 =
|
1336
|
-
line_3 =
|
1337
|
-
line_4 =
|
1338
|
-
line_5 =
|
1309
|
+
context "find correct result compositions for nutriflex" do
|
1310
|
+
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."
|
1311
|
+
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."
|
1312
|
+
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."
|
1313
|
+
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."
|
1314
|
+
line_5 = "Corresp. 4000 kJ."
|
1339
1315
|
text = "#{line_1}\n#{line_2}\n#{line_3}\n#{line_4}\n#{line_5}"
|
1340
|
-
compositions =
|
1341
|
-
specify { expect(compositions.first.substances.first.name).to eq
|
1342
|
-
specify { expect(compositions.first.substances.first.salts.first.name).to eq
|
1343
|
-
specify { expect(compositions.size).to eq 5}
|
1344
|
-
specify { expect(compositions.first.substances.first.qty.to_f).to eq 150.0}
|
1345
|
-
specify { expect(compositions.first.substances.first.unit).to eq
|
1346
|
-
|
1347
|
-
specify { expect(compositions[0].source).to eq line_1}
|
1348
|
-
specify { expect(compositions[0].label).to eq
|
1349
|
-
specify { expect(compositions[0].label_description).to eq
|
1350
|
-
specify { expect(compositions[1].label).to eq
|
1351
|
-
specify { expect(compositions[2].label).to eq
|
1316
|
+
compositions = ParseUtil.parse_compositions(text, "glucosum anhydricum, zinci acetas dihydricus, isoleucinum, leucinum")
|
1317
|
+
specify { expect(compositions.first.substances.first.name).to eq "Glucosum Anhydricum" }
|
1318
|
+
specify { expect(compositions.first.substances.first.salts.first.name).to eq "Glucosum Monohydricum" }
|
1319
|
+
specify { expect(compositions.size).to eq 5 }
|
1320
|
+
specify { expect(compositions.first.substances.first.qty.to_f).to eq 150.0 }
|
1321
|
+
specify { expect(compositions.first.substances.first.unit).to eq "g/500 ml" }
|
1322
|
+
|
1323
|
+
specify { expect(compositions[0].source).to eq line_1 }
|
1324
|
+
specify { expect(compositions[0].label).to eq "I" }
|
1325
|
+
specify { expect(compositions[0].label_description).to eq "Glucoselösung" }
|
1326
|
+
specify { expect(compositions[1].label).to eq "II" }
|
1327
|
+
specify { expect(compositions[2].label).to eq "III" }
|
1352
1328
|
glucosum = compositions.first.substances.first
|
1353
|
-
specify { expect(glucosum.name).to eq
|
1354
|
-
specify { expect(glucosum.qty.to_f).to eq
|
1355
|
-
specify { expect(glucosum.unit).to eq
|
1329
|
+
specify { expect(glucosum.name).to eq "Glucosum Anhydricum" }
|
1330
|
+
specify { expect(glucosum.qty.to_f).to eq 150.0 }
|
1331
|
+
specify { expect(glucosum.unit).to eq "g/500 ml" }
|
1356
1332
|
specify { expect(compositions[0].substances.size).to eq 3 }
|
1357
1333
|
specify { expect(compositions[1].substances.size).to eq 5 } # should have glycerolum, natrii oleas, aqua
|
1358
1334
|
specify { expect(compositions[2].substances.size).to eq 4 }
|
1359
|
-
specify { expect(compositions[1].source).to eq line_2}
|
1360
|
-
specify { expect(compositions[2].source).to eq line_3}
|
1361
|
-
specify { expect(compositions[3].source).to eq line_4}
|
1362
|
-
specify { expect(compositions[3].corresp).to eq line_4.sub(/\.$/,
|
1363
|
-
specify { expect(compositions[4].source).to eq line_5}
|
1364
|
-
specify { expect(compositions[4].corresp).to eq
|
1335
|
+
specify { expect(compositions[1].source).to eq line_2 }
|
1336
|
+
specify { expect(compositions[2].source).to eq line_3 }
|
1337
|
+
specify { expect(compositions[3].source).to eq line_4 }
|
1338
|
+
specify { expect(compositions[3].corresp).to eq line_4.sub(/\.$/, "") }
|
1339
|
+
specify { expect(compositions[4].source).to eq line_5 }
|
1340
|
+
specify { expect(compositions[4].corresp).to eq "4000 kJ" }
|
1365
1341
|
|
1366
1342
|
# from II)
|
1367
|
-
if compositions
|
1368
|
-
lecithinum =
|
1369
|
-
specify { expect(lecithinum).not_to eq nil}
|
1343
|
+
if compositions && compositions[1] && compositions[1].substances
|
1344
|
+
lecithinum = compositions[1].substances.find { |x| x.name.match(/lecithinum/i) }
|
1345
|
+
specify { expect(lecithinum).not_to eq nil }
|
1370
1346
|
if lecithinum
|
1371
|
-
specify { expect(lecithinum.name).to eq
|
1372
|
-
specify { expect(lecithinum.qty.to_f).to eq
|
1373
|
-
specify { expect(lecithinum.unit).to eq
|
1347
|
+
specify { expect(lecithinum.name).to eq "Lecithinum Ex Ovo" }
|
1348
|
+
specify { expect(lecithinum.qty.to_f).to eq 3.0 }
|
1349
|
+
specify { expect(lecithinum.unit).to eq "g/250 ml" }
|
1374
1350
|
end
|
1375
1351
|
|
1376
1352
|
# From III
|
1377
|
-
leucinum =
|
1378
|
-
specify { expect(leucinum).not_to eq nil}
|
1353
|
+
leucinum = compositions[2].substances.find { |x| x.name.eql?("Leucinum") }
|
1354
|
+
specify { expect(leucinum).not_to eq nil }
|
1379
1355
|
if leucinum
|
1380
|
-
specify { expect(leucinum.name).to eq
|
1381
|
-
specify { expect(leucinum.qty.to_f).to eq
|
1382
|
-
specify { expect(leucinum.unit).to eq
|
1356
|
+
specify { expect(leucinum.name).to eq "Leucinum" }
|
1357
|
+
specify { expect(leucinum.qty.to_f).to eq 3.13 }
|
1358
|
+
specify { expect(leucinum.unit).to eq "g/400 ml" }
|
1383
1359
|
end
|
1384
|
-
|
1385
|
-
specify { expect(
|
1386
|
-
|
1387
|
-
specify { expect(
|
1388
|
-
|
1389
|
-
|
1360
|
+
leucinum_i = compositions[0].substances.find { |x| x.name.eql?("Leucinum") }
|
1361
|
+
specify { expect(leucinum_i).to eq nil }
|
1362
|
+
leucinum_ii = compositions[1].substances.find { |x| x.name.eql?("Leucinum") }
|
1363
|
+
specify { expect(leucinum_ii).to eq nil }
|
1364
|
+
# aqua = compositions[2].substances.find{ |x| /aqua ad/i.match(x.name) }
|
1365
|
+
# specify { expect(aqua.name).to eq "Aqua Ad Iniectabilia Q.s. Ad Solutionem Pro"}
|
1390
1366
|
end
|
1391
|
-
|
1392
|
-
end
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
describe ParseUtil::HandleSwissmedicErrors do
|
1397
|
-
context 'should handle fixes' do
|
1398
|
-
replacement = '\1, \2'
|
1399
|
-
pattern_replacement = { /(sulfuris D6\s[^\s]+\smg)\s([^,]+)/ => replacement }
|
1400
|
-
test_string = 'sulfuris D6 2,2 mg hypericum perforatum D2 0,66'
|
1401
|
-
expected = 'sulfuris D6 2,2 mg, hypericum perforatum D2 0,66'
|
1402
|
-
handler = ParseUtil::HandleSwissmedicErrors.new(pattern_replacement )
|
1403
|
-
result = handler.apply_fixes(test_string)
|
1404
|
-
specify { expect(result).to eq expected }
|
1405
|
-
specify { expect(handler.report.size).to eq 2 }
|
1406
|
-
specify { expect(/report/i.match(handler.report[0]).class).to eq MatchData }
|
1407
|
-
specify { expect(handler.report[1].index(replacement).class).to eq Fixnum }
|
1408
1367
|
end
|
1409
1368
|
|
1369
|
+
describe ParseUtil::HandleSwissmedicErrors do
|
1370
|
+
context "should handle fixes" do
|
1371
|
+
replacement = '\1, \2'
|
1372
|
+
pattern_replacement = {/(sulfuris D6\s[^\s]+\smg)\s([^,]+)/ => replacement}
|
1373
|
+
test_string = "sulfuris D6 2,2 mg hypericum perforatum D2 0,66"
|
1374
|
+
expected = "sulfuris D6 2,2 mg, hypericum perforatum D2 0,66"
|
1375
|
+
handler = ParseUtil::HandleSwissmedicErrors.new(pattern_replacement)
|
1376
|
+
result = handler.apply_fixes(test_string)
|
1377
|
+
specify { expect(result).to eq expected }
|
1378
|
+
specify { expect(handler.report.size).to eq 2 }
|
1379
|
+
specify { expect(/report/i.match(handler.report[0]).class).to eq MatchData }
|
1380
|
+
specify { expect(handler.report[1].index(replacement).class).to eq Integer }
|
1381
|
+
end
|
1410
1382
|
end
|
1411
1383
|
end
|
1412
1384
|
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|line|
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1385
|
+
if RUN_ALL_COMPOSITION_TESTS
|
1386
|
+
describe ParseComposition do
|
1387
|
+
context "should parse a complex composition" do
|
1388
|
+
start_time = Time.now
|
1389
|
+
specify { expect(File.exist?(AllCompositionLines)).to eq true }
|
1390
|
+
inhalt = IO.readlines(AllCompositionLines)
|
1391
|
+
nr = 0
|
1392
|
+
@nr_errors = 0
|
1393
|
+
inhalt.each { |line|
|
1394
|
+
nr += 1
|
1395
|
+
next if line.length < 5
|
1396
|
+
puts "#{File.basename(AllCompositionLines)}:#{nr} #{@nr_errors} errors: #{line}" if VERBOSE_MESSAGES
|
1397
|
+
begin
|
1398
|
+
ParseComposition.from_string line
|
1399
|
+
rescue Parslet::ParseFailed
|
1400
|
+
@nr_errors += 1
|
1401
|
+
puts "#{File.basename(AllCompositionLines)}:#{nr} parse_error #{@nr_errors} in: #{line}"
|
1402
|
+
end
|
1403
|
+
}
|
1404
|
+
at_exit { puts "Testing whether #{nr} composition lines can be parsed. Found #{@nr_errors} errors in #{(Time.now - start_time).to_i} seconds" }
|
1430
1405
|
end
|
1431
|
-
}
|
1432
|
-
at_exit { puts "Testing whether #{nr} composition lines can be parsed. Found #{@nrErrors} errors in #{(Time.now - start_time).to_i} seconds" }
|
1433
|
-
|
1434
1406
|
end
|
1435
|
-
end
|
1407
|
+
end
|