oddb2xml 2.0.1 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82754e27fde87282a1643f1acb81a8e30f2bee99
4
- data.tar.gz: 13ae8919c8572bf3d8bf3261802a096bbab9ead2
3
+ metadata.gz: 91e209f6f384705d053e56609465c69349b2f09b
4
+ data.tar.gz: fee149a15fe84a106f74aa3b9c5018ea9a641951
5
5
  SHA512:
6
- metadata.gz: 74e386dab573b605b60e3e4fd92740f1ab482b546e41998bd51e60105361bb8c2164723098a24bec2c64e43ff4c338612c6212806c22748c94077788bca59967
7
- data.tar.gz: 785ab82c497388b1278c5dba170e9318fdec62fe223fa4fa4a7aa22be3100b3094339d74d29bf7f9bb03f8fa758c8e2d9131d6e2d08ea09d3ae9873ff4a34572
6
+ metadata.gz: 13362a32f7f7c3f3bcf63826a7ead70e03678cd219439e2c88f87a3d2ac082ade71093790b2d6a2c59f86094e1c91152cf88fddbee5e3407f98f93be40e1f1e1
7
+ data.tar.gz: 3afe7a0686b90a0c1c33cde46fdd82f8f057d3ea2cb2decadcd2e07f0a796ee984b9fbdb2ce95d424c639d0bcc8e0c388adef0626c4e55e2dfd3916294b1c56c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (2.0.0)
4
+ oddb2xml (2.0.2)
5
5
  archive-tar-minitar (~> 0.5.2)
6
6
  mechanize (~> 2.5.1)
7
7
  nokogiri (~> 1.5.10)
@@ -1,3 +1,7 @@
1
+ === 2.0.2 / 24.03.2015
2
+
3
+ * Fixed handling of chemicals and units with '%'
4
+
1
5
  === 2.0.1 / 17.03.2015
2
6
 
3
7
  * Readded description for label
@@ -41,16 +41,16 @@ module ParseUtil
41
41
  components = line.split(/([^\(]+\([^)]+\)[^,]+|),/).each {
42
42
  |component|
43
43
  next unless component.size > 0
44
- to_consider = component.strip.split(':')[-1] # remove label
44
+ to_consider = component.strip.split(':')[-1].gsub(to_1, rep_1).gsub(to_2, rep_2).gsub(to_3, rep_3) # remove label
45
45
  # very ugly hack to ignore ,()
46
- m = /^(?<name>[^,\d()]+)\s*(?<dose>[\d\-.]+(\s*(?:(Mio\.?\s*)?(U\.\s*Ph\.\s*Eur\.|[^\s,]+))))/.match(to_consider
47
- .gsub(to_1, rep_1).gsub(to_2, rep_2).gsub(to_3, rep_3))
46
+ ptrn1 = /^(?<name>.+)\s+(?<dose>[\d\-.]+(\s*(?:(Mio\.?\s*)?(U\.\s*Ph\.\s*Eur\.|[^\s,]+))))/
47
+ m = ptrn1.match(to_consider)
48
48
  if m2 = /^(|[^:]+:\s)(E\s+\d+)$/.match(component.strip)
49
49
  to_add = ParseSubstance.new(m2[2], '', '')
50
50
  substances << to_add
51
51
  elsif m
52
52
  ptrn = /(\s*(?:ut|corresp\.?)\s+(?<chemical>[^\d,]+)\s*(?<cdose>[\d\-.]+(\s*(?:(Mio\.?\s*)?(U\.\s*Ph\.\s*Eur\.|[^\s,]+))(\s*[mv]\/[mv])?))?)/
53
- m3 = ptrn.match(component.strip)
53
+ m3 = ptrn.match(to_consider)
54
54
  dose = nil
55
55
  unit = nil
56
56
  name = m[:name].split(/\s/).collect{ |x| x.capitalize }.join(' ').strip.gsub(rep_3, to_3).gsub(rep_2, to_2).gsub(rep_1, to_1)
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -468,12 +468,45 @@ Corresp. 5300 kJ.",
468
468
  sennosidum = info.compositions.first.substances.find{ |x| x.name.match(/Sennae/i) }
469
469
  specify { expect(sennosidum).not_to eq nil}
470
470
  if sennosidum
471
- specify { expect(sennosidum.name).to eq 'Sennae Folii Extractum Methanolicum Siccum' }
471
+ specify { expect(sennosidum.name).to eq 'Sennae Folii Extractum Methanolicum Siccum 78-104 Mg Corresp. Sennosidum B' }
472
472
  specify { expect(sennosidum.chemical_substance).to eq 'Sennosidum B' }
473
473
  specify { expect(sennosidum.chemical_dose).to eq '12.5 mg' }
474
- specify { expect(sennosidum.qty).to eq 78.0}
474
+ specify { expect(sennosidum.qty).to eq 12.5}
475
475
  specify { expect(sennosidum.unit).to eq 'mg'}
476
476
  end
477
477
  end
478
478
 
479
- end
479
+ context 'find correct result compositions for fluticasoni with chemical_dose' do
480
+ info = ParseUtil.parse_compositions('fluticasoni-17 propionas 100 µg, lactosum monohydricum q.s. ad pulverem pro 25 mg.')
481
+ specify { expect(info.size).to eq 1 }
482
+ specify { expect(info.first.substances.size).to eq 1 }
483
+ fluticasoni = info.first.substances.find{ |x| x.name.match(/Fluticasoni/i) }
484
+ specify { expect(fluticasoni.name).to eq 'Fluticasoni-17 Propionas' }
485
+ specify { expect(fluticasoni.qty).to eq 100.0 }
486
+ specify { expect(fluticasoni.unit).to eq 'µg/25 mg' }
487
+ lactosum = info.first.substances.find{ |x| x.name.match(/Lactosum/i) }
488
+ specify { expect(lactosum).to eq nil }
489
+ end
490
+
491
+ context 'find correct result compositions for stuff with percents' do
492
+ txt = 'calcium carbonicum hahnemanni C7 5 %, chamomilla recutita D5 22.5 %, magnesii hydrogenophosphas trihydricus C5 50 %, passiflora incarnata D5 22.5 %, xylitolum, excipiens ad globulos.'
493
+ info = ParseUtil.parse_compositions(txt)
494
+ specify { expect(info.size).to eq 1 }
495
+ specify { expect(info.first.substances.size).to eq 4 }
496
+ recutita = info.first.substances.find{ |x| x.name.match(/recutita/i) }
497
+ specify { expect(recutita.name).to eq 'Chamomilla Recutita D5' }
498
+ specify { expect(recutita.qty).to eq 22.5 }
499
+ specify { expect(recutita.unit).to eq '%' }
500
+ end
501
+
502
+ context 'find correct result compositions for procainum with chemical_dose' do
503
+ txt = 'procainum 10 mg ut procaini hydrochloridum, phenazonum 50 mg, Antiox.: E 320, glycerolum q.s. ad solutionem pro 1 g.'
504
+ info = ParseUtil.parse_compositions(txt)
505
+ specify { expect(info.size).to eq 1 }
506
+ specify { expect(info.first.substances.size).to eq 3 }
507
+ procainum = info.first.substances.find{ |x| x.name.match(/procainum/i) }
508
+ specify { expect(procainum.name).to eq 'Procainum' }
509
+ specify { expect(procainum.qty).to eq 10.0 }
510
+ specify { expect(procainum.unit).to eq 'mg/g' }
511
+ end
512
+ end
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.0.1
4
+ version: 2.0.2
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-03-17 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip