oddb2xml 2.0.6 → 2.0.7
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 +8 -8
- data/Gemfile.lock +1 -1
- data/History.txt +13 -0
- data/dokumentation_calc.textile +30 -24
- data/lib/oddb2xml/builder.rb +32 -19
- data/lib/oddb2xml/calc.rb +10 -1
- data/lib/oddb2xml/compositions_syntax.rb +220 -151
- data/lib/oddb2xml/parslet_compositions.rb +148 -323
- data/lib/oddb2xml/version.rb +1 -1
- data/spec/calc_spec.rb +19 -13
- data/spec/composition_syntax_spec.rb +39 -40
- data/spec/data/swissmedic_package-galenic.xlsx +0 -0
- data/spec/parslet_spec.rb +320 -213
- data/spec/spec_helper.rb +0 -1
- metadata +2 -2
@@ -6,57 +6,50 @@ require 'parslet/rig/rspec'
|
|
6
6
|
require 'parslet/convenience'
|
7
7
|
|
8
8
|
RunAllParsingExamples = false # Takes over 3 minutes to run, all the other ones just a few seconds
|
9
|
-
GoIntoPry =
|
9
|
+
GoIntoPry = true
|
10
|
+
NoGoIntoPry = false
|
11
|
+
|
12
|
+
if GoIntoPry
|
13
|
+
|
10
14
|
describe CompositionParser do
|
11
15
|
let(:parser) { CompositionParser.new }
|
12
16
|
context "identifier parsing" do
|
13
17
|
let(:dose_parser) { parser.dose }
|
14
18
|
let(:identifier_parser) { parser.identifier }
|
19
|
+
let(:identifier_with_comma_parser) { parser.identifier_with_comma }
|
20
|
+
let(:identifier_without_comma_parser) { parser.identifier_without_comma }
|
15
21
|
let(:substance_parser) { parser.substance }
|
22
|
+
let(:salts_parser) { parser.salts }
|
16
23
|
let(:substance_name_parser) { parser.substance_name }
|
17
24
|
let(:number_parser) { parser.number }
|
25
|
+
let(:excipiens_parser) { parser.excipiens }
|
26
|
+
let(:composition_parser) { parser.composition }
|
18
27
|
|
19
28
|
it "parses identifier" do
|
20
|
-
|
29
|
+
res1 = substance_parser.parse_with_debug('pollinis allergeni extractum (alnus glutinosa, betula alba, corylus avellana) 300 U.: excipiens ad solutionem pro 1 ml')
|
21
30
|
pp res1
|
22
31
|
binding.pry
|
23
|
-
|
24
|
-
end
|
25
|
-
end if false
|
26
|
-
describe CompositionParser do
|
27
|
-
let(:parser) { CompositionParser.new }
|
28
|
-
context "should help me find problems" do
|
29
|
-
let(:substance_name_parser) { parser.substance_name }
|
30
|
-
|
31
|
-
it "parses substance_name my manual test" do
|
32
|
-
res1 = substance_name_parser.parse_with_debug(
|
33
|
-
'calendula officinalis D2' )
|
32
|
+
res1 = excipiens_parser.parse_with_debug "excipiens ad emulsionem pro 1 g"
|
34
33
|
pp res1
|
35
|
-
res2 = substance_name_parser.parse_with_debug( 'macrogolum 3350' )
|
36
|
-
pp res2
|
37
|
-
res3 = substance_name_parser.parse_with_debug( 'virus poliomyelitis typus inactivatum' )
|
38
|
-
pp res3
|
39
34
|
binding.pry
|
40
|
-
|
41
|
-
end
|
42
|
-
context "should help me find problems" do
|
43
|
-
let(:substance_parser) { parser.substance }
|
44
|
-
|
45
|
-
it "parses substance my manual test" do
|
46
|
-
res1 = substance_parser.parse_with_debug(
|
47
|
-
'calendula officinalis D2 2,2 mg' )
|
35
|
+
res1 = substance_parser.parse_with_debug "excipiens ad emulsionem pro 1 g"
|
48
36
|
pp res1
|
49
|
-
|
37
|
+
binding.pry
|
38
|
+
res2 = substance_parser.parse_with_debug "excipiens ad solutionem pro 1 ml corresp. 50 µg pro dosi"
|
50
39
|
pp res2
|
51
|
-
res3 = substance_parser.parse_with_debug(
|
52
|
-
'calendula officinalis D2' )
|
53
|
-
pp res3
|
54
40
|
binding.pry
|
41
|
+
res1 = substance_name_parser.parse_with_debug("argenti nitras aquos. D13")
|
42
|
+
|
43
|
+
string =
|
44
|
+
"chlorhexidini digluconas 1 mg, aromatica, color.: corresp. ethanolum 8.5 % V/V, E 127, excipiens ad solutionem pro 1 ml"
|
45
|
+
res2 = composition_parser.parse_with_debug(string)
|
46
|
+
res2 = substance_parser.parse_with_debug(string)
|
47
|
+
pp res1
|
55
48
|
end
|
56
|
-
end
|
57
|
-
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
else
|
58
52
|
|
59
|
-
unless GoIntoPry
|
60
53
|
excipiens_tests = {
|
61
54
|
'aether q.s. ad solutionem pro 1 g' => 'aether q.s. ad solutionem',
|
62
55
|
'saccharum ad globulos pro 1 g' => 'saccarum',
|
@@ -78,6 +71,8 @@ excipiens_tests = {
|
|
78
71
|
}
|
79
72
|
|
80
73
|
substance_tests = {
|
74
|
+
'pollinis allergeni extractum (alnus glutinosa, betula alba, corylus avellana) 300 U.: excipiens ad solutionem pro 1 ml' => 'zzz',
|
75
|
+
'pollinis allergeni extractum (alnus glutinosa, betula alba, corylus avellana)' => 'xxx',
|
81
76
|
"U = Histamin Equivalent Prick" => 'U = Histamin Equivalent Prick', # 58566
|
82
77
|
"Vipera aspis > 1000 LD50 mus et Vipera berus > 500 LD50, natrii chloridum" => "Vipera Aspis > 1000 Ld50 Mus",
|
83
78
|
"Vipera aspis > 1000 LD50 mus et Vipera berus > 500 LD50, natrii chloridum, polysorbatum 80" => "Vipera Aspis > 1000 Ld50 Mus",
|
@@ -329,6 +324,10 @@ describe CompositionParser do
|
|
329
324
|
'pollinis allergeni extractum (Phleum pratense) 10 U.',
|
330
325
|
'phenoxymethylpenicillinum kalicum 1 U.I.',
|
331
326
|
'phenoxymethylpenicillinum kalicum 1 Mio. U.I.',
|
327
|
+
'DER: 1:4',
|
328
|
+
'DER: 3-5:1',
|
329
|
+
'DER: 6-8:1',
|
330
|
+
'DER: 4.0-9.0:1',
|
332
331
|
'retinoli palmitas 7900 U.I.',
|
333
332
|
].each {
|
334
333
|
|id|
|
@@ -337,12 +336,16 @@ describe CompositionParser do
|
|
337
336
|
end
|
338
337
|
}
|
339
338
|
it "parses substance calcium, zwei" do expect(substance_parser).to_not parse("calcium, zwei") end
|
339
|
+
end
|
340
|
+
|
341
|
+
context "excipiens parsing" do
|
342
|
+
let(:excipiens_parser) { parser.excipiens }
|
340
343
|
|
341
344
|
puts "Testing whether #{excipiens_tests.size} excipiens can be parsed"
|
342
|
-
let(:
|
345
|
+
let(:excipiens_parser) { parser.excipiens }
|
343
346
|
excipiens_tests.each{
|
344
347
|
|value, name|
|
345
|
-
it "parses
|
348
|
+
it "parses excipiens #{value}" do expect(excipiens_parser).to parse(value) end
|
346
349
|
}
|
347
350
|
|
348
351
|
end
|
@@ -417,10 +420,6 @@ describe CompositionParser do
|
|
417
420
|
'virus poliomyelitis typus 1 inactivatum (D-Antigen)',
|
418
421
|
'stanni(II) chloridum dihydricum',
|
419
422
|
'ethanol.',
|
420
|
-
'DER: 1:4',
|
421
|
-
'DER: 3-5:1',
|
422
|
-
'DER: 6-8:1',
|
423
|
-
'DER: 4.0-9.0:1',
|
424
423
|
'calendula officinalis D2',
|
425
424
|
# "Viperis Antitoxinum Equis F(ab')2", swissmedic patch, as only one occurrence
|
426
425
|
"xenonum(133-Xe)",
|
@@ -475,7 +474,7 @@ describe CompositionParser do
|
|
475
474
|
expect(composition_parser).to parse(value)
|
476
475
|
end
|
477
476
|
}
|
478
|
-
puts "Testing whether #{substance_tests.size} substances can be parsed"
|
477
|
+
puts "Testing whether #{substance_tests.size} substances can be parsed as composition"
|
479
478
|
substance_tests.each{
|
480
479
|
|value, name|
|
481
480
|
it "parses substance #{value}" do
|
@@ -499,4 +498,4 @@ describe CompositionParser do
|
|
499
498
|
end
|
500
499
|
|
501
500
|
end
|
502
|
-
end
|
501
|
+
end
|
Binary file
|