oddb2xml 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDA5ZTJmMjQ1NzlhMWM0ZjE5YzY5NjA2NWFjNGFlYjQxMjI0NjIzYw==
4
+ MDg2MTM3NzVmZDE3MjhkNjg5ODc3Y2IxNGJkYzVmYTBhMTYyNGI2MQ==
5
5
  data.tar.gz: !binary |-
6
- MmUxZWYwYTBiYjkyMjdiMGMzM2QwZjQwOWI5MTZjZTIxMmQ2YzhhYw==
6
+ MmM2ZjRlNzA5NTYwNWIzZDc0MTZmNjcwZDA1NWZkOGEyYzY2MDY2NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDBiZDcyMzQyZTMzMDhiNDFmNGQxOTAwOTc2MjA1OTY4NjMyNzhiNWE3NzI4
10
- ODVlM2RmMTg2MTRkODdjODhlM2ExNDVkOTUyOTgwZTM3MzY1MzA1Y2Q2MmRi
11
- NjI4Zjc0OTlkM2M0NTIzMmZlOTlmYzcwMGQ0YTdlMTc5NjZiNjY=
9
+ Y2I2YTc2MjA0OTQ1MmFhMDEyZjBmNTZkY2IwMjVjNTg0MzQ1NzY4ZGRlYzIx
10
+ ZjY4OTAxNzRhMGVjYjU3OTMxYjg1YzVhNjQ0MmQzZTIxNzQwMzAyYTM2MDFj
11
+ M2ExZmFiZGU3NWRlN2U3YzBjOGE3MDNkMjJkMWQwNTAyNDViYjE=
12
12
  data.tar.gz: !binary |-
13
- OGY4NThmMTRhNDVhY2ZlYzdmZmYwMThjMGY0NTM5MmJhYjMxYThjOTE4ZTUy
14
- MmYwYzlhOWI5OTQ5OWQ0MDllMjk2YmM3OGY3YzUzMDE4MTM0YTYzOTRlY2Uz
15
- NzM0NTQwZTlhOWQwZjMwZDlmMGYzMWM2ZmIzZDhlZjlmMDE1MjQ=
13
+ ZjJkZDk1ZjIzOTVlODQ2YWU3MWE0ZmZkMGM3NTMyMTA2ODNlZGJlOWViOTJm
14
+ OTYyOTdkMTc0ODkyNTViNjI1Y2YzZDhlOGUyOWE4YzZhNzMzODlkNmQ1M2Jj
15
+ YmMzODcwMWRjMjIwNGVlOTkzZWMyMTJhZjQ3NDhhZmMyNjQ0ZjA=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oddb2xml (2.0.6)
4
+ oddb2xml (2.0.7)
5
5
  archive-tar-minitar (~> 0.5.2)
6
6
  mechanize (~> 2.5.1)
7
7
  nokogiri (~> 1.5.10)
data/History.txt CHANGED
@@ -1,3 +1,16 @@
1
+ === 2.0.7 / 29.04.2015
2
+
3
+ * parse swissmedic composition with the help of RubyGem parslet.
4
+ ** with extensive unit-tests (spec/composition_spec.rb and spec/parslet_spec.rb
5
+ * new/changed fields when using --calc, e.g.
6
+ ** more_info
7
+ ** salts
8
+ ** dose_text if qty/unit is not normalized
9
+ ** chemical_substance is now represented as a normal substance
10
+ ** composition.label
11
+ ** composition.label_description
12
+ ** composition.correpond
13
+
1
14
  === 2.0.6 / 27.04.2015
2
15
 
3
16
  * Remove trailing spaces in names imported from ZurRose transfer.dat
@@ -13,34 +13,39 @@ h2. Syntax
13
13
 
14
14
  Die Syntax wird in einer Datei "compositions_syntax":https://raw.githubusercontent.com/ngiger/oddb2xml/master/lib/oddb2xml/compositions_syntax.rb beschrieben.
15
15
 
16
- * ratio: Falls eine Zeile in der Zusammensetzung sow was wie @ratio: 1:10@ oder @ratio: 1:1.5-2.4@ enthält, wird das Feld "more_info" entsprechend gesetzt.
16
+ - ratio := Falls eine Zeile in der Zusammensetzung sow was wie @ratio: 1:10@ oder @ratio: 1:1.5-2.4@ enthält, wird das Feld "more_info" entsprechend gesetzt.
17
17
 
18
- * Namen mit Zahlen. Beschloss dass @Glyceroli Monostearas 33-45@ eine Name und nicht Glyceroli Monostearas von 33 bis 45 von irgendwas ist.
18
+ - Namen mit Zahlen := Beschloss dass @Glyceroli Monostearas 33-45@ eine Name und nicht Glyceroli Monostearas von 33 bis 45 von irgendwas ist.
19
19
 
20
- h2. Gebrauchte Abkürzungen und Schlüsselworte
20
+ - Dosis := Häufig einfach, z.B. @5 mg@. Komplizierte Ausdrücke wie @2*10^9 CFU@, @9 g/L 5 ml@, @40-55@, @75/25@, @150 U.I. hFSH et 150 U.I. hLH@ oder @6.0 +/-1.2 µg/0.5 ml@ findet man auch.
21
+
22
+ - chemical_substance := In der XML-Datei findet man die Substance welche im Swissmedic-Jargon via @corresp@ (u.ä) als eigentlicher Wirkstoff referenziert wird.
21
23
 
22
- * q.s.
23
- * pro praeparatione
24
- * excipiens
25
- * pro compresso obducto
26
- * pro compresso
27
- * epro praeparatione
28
- * ad pulverem
29
- * pro charta
30
- * ad globulos
31
- * aqua ad iniectabilia q.s. ad solutionem
32
- * solvens (i.v.): aqua ad iniectabilia
33
- * ad solutionem
34
- * q.s. ad
35
- * aqua q.s. ad
36
- * saccharum ad
37
- * aether q.s.
38
- * aqua ad iniectabilia
39
- * q.s. pro praeparatione
40
- * ana partes
41
- * et oder @,@ trennen Substanzen
42
- * ut vorgehende Substanz wird via nachstehend aufgeführte Salze(e) aufgenommen
24
+ h2. Gebrauchte Abkürzungen und Schlüsselworte
43
25
 
26
+ - et alia := es gibt noch andere Substanzen. Beispiel: 62504 Olanzapin Sandoz Solufilm 20 mg
27
+ - et oder , := trennen Substanzen. Beispiel: 29555 NaCl 11,7 % B. Braun, Zusatzampullen zu Infusionslösungen
28
+ - ut := vorgehende Substanz wird via nachstehend aufgeführte Salze(e) aufgenommen. Beispiel: 54749 Supradyn Vital 50+.
29
+ - DER: := DrugEthanol Ratio
30
+ - q.s. :=
31
+ - pro praeparatione :=
32
+ - excipiens :=
33
+ - pro compresso obducto :=
34
+ - pro compresso :=
35
+ - epro praeparatione :=
36
+ - ad pulverem :=
37
+ - pro charta :=
38
+ - ad globulos :=
39
+ - aqua ad iniectabilia q.s. ad solutionem :=
40
+ - solvens (i.v.): aqua ad iniectabilia :=
41
+ - ad solutionem :=
42
+ - q.s. ad :=
43
+ - aqua q.s. ad :=
44
+ - saccharum ad :=
45
+ - aether q.s. :=
46
+ - aqua ad iniectabilia :=
47
+ - q.s. pro praeparatione :=
48
+ - ana partes :=
44
49
 
45
50
  h2. Vorgeschlag für Bereinigung
46
51
 
@@ -48,3 +53,4 @@ h2. Vorgeschlag für Bereinigung
48
53
  * Corresp: als Label für Bestandteile
49
54
  * corresp. für zugehörende Substanz
50
55
  * @<@ durch @max.@ ersetzen (1 Mal)
56
+ * @mind.@ durch @min.@ ersetzen, @min.@ kommt viel häufiger vor
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: utf-8
2
2
 
3
3
  require 'nokogiri'
4
4
  require 'oddb2xml/util'
@@ -31,7 +31,7 @@ module Oddb2xml
31
31
  'xmlns' => 'http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration',
32
32
  'CREATION_DATETIME' => Time.new.strftime('%FT%T%z'),
33
33
  'PROD_DATE' => Time.new.strftime('%FT%T%z'),
34
- 'VALID_DATE' => Time.new.strftime('%FT%T%z')
34
+ 'VALID_DATE' => Time.new.strftime('%FT%T%z'),
35
35
  }
36
36
  class Builder
37
37
  attr_accessor :subject, :index, :items, :flags, :lppvs,
@@ -632,6 +632,34 @@ module Oddb2xml
632
632
  end
633
633
 
634
634
  def build_calc
635
+ def emit_substance(xml, substance, emit_active=false)
636
+ xml.MORE_INFO substance.more_info if substance.more_info
637
+ xml.SUBSTANCE_NAME substance.name
638
+ xml.IS_ACTIVE_AGENT substance.is_active_agent if emit_active
639
+ if substance.dose
640
+ if substance.qty.is_a?(Float) or substance.qty.is_a?(Fixnum)
641
+ xml.QTY substance.qty
642
+ xml.UNIT substance.unit
643
+ else
644
+ xml.DOSE_TEXT substance.dose.to_s
645
+ end
646
+ end
647
+ if substance.chemical_substance
648
+ xml.CHEMICAL_SUBSTANCE {
649
+ emit_substance(xml, substance.chemical_substance)
650
+ }
651
+ end
652
+ if substance.salts and substance.salts.size > 0
653
+ xml.SALTS {
654
+ substance.salts.each { |salt|
655
+ xml.SALT {
656
+ emit_substance(xml, salt)
657
+ }
658
+ }
659
+ }
660
+
661
+ end
662
+ end
635
663
  packungen_xlsx = File.join(Oddb2xml::WorkDir, "swissmedic_package.xlsx")
636
664
  idx = 0
637
665
  return unless File.exists?(packungen_xlsx)
@@ -649,7 +677,7 @@ module Oddb2xml
649
677
  seqnr = "%02d" % row.cells[1].value.to_i
650
678
  if row_nr % 250 == 0
651
679
  puts "#{Time.now}: At row #{row_nr} iksnr #{iksnr}";
652
- $stdout.sync
680
+ $stdout.flush
653
681
  end
654
682
  no8 = sprintf('%05d',row.cells[0].value.to_i) + sprintf('%03d',row.cells[10].value.to_i)
655
683
  name = row.cells[2].value
@@ -688,22 +716,7 @@ module Oddb2xml
688
716
  xml.LABEL composition.label if composition.label
689
717
  xml.LABEL_DESCRIPTION composition.label_description if composition.label_description
690
718
  xml.SUBSTANCES {
691
- composition.substances.each { |substance|
692
- xml.SUBSTANCE {
693
- xml.MORE_INFO substance.more_info.gsub('&gt','>').gsub('&amp', '&') if substance.more_info
694
- xml.SUBSTANCE_NAME substance.name
695
- xml.IS_ACTIVE_AGENT substance.is_active_agent
696
- if substance.unit
697
- xml.QTY substance.qty
698
- xml.UNIT substance.unit
699
- end
700
- if substance.chemical_substance
701
- xml.CHEMICAL_SUBSTANCE substance.chemical_substance.name
702
- xml.CHEMICAL_QTY substance.chemical_substance.qty
703
- xml.CHEMICAL_UNIT substance.chemical_substance.unit
704
- end
705
- }
706
- }
719
+ composition.substances.each { |substance| xml.SUBSTANCE { emit_substance(xml, substance, true) }}
707
720
  } if composition.substances
708
721
  }
709
722
  }
data/lib/oddb2xml/calc.rb CHANGED
@@ -205,6 +205,7 @@ public
205
205
 
206
206
  def get_selling_units(part_from_name_C, pkg_size_L, einheit_M)
207
207
  begin
208
+ break_condition = (defined?(Pry) and false) # /5 x 2500 ml/.match(pkg_size_L))
208
209
  return pkg_size_to_int(pkg_size_L) unless part_from_name_C
209
210
  part_from_name_C = part_from_name_C.gsub(/[()]/, '_')
210
211
  Measurements.each{ |x|
@@ -212,6 +213,7 @@ public
212
213
  puts "measurement in einheit_M #{einheit_M} matched: #{x}" if $VERBOSE
213
214
  update_rule('measurement einheit_M')
214
215
  @measure = x
216
+ binding.pry if break_condition
215
217
  return pkg_size_to_int(pkg_size_L, true)
216
218
  end
217
219
  }
@@ -220,12 +222,14 @@ public
220
222
  puts "feste_form in #{part_from_name_C} matched: #{x}" if $VERBOSE
221
223
  update_rule('feste_form name_C')
222
224
  @measure = x
225
+ binding.pry if break_condition
223
226
  return pkg_size_to_int(pkg_size_L)
224
227
  end
225
228
  if einheit_M and x.eql?(einheit_M)
226
229
  puts "feste_form in einheit_M #{einheit_M} matched: #{x}" if $VERBOSE
227
230
  update_rule('feste_form einheit_M')
228
231
  @measure = x
232
+ binding.pry if break_condition
229
233
  return pkg_size_to_int(pkg_size_L)
230
234
  end
231
235
  }
@@ -234,18 +238,21 @@ public
234
238
  puts "liquid_form in #{part_from_name_C} matched: #{x}" if $VERBOSE
235
239
  update_rule('liquid_form name_C')
236
240
  @measure = x
241
+ binding.pry if break_condition
237
242
  return pkg_size_to_int(pkg_size_L, true)
238
243
  end
239
244
  if part_from_name_C and x.match(part_from_name_C.split(' ')[0])
240
245
  puts "liquid_form in #{part_from_name_C} matched: #{x}" if $VERBOSE
241
246
  update_rule('liquid_form first_part')
247
+ binding.pry if break_condition
242
248
  return pkg_size_to_int(pkg_size_L, true)
243
249
  end
244
250
  if einheit_M and x.eql?(einheit_M)
245
251
  puts "liquid_form in einheit_M #{einheit_M} matched: #{x}" if $VERBOSE
246
252
  update_rule('liquid_form einheit_M')
247
253
  @measure = x
248
- return pkg_size_to_int(pkg_size_L, false)
254
+ binding.pry if break_condition
255
+ return pkg_size_to_int(pkg_size_L, Measurements.find{ |x| pkg_size_L.index(" #{x}")})
249
256
  end
250
257
  }
251
258
  Measurements.each{ |x|
@@ -253,9 +260,11 @@ public
253
260
  puts "measurement in pkg_size_L #{pkg_size_L} matched: #{x}" if $VERBOSE
254
261
  update_rule('measurement pkg_size_L')
255
262
  @measure = x
263
+ binding.pry if break_condition
256
264
  return pkg_size_to_int(pkg_size_L, true)
257
265
  end
258
266
  }
267
+ binding.pry if break_condition
259
268
  puts "Could not find anything for name_C #{part_from_name_C} pkg_size_L: #{pkg_size_L} einheit_M #{einheit_M}" if $VERBOSE
260
269
  update_rule('unbekannt')
261
270
  return 'unbekannt'