oddb2xml 1.9.7 → 1.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cead671c938149dab5dfde7f418a9cc2fdd5d62
4
- data.tar.gz: 1ae54ff9d2724b4675b2f9a7e2a345a20f9017b6
3
+ metadata.gz: 721c2d137c7dbaaed24ff52acfe254adc280b954
4
+ data.tar.gz: 67e7cc0025f8e76d9e6ae64d9877055f4c0d4788
5
5
  SHA512:
6
- metadata.gz: fc4db40f9ede22f2f48dc3159eff3d93f5fbae6c46f7a4ab0fc466c4ecc8d142c4e8e41d9395effac0bfe79c5c6e34553d87ed2b171fb16287a63c8b21c3dce9
7
- data.tar.gz: b784b7ea2ae441c6869a514729b2663a1939022c2f2d841b3a2e87bc9bdf70d46892cf95eb8b815d2f51cb0148efac31ec38995d302155959c483f538673fa96
6
+ metadata.gz: 0debbdf566d2180e15c345a1b7d7faa3fdf4013a8ada0204bc01d92a29a5d246fd53f3a9288cc50c44a36373d69a4412b7447129b9a99f7e495ce115b3368f6b
7
+ data.tar.gz: 5f75349fbf9ec7bd2b05cc6e6fec4c1efd0028210a9e49497813edc44f701dbf5cc274bd0c95c4ac2b3531927be9533f9fd072de2697a5ec6ed9e6c49fc911b7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (1.9.7)
4
+ oddb2xml (1.9.8)
5
5
  archive-tar-minitar (~> 0.5.2)
6
6
  mechanize (~> 2.5.1)
7
7
  nokogiri (~> 1.5.10)
@@ -75,11 +75,11 @@ GEM
75
75
  rspec-support (~> 3.1.0)
76
76
  rspec-support (3.1.2)
77
77
  ruby-ole (1.2.11.8)
78
- rubyXL (3.3.3)
78
+ rubyXL (3.3.6)
79
79
  nokogiri (>= 1.4.4)
80
80
  rubyzip (>= 1.1.6)
81
81
  rubyntlm (0.3.4)
82
- rubyzip (1.1.6)
82
+ rubyzip (1.1.7)
83
83
  safe_yaml (1.0.4)
84
84
  savon (2.4.0)
85
85
  akami (~> 1.2.0)
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.9.8 / 04.03.2015
2
+
3
+ * Remove unnecessary spaces from ARTICLE.GALENIC_FORM in oddb_calc.xml
4
+ * Remove unnecessary spaces from ARTICLE.PKG_SIZE in oddb_calc.xml
5
+ * Remove unnecessary spaces from ARTICLE.NAME in oddb_calc.xml
6
+ * Emit comment for compositions, eg. 'Solvens: aqua ad iniectabilia.'
7
+ * Renamed COMPOSITION to COMPONENT in COMPOSITIONS
8
+
1
9
  === 1.9.7 / 03.03.2015
2
10
 
3
11
  * Emit qty as floats
@@ -665,8 +665,8 @@ module Oddb2xml
665
665
  items[ean13] = info
666
666
  xml.ARTICLE {
667
667
  xml.GTIN ean13
668
- xml.NAME name
669
- xml.PKG_SIZE package_size
668
+ xml.NAME info.name
669
+ xml.PKG_SIZE info.pkg_size
670
670
  xml.SELLING_UNITS info.selling_units
671
671
  # xml.COUNT info.count
672
672
  # xml.MULTI info.multi
@@ -683,14 +683,16 @@ module Oddb2xml
683
683
  xml.COMPOSITIONS {
684
684
  info.compositions.each {
685
685
  |composition|
686
- xml.COMPOSITION {
686
+ xml.COMPONENT {
687
687
  xml.NAME composition.name
688
688
  if composition.unit
689
689
  xml.QTY composition.qty
690
690
  xml.UNIT composition.unit
691
691
  end
692
+ xml.LABEL composition.label if composition.label
692
693
  }
693
694
  }
695
+ xml.COMMENT info.composition_comment if info.composition_comment
694
696
  }
695
697
  } if info.compositions
696
698
  end
data/lib/oddb2xml/calc.rb CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
6
6
  module Oddb2xml
7
7
  # Calc is responsible for analysing the columns "Packungsgrösse" and "Einheit"
8
8
  #
9
- Composition = Struct.new("Composition", :name, :qty, :unit)
9
+ Composition = Struct.new("Composition", :name, :qty, :unit, :label)
10
10
  GalenicGroup = Struct.new("GalenicGroup", :oid, :descriptions)
11
11
  GalenicForm = Struct.new("GalenicForm", :oid, :descriptions, :galenic_group)
12
12
 
@@ -103,7 +103,7 @@ module Oddb2xml
103
103
  @@names_without_galenic_forms = []
104
104
  @@rules_counter = {}
105
105
  attr_accessor :galenic_form, :unit, :pkg_size
106
- attr_reader :name, :substances, :composition, :compositions
106
+ attr_reader :name, :substances, :composition, :compositions, :composition_comment
107
107
  attr_reader :selling_units, :count, :multi, :measure, :addition, :scale # s.a. commercial_form in oddb.org/src/model/part.rb
108
108
  def self.get_galenic_group(name, lang = 'de')
109
109
  @@galenic_groups.values.collect { |galenic_group|
@@ -182,10 +182,14 @@ public
182
182
  [name, dose ? [dose[0], dose[1]] : [nil, nil] ].flatten
183
183
  end
184
184
  end
185
+ private
186
+ def remove_duplicated_spaces(string)
187
+ string ? string.to_s.gsub(/\s\s+/, ' ') : nil
188
+ end
185
189
  public
186
190
  def initialize(name = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
187
- @name = name
188
- @pkg_size = size
191
+ @name = remove_duplicated_spaces(name)
192
+ @pkg_size = remove_duplicated_spaces(size)
189
193
  @unit = unit
190
194
  # @pkg_size, @galenic_group, @galenic_form =
191
195
  search_galenic_info
@@ -206,12 +210,20 @@ public
206
210
  current = numbers.shift
207
211
  labels = []
208
212
  composition_text = composition.gsub(/\r\n?/u, "\n")
213
+ puts "composition_text for #{name}: #{composition_text}" if composition_text.split(/\n/u).size > 1 and $VERBOSE
209
214
  compositions = composition_text.split(/\n/u).select do |line|
210
- if match = /^(#{current})\)/.match(line)
211
- labels.push match[1]
215
+ if match = /^(#{current})\)([^:]+)/.match(line)
216
+ labels.push [match[1], match[2]]
212
217
  current = numbers.shift
213
218
  end
214
219
  end
220
+ puts "labels for #{name}: #{labels}" if labels.size > 0 and $VERBOSE
221
+ if composition_text.split(/\n/u).size > 1
222
+ last_line = composition_text.split(/\n/u)[-1]
223
+ @composition_comment = last_line
224
+ else
225
+ @composition_comment = nil
226
+ end
215
227
  if compositions.empty?
216
228
  compositions.push composition_text.gsub(/\n/u, ' ')
217
229
  end
@@ -221,7 +233,7 @@ public
221
233
  composition.gsub!(/'/, '')
222
234
  @active_substances.each { |name|
223
235
  name, qty, unit = Calc.update_active_agent(name, composition)
224
- res << Composition.new(name, qty.to_f, unit) if name
236
+ res << Composition.new(name, qty.to_f, unit, labels[idx] ? labels[idx].join('') : nil) if name
225
237
  }
226
238
  end
227
239
  @compositions = res
@@ -366,7 +378,7 @@ public
366
378
  # puts "oid #{UnknownGalenicForm} #{@galenic_form.oid} for #{name}"
367
379
  break unless @galenic_form.oid == UnknownGalenicForm
368
380
  if @galenic_form.oid == UnknownGalenicForm
369
- @galenic_form = GalenicForm.new(0, {'de' => form_name}, @@galenic_forms[UnknownGalenicForm] )
381
+ @galenic_form = GalenicForm.new(0, {'de' => remove_duplicated_spaces(form_name.gsub(' +', ' '))}, @@galenic_forms[UnknownGalenicForm] )
370
382
  @@new_galenic_forms << form_name
371
383
  end
372
384
  }
@@ -1,3 +1,3 @@
1
1
  module Oddb2xml
2
- VERSION = "1.9.7"
2
+ VERSION = "1.9.8"
3
3
  end
data/spec/calc_spec.rb CHANGED
@@ -260,7 +260,8 @@ Corresp. 5300 kJ.",
260
260
  expect(File.exists?(full)).to eq true
261
261
  }
262
262
  xml = File.read(File.join(Oddb2xml::WorkDir, 'oddb_calc.xml'))
263
- puts xml
263
+ m = />.* /.match(xml)
264
+ m.should eq nil
264
265
  doc = REXML::Document.new xml
265
266
  gtin = '7680540151009'
266
267
  ean12 = '7680' + sprintf('%05d',tst_naropin.iksnr_A) + sprintf('%03d',tst_naropin.pack_K)
@@ -284,9 +285,9 @@ Corresp. 5300 kJ.",
284
285
  puts "Testing key #{key.inspect} #{value.inspect} against #{result} seems to fail" unless result == value.to_s
285
286
  result.should eq value.to_s
286
287
  }
287
- XPath.match( doc, "//ARTICLE[GTIN='7680006790124']/COMPOSITIONS/COMPOSITION/NAME").last.text.should eq 'Bifidobacterium Infantis'
288
- XPath.match( doc, "//ARTICLE[GTIN='7680545250363']/COMPOSITIONS/COMPOSITION/NAME").last.text.should eq 'Alprostadilum'
289
- # 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.
288
+ XPath.match( doc, "//ARTICLE[GTIN='7680006790124']/COMPOSITIONS/COMPONENT/NAME").last.text.should eq 'Bifidobacterium Infantis'
289
+ XPath.match( doc, "//ARTICLE[GTIN='7680545250363']/COMPOSITIONS/COMPONENT/NAME").last.text.should eq 'Alprostadilum'
290
+ XPath.match( doc, "//ARTICLE[GTIN='7680458820202']/NAME").last.text.should eq 'Magnesiumchlorid 0,5 molar B. Braun, Zusatzampulle für Infusionslösungen'
290
291
  end
291
292
  end
292
293
 
@@ -337,4 +338,27 @@ Corresp. 5300 kJ.",
337
338
  skip "Infloran, capsule mit cryodesiccatus min. 10^9 CFU"
338
339
  end
339
340
 
341
+ context 'find correct result compositions' do
342
+ result = Calc.new('Nutriflex Lipid peri, Infusionsemulsion, 1250ml', nil, nil,
343
+ 'glucosum anhydricum, zinci acetas dihydricus, isoleucinum, leucinum, lysinum anhydricum, methioninum, phenylalaninum, threoninum, tryptophanum, valinum, argininum, histidinum, alaninum, acidum asparticum, acidum glutamicum, glycinum, prolinum, serinum, magnesii acetas tetrahydricus, chloridum, phosphas, acetas, sojae oleum, triglycerida saturata media',
344
+ 'I) Glucoselösung: glucosum anhydricum 80 g ut glucosum monohydricum, natrii dihydrogenophosphas dihydricus 1.17 g, zinci acetas dihydricus 6.625 mg, acidum citricum q.s. ad pH, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.
345
+ 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.
346
+ III) Aminosäurenlösung: isoleucinum 2.34 g, leucinum 3.13 g, lysinum anhydricum 2.26 g ut lysini hydrochloridum, methioninum 1.96 g, phenylalaninum 3.51 g, threoninum 1.82 g, tryptophanum 0.57 g, valinum 2.6 g, argininum 2.7 g, histidinum 1.25 g ut histidini hydrochloridum monohydricum, alaninum 4.85 g, acidum asparticum 1.5 g, acidum glutamicum 3.5 g, glycinum 1.65 g, prolinum 3.4 g, serinum 3 g, natrii hydroxidum 0.8 g, natrii chloridum 1.081 g, natrii acetas trihydricus 0.544 g, kalii acetas 2.943 g, magnesii acetas tetrahydricus 0.644 g, calcii chloridum dihydricum 0.441 g, aqua ad iniectabilia q.s. ad solutionem pro 500 ml.
347
+ .
348
+ I) et II) et III) corresp.: aminoacida 32 g/l, carbohydrata 64 g/l, materia crassa 40 g/l, natrium 40 mmol/l, kalium 24 mmol/l, calcium 2.4 mmol/l, magnesium 2.4 mmol, zincum 0.024 mmol/l, chloridum 38.4 mmol/l, phosphas 6 mmol/l, acetas 32 mmol/l, acidum citricum monohydricum, in emulsione recenter mixta 1250 ml.
349
+ Corresp. 4000 kJ.')
350
+ specify { expect(result.compositions.first.name).to eq 'Glucosum Anhydricum' }
351
+ specify { expect(result.compositions.first.qty).to eq 80.0}
352
+ specify { expect(result.compositions.first.unit).to eq 'g/500 ml'}
353
+ zinci = result.compositions.find{ |x| x.name == 'Zinci Acetas Dihydricus' }
354
+ specify { expect(zinci.name).to eq 'Zinci Acetas Dihydricus' }
355
+ specify { expect(zinci.qty).to eq 6.625}
356
+ specify { expect(zinci.unit).to eq 'mg/500 ml'}
357
+ zinci = result.compositions.find{ |x| x.name == 'Zinci Acetas Dihydricus' }
358
+ natrii = result.compositions.find{ |x| x.name == 'Natrii Dihydrogenophosphas Dihydricus' }
359
+ specify { expect(zinci).not_to eq nil}
360
+ skip 'Is Natrii Dihydrogenophosphas Dihydricus a real error or not?'
361
+ # specify { expect(natrii).not_to eq nil }
362
+
363
+ end
340
364
  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: 1.9.7
4
+ version: 1.9.8
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-03 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip