oddb2xml 2.4.4 → 2.4.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 +4 -4
- data/History.txt +7 -0
- data/lib/oddb2xml/builder.rb +3 -2
- data/lib/oddb2xml/extractor.rb +2 -2
- data/lib/oddb2xml/parslet_compositions.rb +3 -5
- data/lib/oddb2xml/version.rb +1 -1
- data/spec/builder_spec.rb +4 -6
- data/spec/calc_spec.rb +11 -0
- data/spec/parslet_spec.rb +32 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 952fe0868841bf075f3db7cd128326004b2ab2bf
|
4
|
+
data.tar.gz: c026575530d35d1ef75ff9b3ac4688f647d07427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4baa838d2b817cfd994882092585e768a4375f82e3bb4843d083ade252666f939628129fa4bfecd709c36f63e81168dd2f996c5dd1f2cae6fbacb05e578a37e
|
7
|
+
data.tar.gz: c839a38f2739a18c515d5b90b7c64c9dd7f8dff06c17ea0a549a106dbc95faded479ae986bed4575c3780d0492f420b18c99ff568057e99e273454da70bcbf85
|
data/History.txt
CHANGED
data/lib/oddb2xml/builder.rb
CHANGED
@@ -220,6 +220,7 @@ module Oddb2xml
|
|
220
220
|
@refdata.each_pair do |ean13, item|
|
221
221
|
next if item and item.is_a?(Hash) and item[:atc_code] and /^Q/i.match(item[:atc_code])
|
222
222
|
next if item[:prodno] and @products[item[:prodno]]
|
223
|
+
next unless ean13.to_s.length == 13
|
223
224
|
obj = {
|
224
225
|
:seq => @items[ean13] ? @items[ean13] : @items[item[:ean]],
|
225
226
|
:pac => nil,
|
@@ -808,7 +809,7 @@ module Oddb2xml
|
|
808
809
|
if obj[:seq]
|
809
810
|
pac = obj[:seq][:packages][obj[:pharmacode]]
|
810
811
|
pac = obj[:seq][:packages][ean] unless pac
|
811
|
-
|
812
|
+
elsif ean > 0
|
812
813
|
pac = @items[ean][:packages][ean] if @items and ean and @items[ean] and @items[ean][:packages]
|
813
814
|
end
|
814
815
|
if no8
|
@@ -922,7 +923,7 @@ module Oddb2xml
|
|
922
923
|
xml.BC /^9999|^0000|^0$/.match(ean.to_s) ? 0 : sprintf('%013d', ean)
|
923
924
|
xml.BCSTAT 'A' # P is alternative
|
924
925
|
#xml.PHAR2
|
925
|
-
} if ean
|
926
|
+
} if ean && ean > 0
|
926
927
|
#xml.ARTCH {
|
927
928
|
#xml.PHAR2
|
928
929
|
#xml.CHTYPE
|
data/lib/oddb2xml/extractor.rb
CHANGED
@@ -485,14 +485,14 @@ module Oddb2xml
|
|
485
485
|
ean13 = $1.to_i
|
486
486
|
end
|
487
487
|
if data[ean13]
|
488
|
-
@@error_file.puts "Duplicate ean13 #{ean13} in line \nact: #{line
|
488
|
+
@@error_file.puts "Duplicate ean13 #{ean13} in line \nact: #{line}\norg: #{data[ean13][:line]}"
|
489
489
|
@@items_without_ean13s -= 1
|
490
490
|
@@duplicated_ean13s += 1
|
491
491
|
next
|
492
492
|
end
|
493
493
|
|
494
494
|
data[ean13] = {
|
495
|
-
:line => line
|
495
|
+
:line => line,
|
496
496
|
:ean => ean13,
|
497
497
|
:clag => line[73],
|
498
498
|
:vat => line[96],
|
@@ -74,11 +74,9 @@ module ParseUtil
|
|
74
74
|
if composition.is_a?(ParseComposition)
|
75
75
|
composition.substances.each do
|
76
76
|
|substance_item|
|
77
|
-
|
77
|
+
active_substance_name = substance_item.name.downcase.sub(/^cum\s/, '')
|
78
|
+
substance_item.is_active_agent = (active_agents.find {|x| /#{x.downcase.gsub('(', '\(').gsub(')', '\)')}($|\s)/.match(active_substance_name) } != nil)
|
78
79
|
substance_item.is_active_agent = true if substance_item.chemical_substance and active_agents.find {|x| x.downcase.eql?(substance_item.chemical_substance.name.downcase) }
|
79
|
-
# next line is an ugly hack for 24 entries with names containing commas between brackets, eg.
|
80
|
-
# globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)
|
81
|
-
substance_item.is_active_agent = true if /globulina equina/.match(substance_item.name.downcase)
|
82
80
|
end
|
83
81
|
comps << composition
|
84
82
|
end
|
@@ -489,4 +487,4 @@ class ParseGalenicForm
|
|
489
487
|
name = ast[:prepation_name] ? ast[:prepation_name].to_s.strip : nil
|
490
488
|
return [name, form]
|
491
489
|
end
|
492
|
-
end
|
490
|
+
end
|
data/lib/oddb2xml/version.rb
CHANGED
data/spec/builder_spec.rb
CHANGED
@@ -309,6 +309,7 @@ def check_validation_via_xsd
|
|
309
309
|
|error|
|
310
310
|
if error.message
|
311
311
|
puts "Failed validating #{file} with #{File.size(file)} bytes using XSD from #{@oddb2xml_xsd}"
|
312
|
+
puts "cmd would be: xsdvalidate #{@oddb2xml_xsd} #{file}"
|
312
313
|
end
|
313
314
|
expect(error.message).to be_nil, "expected #{error.message} to be nil\nfor #{file} content \n#{File.read(file)}"
|
314
315
|
end
|
@@ -377,7 +378,6 @@ def checkArticleXml(checkERYTHROCIN = true)
|
|
377
378
|
|
378
379
|
desitin = checkAndGetArticleWithGTIN(doc, Oddb2xml::LEVETIRACETAM_GTIN)
|
379
380
|
expect(desitin).not_to eq nil
|
380
|
-
# TODO: why is this now nil? desitin.elements['ATC'].text.should == 'N03AX14'
|
381
381
|
expect(desitin.elements['DSCRD'].text).to eq("LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk")
|
382
382
|
expect(desitin.elements['DSCRF'].text).to eq('LEVETIRACETAM DESITIN mini cpr pel 250 mg 30 pce')
|
383
383
|
expect(desitin.elements['REF_DATA'].text).to eq('1')
|
@@ -405,7 +405,6 @@ def checkArticleXml(checkERYTHROCIN = true)
|
|
405
405
|
expect(zyvoxid.elements['DSCRD'].text).to eq 'ZYVOXID Filmtabl 600 mg 10 Stk'
|
406
406
|
|
407
407
|
expect(XPath.match( doc, "//LIMPTS" ).size).to be >= 1
|
408
|
-
# TODO: desitin.elements['QTY'].text.should eq '250 mg'
|
409
408
|
end
|
410
409
|
|
411
410
|
def checkProductXml(nbr_record = -1)
|
@@ -581,7 +580,7 @@ describe Oddb2xml::Builder do
|
|
581
580
|
m = /<paragraph><!\[CDATA\[(.+)\n(.*)/.match(inhalt.to_s)
|
582
581
|
expect(m[1]).to eq '<?xml version="1.0" encoding="utf-8"?><div xmlns="http://www.w3.org/1999/xhtml">'
|
583
582
|
expected = '<p class="s2"> </p>'
|
584
|
-
skip { m[2].
|
583
|
+
skip { expect(m[2]).to eq '<p class="s4" id="section1"><span class="s2"><span>Zyvoxid</span></span><sup class="s3"><span>®</span></sup></p>' }
|
585
584
|
expect(File.exists?(@oddb_fi_product_xml)).to eq true
|
586
585
|
inhalt = IO.read(@oddb_fi_product_xml)
|
587
586
|
end
|
@@ -881,7 +880,7 @@ if RUN_ALL
|
|
881
880
|
expect(File.exists?(oddb_article_xml)).to eq true
|
882
881
|
doc = REXML::Document.new IO.read(oddb_article_xml)
|
883
882
|
article = XPath.match( doc, "//ART[PHAR=5822801]").first
|
884
|
-
article.elements['DSCRD'].text.
|
883
|
+
expect(article.elements['DSCRD'].text).to match(/EPIMINERAL/)
|
885
884
|
end
|
886
885
|
|
887
886
|
it 'should generate a correct oddb_product.xml' do
|
@@ -891,7 +890,7 @@ if RUN_ALL
|
|
891
890
|
it 'should generate an article with the COOL (fridge) attribute' do
|
892
891
|
doc = REXML::Document.new File.new(oddb_article_xml)
|
893
892
|
fridge_product = checkAndGetArticleWithGTIN(doc, Oddb2xml::FRIDGE_GTIN)
|
894
|
-
fridge_product.elements['COOL'].text.
|
893
|
+
expect(fridge_product.elements['COOL'].text).to eq '1'
|
895
894
|
end
|
896
895
|
|
897
896
|
it 'should generate a correct oddb_article.xml' do
|
@@ -919,7 +918,6 @@ if RUN_ALL
|
|
919
918
|
expect(oddb_dat).to match(/^..3/), "should have a record with '3' in CMUT field"
|
920
919
|
expect(oddb_dat).to match(RegExpDesitin), "should have Desitin"
|
921
920
|
IO.readlines(dat_filename).each{ |line| check_article_IGM_format(line, 0) }
|
922
|
-
# oddb_dat.should match(/^..1/), "should have a record with '1' in CMUT field" # we have no
|
923
921
|
end
|
924
922
|
end
|
925
923
|
|
data/spec/calc_spec.rb
CHANGED
@@ -608,6 +608,17 @@ Die HILFSSTOFFE sind Aqua ad iniectabilia und Natrii chloridum.
|
|
608
608
|
specify { expect(argenti.chemical_substance).to eq nil }
|
609
609
|
end
|
610
610
|
end
|
611
|
+
context 'shire Subcuvia' do
|
612
|
+
# def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
|
613
|
+
substance = 'immunoglobulinum humanum normale'
|
614
|
+
composition = 'proteina 160 mg cum immunoglobulinum humanum normale min. 95 %, glycinum, natrii chloridum, aqua ad iniectabilia, q.s. ad solutionem pro 1 ml.'
|
615
|
+
info = Calc.new('Subcuvia, Injektionslösung', '5', 'ml', substance, composition)
|
616
|
+
specify { expect(info.compositions.first.substances.first.name).to eq 'Proteina' }
|
617
|
+
specify { expect(info.compositions.first.substances[1].name).to eq 'Cum Immunoglobulinum Humanum Normale' }
|
618
|
+
specify { expect(info.compositions.first.substances[1].is_active_agent).to eq true }
|
619
|
+
specify { expect(info.pkg_size).to eq '5' }
|
620
|
+
end
|
621
|
+
|
611
622
|
end
|
612
623
|
|
613
624
|
describe Oddb2xml::Calc do
|
data/spec/parslet_spec.rb
CHANGED
@@ -35,6 +35,32 @@ describe ParseComposition do
|
|
35
35
|
specify { expect( composition.substances.first.name).to eq "E 216" }
|
36
36
|
end
|
37
37
|
|
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.'
|
42
|
+
composition = ParseUtil.parse_compositions(composition_text, active_substance).first
|
43
|
+
specify { expect(composition.substances.size).to eq 4 }
|
44
|
+
specify { expect(composition.label).to eq nil }
|
45
|
+
specify { expect(composition.label_description).to eq nil }
|
46
|
+
specify { expect(composition.substances[0].name).to eq 'Proteina' }
|
47
|
+
specify { expect(composition.substances[1].name).to eq 'Cum Immunoglobulinum Humanum Normale' }
|
48
|
+
specify { expect(composition.substances[0].is_active_agent).to eq false }
|
49
|
+
specify { expect(composition.substances[1].is_active_agent).to eq true }
|
50
|
+
end
|
51
|
+
|
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.'
|
56
|
+
composition = ParseUtil.parse_compositions(composition_text, active_substance).first
|
57
|
+
specify { expect(composition.substances.size).to eq 1 }
|
58
|
+
specify { expect(composition.label).to eq nil }
|
59
|
+
specify { expect(composition.label_description).to eq nil }
|
60
|
+
specify { expect(composition.substances[0].is_active_agent).to eq true }
|
61
|
+
specify { expect(composition.substances[0].name).to eq 'Lanthanum 500 Mg Ut Lanthani (iii) Carbonas Hydricum' }
|
62
|
+
end
|
63
|
+
|
38
64
|
context "should return label with description" do
|
39
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."
|
40
66
|
composition = ParseComposition.from_string(string)
|
@@ -708,8 +734,9 @@ describe ParseComposition do
|
|
708
734
|
end
|
709
735
|
|
710
736
|
context "should parse a complex composition" do
|
711
|
-
|
712
|
-
|
737
|
+
composition = ParseUtil.parse_compositions(
|
738
|
+
'globulina equina (immunisé avec coeur) 8 mg',
|
739
|
+
'globulina equina (immunisé avec coeur)').first
|
713
740
|
specify { expect(composition.substances.size).to eq 1 }
|
714
741
|
globulina = composition.substances.find{ |x| /globulina/i.match(x.name) }
|
715
742
|
specify { expect(globulina.name).to eq 'Globulina Equina (immunisé Avec Coeur)' }
|
@@ -719,8 +746,9 @@ describe ParseComposition do
|
|
719
746
|
end
|
720
747
|
|
721
748
|
context "should parse globulina equina (immunise" do
|
722
|
-
|
723
|
-
|
749
|
+
composition = ParseUtil.parse_compositions(
|
750
|
+
'globulina equina (immunisé avec coeur, Tissu Pulmonaire, Reins De Porcins) 8 mg',
|
751
|
+
'globulina equina (immunisé avec coeur, Tissu Pulmonaire, Reins De Porcins)').first
|
724
752
|
specify { expect(composition.substances.size).to eq 1 }
|
725
753
|
globulina = composition.substances.find{ |x| /globulina/i.match(x.name) }
|
726
754
|
specify { expect(globulina.name).to eq 'Globulina Equina (immunisé Avec Coeur, Tissu Pulmonaire, Reins De Porcins)' }
|
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.4.
|
4
|
+
version: 2.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhiro Asaka, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|