oddb2xml 2.1.4 → 2.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efe088433407017fa298a6e78834bbe34d4490f4
4
- data.tar.gz: f4d2f7b5324fd72230a1b849c972955f71e5c16b
3
+ metadata.gz: c23ad09144021304d4c843e68e223d7071fa6f45
4
+ data.tar.gz: 28469d65080b256c22ddece82312e8a580144dfa
5
5
  SHA512:
6
- metadata.gz: 4f7fd0a26a4ee072b4e1ff34dde9ba121278786b111e1f827252df903578eff88bc4e049fb59146b53b7477ce0831eb9d1bf14e629105014131326c6b9c9760b
7
- data.tar.gz: 2133aea32f7d76524f25807749366cf8cfdac260b1c01845ebecb8503ab47eff892355cdcaf65aded3805aa8bcf3293f7c087f695457bbf98a23f31f73c5496c
6
+ metadata.gz: 1741fd3f64f4b735062b4e456e4643b673cb5bf9a31ce4fad59737b95ac3102d35c13d804796947fbc2602f8940d2aa3fe5b46dcb6d886cfb349dc3279f5dc4f
7
+ data.tar.gz: 6e75c9e2f02ef5811e2f6227bf5c82da6111b5d030aaa2bdbaeda1fd36220b4882d128075070670a7493cc444a60e8f2b39d72c285f11de51f7b69c7352898a5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (2.1.4)
4
+ oddb2xml (2.1.5)
5
5
  archive-tar-minitar (~> 0.5.2)
6
6
  mechanize (~> 2.5.1)
7
7
  nokogiri (~> 1.5.10)
@@ -1,3 +1,9 @@
1
+ === 2.1.5 / 03.06.2015
2
+
3
+ * Give substances for lines starting with Solvens
4
+ * Emit label Solvens when line stars with Solvens
5
+ * Don't emit SUBSTANCES if no substance is contained
6
+
1
7
  === 2.1.4 / 02.06.2015
2
8
 
3
9
  * Consider changes in ATC-codes by EPha
@@ -713,12 +713,14 @@ module Oddb2xml
713
713
  info.compositions.each { |composition|
714
714
  xml.COMPOSITION {
715
715
  xml.EXCIPIENS { emit_substance(xml, composition.excipiens) } if composition.excipiens
716
- xml.CORRESP composition.corresp if composition.corresp
717
716
  xml.LABEL composition.label if composition.label
718
717
  xml.LABEL_DESCRIPTION composition.label_description if composition.label_description
719
- xml.SUBSTANCES {
720
- composition.substances.each { |substance| xml.SUBSTANCE { emit_substance(xml, substance, true) }}
721
- } if composition.substances
718
+ xml.CORRESP composition.corresp if composition.corresp
719
+ if composition.substances and composition.substances.size > 0
720
+ xml.SUBSTANCES {
721
+ composition.substances.each { |substance| xml.SUBSTANCE { emit_substance(xml, substance, true) }}
722
+ }
723
+ end
722
724
  }
723
725
  }
724
726
  }
@@ -399,9 +399,6 @@ class CompositionParser < Parslet::Parser
399
399
  str('doses ') |
400
400
  str('Pulver: ') |
401
401
  str('Diluens: ') |
402
- str('Solvens (i.v.): ') |
403
- str('Solvens (i.m.): ') |
404
- str('Solvens: ') |
405
402
  str('Solutio reconstituta:') |
406
403
  str('Corresp., ') |
407
404
  str('Corresp. ') |
@@ -412,6 +409,13 @@ class CompositionParser < Parslet::Parser
412
409
  }
413
410
  rule(:corresp_line_neu) { corresp_label >> any.repeat(1).as(:corresp) }
414
411
 
412
+ rule(:solvens_label) {
413
+ str('Solvens (i.v.)') |
414
+ str('Solvens (i.m.)') |
415
+ str('Solvens')
416
+ }
417
+ rule(:solvens_line) { solvens_label.as(:label) >> (str(': ') >> composition.repeat(1).as(:composition) | any.repeat(1).as(:corresp))}
418
+
415
419
  rule(:multiple_et_line) {
416
420
  ((label_id >> label_separator >> space? >> (str('pro usu') |str('et '))).repeat(1) >> any.repeat(1)).as(:corresp)
417
421
  }
@@ -425,6 +429,7 @@ class CompositionParser < Parslet::Parser
425
429
  composition.as(:composition) }
426
430
 
427
431
  rule(:expression_comp) {
432
+ solvens_line |
428
433
  multiple_et_line |
429
434
  label_id_composition |
430
435
  corresp_line_neu |
@@ -435,6 +440,18 @@ class CompositionParser < Parslet::Parser
435
440
  space.repeat(3)
436
441
  }
437
442
 
443
+ rule(:expression_compD) {
444
+ solvens_line |
445
+ multiple_et_line.as('multiple_et_line') |
446
+ label_id_composition.as('label_id_composition') |
447
+ corresp_line_neu.as('corresp_line_neu') |
448
+ leading_label.maybe >> space? >> composition.as(:composition) >> space? >> str('.').maybe >> space? |
449
+ polvac.as('polvac') |
450
+ label_comment_excipiens.as('label_comment_excipiens') |
451
+ excipiens.as(:composition) |
452
+ space.repeat(3)
453
+ }
454
+
438
455
  root :expression_comp
439
456
  end
440
457
 
@@ -441,6 +441,7 @@ class ParseComposition
441
441
  end
442
442
  result.label_description = label_description.gsub(/:+$/, '').strip if label_description
443
443
  end
444
+ result.corresp = ast[:corresp].to_s.sub(/:\s+/, '') if not result.corresp and ast.is_a?(Hash) and ast[:corresp]
444
445
  return result
445
446
  end
446
447
  end
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "2.1.4"
2
+ VERSION = "2.1.5"
3
3
  end
@@ -142,6 +142,16 @@ Corresp. 5300 kJ.",
142
142
  )
143
143
 
144
144
  if RunAllTests
145
+ context 'should parse Solvens:' do
146
+ text = 'Solvens: conserv.: alcohol benzylicus 18 mg, aqua ad iniectabilia q.s. ad solutionem pro 2 ml.'
147
+ info = Calc.new('Solu-Cortef 100 mg, Injektions-/Infusionspräparat', nil, nil,
148
+ 'hydrocortisonum',
149
+ text
150
+ )
151
+ specify { expect(info.compositions.first.substances.first.name).to eq "Alcohol Benzylicus" }
152
+ specify { expect(info.compositions.first.substances.size).to eq 1 }
153
+ end
154
+
145
155
  context "adapt ATC for epha 16105 C05BA" do
146
156
  specify { expect(Oddb2xml.add_epha_changes_for_ATC(16105, 'C05BA')).to eq 'C05BA01' }
147
157
  end
@@ -311,9 +321,9 @@ if RunAllTests
311
321
  File.exists?(oddb_calc_xsd).should eq true
312
322
  xsd = Nokogiri::XML::Schema(File.read(oddb_calc_xsd))
313
323
  doc = Nokogiri::XML(File.read(xml_file_name))
324
+ # puts xml; binding.pry
314
325
  xsd.validate(doc).each do |error| expect(error).to be_nil end
315
326
  doc = REXML::Document.new xml
316
- # puts xml; binding.pry
317
327
  gtin = '7680540151009'
318
328
  ean12 = '7680' + sprintf('%05d',tst_naropin.iksnr_A) + sprintf('%03d',tst_naropin.pack_K)
319
329
  ean13 = (ean12 + Oddb2xml.calc_checksum(ean12))
@@ -23,12 +23,12 @@ let(:parser) { CompositionParser.new }
23
23
  let(:substance_name_parser) { parser.substance_name }
24
24
  let(:number_parser) { parser.number }
25
25
  let(:excipiens_parser) { parser.excipiens }
26
- let(:composition_parser) { parser.composition }
26
+ let(:composition_parser) { parser }
27
27
 
28
28
  it "parses identifier" do
29
- res1 = substance_parser.parse_with_debug('pollinis allergeni extractum (alnus glutinosa, betula alba, corylus avellana) 300 U.: excipiens ad solutionem pro 1 ml')
30
- pp res1
31
- # binding.pry
29
+ text = 'Solvens: conserv.: alcohol benzylicus 18 mg, aqua ad iniectabilia q.s. ad solutionem pro 2 ml.'
30
+ res1 = composition_parser.parse_with_debug(text)
31
+ pp res1; binding.pry
32
32
  end
33
33
  end
34
34
  end
@@ -24,23 +24,9 @@ to_add = %(
24
24
  pp composition; binding.pry
25
25
  )
26
26
 
27
- context "should handle failed" do
28
- strings = [
29
- ]
30
- strings.each{ |string|
31
- composition = ParseComposition.from_string(string)
32
- binding.pry if composition.substances.size == 0
33
- specify { expect( composition.substances.size).not_to eq 0 }
34
- }
35
- end
36
-
37
27
  end
38
28
 
39
29
  if RunFailingSpec
40
- describe ParseComposition do
41
-
42
- end
43
-
44
30
  end
45
31
 
46
32
  describe ParseComposition do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhiro Asaka, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip