oddb2xml 2.6.7 → 2.7.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +40 -0
  3. data/.standard.yml +2 -0
  4. data/Elexis_Artikelstamm_v5.xsd +0 -3
  5. data/Gemfile +3 -3
  6. data/History.txt +30 -0
  7. data/README.md +1 -1
  8. data/Rakefile +24 -23
  9. data/bin/check_artikelstamm +11 -11
  10. data/bin/compare_v5 +23 -23
  11. data/bin/oddb2xml +14 -13
  12. data/lib/oddb2xml.rb +1 -1
  13. data/lib/oddb2xml/builder.rb +1077 -1039
  14. data/lib/oddb2xml/calc.rb +232 -233
  15. data/lib/oddb2xml/chapter_70_hack.rb +38 -32
  16. data/lib/oddb2xml/cli.rb +252 -233
  17. data/lib/oddb2xml/compare.rb +70 -59
  18. data/lib/oddb2xml/compositions_syntax.rb +448 -430
  19. data/lib/oddb2xml/compressor.rb +20 -20
  20. data/lib/oddb2xml/downloader.rb +155 -129
  21. data/lib/oddb2xml/extractor.rb +302 -296
  22. data/lib/oddb2xml/options.rb +34 -35
  23. data/lib/oddb2xml/parslet_compositions.rb +263 -265
  24. data/lib/oddb2xml/semantic_check.rb +39 -33
  25. data/lib/oddb2xml/util.rb +169 -159
  26. data/lib/oddb2xml/version.rb +1 -1
  27. data/lib/oddb2xml/xml_definitions.rb +32 -33
  28. data/oddb2xml.gemspec +32 -30
  29. data/spec/artikelstamm_spec.rb +139 -132
  30. data/spec/builder_spec.rb +495 -524
  31. data/spec/calc_spec.rb +552 -593
  32. data/spec/check_artikelstamm_spec.rb +26 -26
  33. data/spec/cli_spec.rb +182 -157
  34. data/spec/compare_spec.rb +9 -11
  35. data/spec/composition_syntax_spec.rb +390 -409
  36. data/spec/compressor_spec.rb +48 -48
  37. data/spec/data/Preparations.xml +139 -3
  38. data/spec/data/refdata_NonPharma.xml +0 -3
  39. data/spec/data/refdata_Pharma.xml +10 -25
  40. data/spec/data/swissmedic_package.xlsx +0 -0
  41. data/spec/data/transfer.dat +3 -1
  42. data/spec/data/varia_De.htm +2 -2
  43. data/spec/data_helper.rb +47 -49
  44. data/spec/downloader_spec.rb +247 -260
  45. data/spec/extractor_spec.rb +173 -165
  46. data/spec/galenic_spec.rb +233 -256
  47. data/spec/options_spec.rb +116 -119
  48. data/spec/parslet_spec.rb +833 -861
  49. data/spec/spec_helper.rb +154 -153
  50. data/test_options.rb +39 -42
  51. data/tools/win_fetch_cacerts.rb +2 -3
  52. metadata +49 -5
  53. data/.travis.yml +0 -30
data/lib/oddb2xml/calc.rb CHANGED
@@ -1,111 +1,109 @@
1
- # encoding: utf-8
2
-
3
- require 'oddb2xml/util'
4
- require 'oddb2xml/parslet_compositions'
5
- require 'yaml'
1
+ require "oddb2xml/util"
2
+ require "oddb2xml/parslet_compositions"
3
+ require "yaml"
6
4
 
7
5
  module Oddb2xml
8
- # Calc is responsible for analysing the columns "Packungsgrösse" and "Einheit"
9
- #
10
- GalenicGroup = Struct.new("GalenicGroup", :oid, :descriptions)
11
- GalenicForm = Struct.new("GalenicForm", :oid, :descriptions, :galenic_group)
6
+ # Calc is responsible for analysing the columns "Packungsgrösse" and "Einheit"
7
+ #
8
+ GalenicGroup = Struct.new("GalenicGroup", :oid, :descriptions)
9
+ GalenicForm = Struct.new("GalenicForm", :oid, :descriptions, :galenic_group)
12
10
 
13
11
  class GalenicGroup
14
- def description(lang = 'de')
12
+ def description(lang = "de")
15
13
  descriptions[lang]
16
14
  end
17
15
  end
18
16
 
19
17
  class GalenicForm
20
- def description(lang = 'de')
18
+ def description(lang = "de")
21
19
  descriptions[lang]
22
20
  end
23
21
  end
24
22
 
25
23
  class Calc
26
- FluidForms = [
27
- 'Ampulle(n)',
28
- 'Beutel',
29
- 'Bolus/Boli',
30
- 'Bq',
31
- 'Dose(n)',
32
- 'Durchstechflasche(n)',
33
- 'Einmaldosenbehälter',
34
- 'Einzeldose(n)',
35
- 'Fertigspritze',
36
- 'Fertigspritze(n)',
37
- 'Flasche(n)',
38
- 'I.E.',
39
- 'Infusionskonzentrat',
40
- 'Infusionslösung',
41
- 'Infusionsemulsion',
42
- 'Inhalationen',
43
- 'Inhalator',
44
- 'Injektions-Set',
45
- 'Injektions-Sets',
46
- 'Injektor(en), vorgefüllt/Pen',
47
- 'Klistier(e)',
48
- 'MBq',
49
- 'Pipetten',
50
- 'Sachet(s)',
51
- 'Spritze(n)',
52
- 'Sprühstösse',
53
- 'Stechampulle (Lyophilisat) und Ampulle (Solvens)',
54
- 'Stechampulle',
55
- 'Suspension',
56
- 'Zylinderampulle(n)',
57
- 'cartouches',
58
- 'dose(s)',
59
- 'flacon perforable',
60
- 'sacchetto',
61
- 'vorgefüllter Injektor',
62
- ]
63
- FesteFormen = [
64
- 'Depotabs',
65
- 'Dragée(s)',
66
- 'Generator mit folgenden Aktivitäten:',
67
- 'Filmtabletten',
68
- 'Gerät',
69
- 'Kapsel(n)',
70
- 'Kautabletten',
71
- 'Lutschtabletten',
72
- 'Kugeln',
73
- 'Ovulum',
74
- 'Packung(en)',
75
- 'Pflaster',
76
- 'Schmelzfilme',
77
- 'Set',
78
- 'Strips',
79
- 'Stück',
80
- 'Suppositorien',
81
- 'Tablette(n)',
82
- 'Tüchlein',
83
- 'Urethrastab',
84
- 'Vaginalzäpfchen',
85
- 'comprimé',
86
- 'comprimé pelliculé',
87
- 'comprimés',
88
- 'comprimés à libération modifiée',
89
- 'comprimés à croquer sécables',
90
- 'imprägnierter Verband',
91
- 'magensaftresistente Filmtabletten',
92
- 'ovale Körper',
93
- 'tube(s)',
24
+ FLUIDFORMS = [
25
+ "Ampulle(n)",
26
+ "Beutel",
27
+ "Bolus/Boli",
28
+ "Bq",
29
+ "Dose(n)",
30
+ "Durchstechflasche(n)",
31
+ "Einmaldosenbehälter",
32
+ "Einzeldose(n)",
33
+ "Fertigspritze",
34
+ "Fertigspritze(n)",
35
+ "Flasche(n)",
36
+ "I.E.",
37
+ "Infusionskonzentrat",
38
+ "Infusionslösung",
39
+ "Infusionsemulsion",
40
+ "Inhalationen",
41
+ "Inhalator",
42
+ "Injektions-Set",
43
+ "Injektions-Sets",
44
+ "Injektor(en), vorgefüllt/Pen",
45
+ "Klistier(e)",
46
+ "MBq",
47
+ "Pipetten",
48
+ "Sachet(s)",
49
+ "Spritze(n)",
50
+ "Sprühstösse",
51
+ "Stechampulle (Lyophilisat) und Ampulle (Solvens)",
52
+ "Stechampulle",
53
+ "Suspension",
54
+ "Zylinderampulle(n)",
55
+ "cartouches",
56
+ "dose(s)",
57
+ "flacon perforable",
58
+ "sacchetto",
59
+ "vorgefüllter Injektor"
60
+ ]
61
+ FESTE_FORMEN = [
62
+ "Depotabs",
63
+ "Dragée(s)",
64
+ "Generator mit folgenden Aktivitäten:",
65
+ "Filmtabletten",
66
+ "Gerät",
67
+ "Kapsel(n)",
68
+ "Kautabletten",
69
+ "Lutschtabletten",
70
+ "Kugeln",
71
+ "Ovulum",
72
+ "Packung(en)",
73
+ "Pflaster",
74
+ "Schmelzfilme",
75
+ "Set",
76
+ "Strips",
77
+ "Stück",
78
+ "Suppositorien",
79
+ "Tablette(n)",
80
+ "Tüchlein",
81
+ "Urethrastab",
82
+ "Vaginalzäpfchen",
83
+ "comprimé",
84
+ "comprimé pelliculé",
85
+ "comprimés",
86
+ "comprimés à libération modifiée",
87
+ "comprimés à croquer sécables",
88
+ "imprägnierter Verband",
89
+ "magensaftresistente Filmtabletten",
90
+ "ovale Körper",
91
+ "tube(s)"
94
92
  ]
95
- Measurements = [ 'g', 'kg', 'l', 'mg', 'ml', 'cm', 'GBq']
96
- Others = ['Kombipackung', 'emballage combiné' ]
97
- UnknownGalenicForm = 140
98
- UnknownGalenicGroup = 1
99
- Data_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','..', 'data'))
100
- @@galenic_groups = YAML.load_file(File.join(Data_dir, 'gal_groups.yaml'))
101
- @@galenic_forms = YAML.load_file(File.join(Data_dir, 'gal_forms.yaml'))
93
+ MEASUREMENTS = ["g", "kg", "l", "mg", "ml", "cm", "GBq"]
94
+ OTHERS = ["Kombipackung", "emballage combiné"]
95
+ UNKNOWN_GALENIC_FORM = 140
96
+ UNKNOWN_GALENIC_GROUP = 1
97
+ DATA_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data"))
98
+ @@galenic_groups = YAML.load_file(File.join(DATA_DIR, "gal_groups.yaml"))
99
+ @@galenic_forms = YAML.load_file(File.join(DATA_DIR, "gal_forms.yaml"))
102
100
  @@new_galenic_forms = []
103
101
  @@names_without_galenic_forms = []
104
102
  @@rules_counter = {}
105
- attr_accessor :galenic_form, :unit, :pkg_size
106
- attr_reader :name, :substances, :composition, :compositions, :column_c
107
- attr_reader :selling_units, :count, :multi, :measure, :addition, :scale # s.a. commercial_form in oddb.org/src/model/part.rb
108
- def self.get_galenic_group(name, lang = 'de')
103
+ attr_accessor :galenic_form, :unit, :pkg_size
104
+ attr_reader :name, :substances, :composition, :compositions, :column_c
105
+ attr_reader :selling_units, :count, :multi, :measure, :addition, :scale # s.a. commercial_form in oddb.org/src/model/part.rb
106
+ def self.get_galenic_group(name, lang = "de")
109
107
  @@galenic_groups.values.collect { |galenic_group|
110
108
  return galenic_group if galenic_group.descriptions[lang].eql?(name)
111
109
  }
@@ -113,80 +111,84 @@ module Oddb2xml
113
111
  end
114
112
 
115
113
  def self.report_conversion
116
- lines = [ '', '',
117
- 'Report of used conversion rules',
118
- '-------------------------------',
119
- ''
120
- ]
121
- @@rules_counter.each{
122
- | key, value|
123
- lines << "#{key}: #{value} occurrences"
114
+ lines = ["", "",
115
+ "Report of used conversion rules",
116
+ "-------------------------------",
117
+ ""]
118
+ @@rules_counter.each { |key, value|
119
+ lines << "#{key}: #{value} occurrences"
124
120
  }
125
- lines << ''
126
- lines << ''
121
+ lines << ""
122
+ lines << ""
127
123
  lines
128
124
  end
129
125
 
130
- def self.get_galenic_form(name, lang = 'de')
126
+ def self.get_galenic_form(name, lang = "de")
131
127
  @@galenic_forms.values.collect { |galenic_form|
132
128
  return galenic_form if galenic_form.descriptions[lang].eql?(name)
133
- if name and galenic_form.descriptions[lang].eql?(name.sub(' / ', '/'))
129
+ if name && galenic_form.descriptions[lang].eql?(name.sub(" / ", "/"))
134
130
  return galenic_form
135
131
  end
136
132
  }
137
- @@galenic_forms[UnknownGalenicForm]
133
+ @@galenic_forms[UNKNOWN_GALENIC_FORM]
138
134
  end
139
135
 
140
136
  def self.dump_new_galenic_forms
141
137
  if @@new_galenic_forms.size > 0
142
- "\n\n\nAdded the following galenic_forms\n"+ @@new_galenic_forms.uniq.join("\n")
138
+ "\n\n\nAdded the following galenic_forms\n" + @@new_galenic_forms.uniq.join("\n")
143
139
  else
144
140
  "\n\n\nNo new galenic forms added"
145
141
  end
146
142
  end
143
+
147
144
  def self.dump_names_without_galenic_forms
148
145
  if @@names_without_galenic_forms.size > 0
149
- "\n\n\nThe following products did not have a galenic form in column Präparateliste\n"+ @@names_without_galenic_forms.sort.uniq.join("\n")
146
+ "\n\n\nThe following products did not have a galenic form in column Präparateliste\n" + @@names_without_galenic_forms.sort.uniq.join("\n")
150
147
  else
151
148
  "\n\n\nColumn Präparateliste has everywhere a name\n"
152
149
  end
153
150
  end
154
- private
151
+
152
+ private
153
+
155
154
  def remove_duplicated_spaces(string)
156
- string ? string.to_s.gsub(/\s\s+/, ' ') : nil
155
+ string ? string.to_s.gsub(/\s\s+/, " ") : nil
157
156
  end
158
- public
159
- def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
160
- @column_c = column_c ? column_c.gsub(/\s\s+/, ' ') : nil
161
- @name, gal_form = ParseGalenicForm.from_string(column_c)
162
- gal_form = gal_form.gsub(/\s\s+/, ' ').sub(' / ', '/') if gal_form
157
+
158
+ public
159
+
160
+ def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition = nil)
161
+ @column_c = column_c ? column_c.gsub(/\s\s+/, " ") : nil
162
+ @name, gal_form = ParseGalenicForm.from_string(column_c)
163
+ gal_form = gal_form.gsub(/\s\s+/, " ").sub(" / ", "/") if gal_form
163
164
  @galenic_form = search_galenic_info(gal_form)
164
165
  @pkg_size = remove_duplicated_spaces(size)
165
166
  @unit = unit
166
- @selling_units = get_selling_units(@name, @pkg_size, @unit)
167
+ @selling_units = getSellingUnits(@name, @pkg_size, @unit)
167
168
  @composition = composition
168
- @measure = unit if unit and not @measure
169
- unless @galenic_form
170
- parts = column_c.split(/\s+|,|\-/)
171
- parts.each{
172
- |part|
173
- if idx = search_exact_galform(part)
174
- @galenic_form = idx
175
- break
176
- end
177
- }
178
- end if column_c
179
- if @measure and not @galenic_form
180
- @galenic_form ||= search_exact_galform(@measure)
181
- @galenic_form ||= search_exact_galform(@measure.sub('(n)', 'n'))
169
+ @measure = unit if unit && !@measure
170
+ if column_c
171
+ unless @galenic_form
172
+ parts = column_c.split(/\s+|,|-/)
173
+ parts.each { |part|
174
+ if (idx = searchExactGalform(part))
175
+ @galenic_form = idx
176
+ break
177
+ end
178
+ }
179
+ end
182
180
  end
183
- handle_unknown_galform(gal_form)
184
- @measure = @galenic_form.description if @galenic_form and not @measure
181
+ if @measure && !@galenic_form
182
+ @galenic_form ||= searchExactGalform(@measure)
183
+ @galenic_form ||= searchExactGalform(@measure.sub("(n)", "n"))
184
+ end
185
+ handleUnknownGalform(gal_form)
186
+ @measure = @galenic_form.description if @galenic_form && !@measure
185
187
 
186
- unless composition
187
- @compositions = []
188
+ @compositions = if composition
189
+ ParseUtil.parse_compositions(composition, active_substance)
188
190
  else
189
- @compositions = ParseUtil.parse_compositions(composition, active_substance)
191
+ []
190
192
  end
191
193
  end
192
194
 
@@ -196,157 +198,154 @@ public
196
198
 
197
199
  # helper for generating csv
198
200
  def headers
199
- [ "name", "pkg_size", "selling_units", "measure",
201
+ ["name", "pkg_size", "selling_units", "measure",
200
202
  # "count", "multi", "addition", "scale", "unit",
201
203
  "galenic_form",
202
- "galenic_group"
203
- ]
204
+ "galenic_group"]
204
205
  end
206
+
205
207
  def to_array
206
- [ @name, @pkg_size, @selling_units, @measure,
208
+ [@name, @pkg_size, @selling_units, @measure,
207
209
  # @count, @multi, @addition, @scale, @unit,
208
- galenic_form ? galenic_form.description : '' ,
209
- galenic_group ? galenic_group.description : ''
210
- ]
210
+ galenic_form ? galenic_form.description : "",
211
+ galenic_group ? galenic_group.description : ""]
211
212
  end
212
- private
213
+
214
+ private
213
215
 
214
216
  def update_rule(rulename)
215
217
  @@rules_counter[rulename] ||= 0
216
218
  @@rules_counter[rulename] += 1
217
219
  end
218
220
 
219
- def get_selling_units(part_from_name_C, pkg_size_L, einheit_M)
220
- begin
221
- break_condition = (defined?(Pry) and false) # /5 x 2500 ml/.match(pkg_size_L))
222
- return pkg_size_to_int(pkg_size_L) unless part_from_name_C
223
- part_from_name_C = part_from_name_C.gsub(/[()]/, '_')
224
- Measurements.each{ |x|
225
- if einheit_M and /^#{x}$/i.match(einheit_M)
226
- puts "measurement in einheit_M #{einheit_M} matched: #{x}" if $VERBOSE
227
- update_rule('measurement einheit_M')
228
- @measure = x
229
- binding.pry if break_condition
230
- return pkg_size_to_int(pkg_size_L, true)
231
- end
232
- }
233
- FesteFormen.each{ |x|
234
- if part_from_name_C and (x.gsub(/[()]/, '_')).match(part_from_name_C)
235
- puts "feste_form in #{part_from_name_C} matched: #{x}" if $VERBOSE
236
- update_rule('feste_form name_C')
237
- @measure = x
238
- binding.pry if break_condition
239
- return pkg_size_to_int(pkg_size_L)
240
- end
241
- if einheit_M and x.eql?(einheit_M)
242
- puts "feste_form in einheit_M #{einheit_M} matched: #{x}" if $VERBOSE
243
- update_rule('feste_form einheit_M')
244
- @measure = x
245
- binding.pry if break_condition
246
- return pkg_size_to_int(pkg_size_L)
247
- end
248
- }
249
- FluidForms.each{ |x|
250
- if part_from_name_C and x.match(part_from_name_C)
251
- puts "liquid_form in #{part_from_name_C} matched: #{x}" if $VERBOSE
252
- update_rule('liquid_form name_C')
253
- @measure = x
254
- binding.pry if break_condition
255
- return pkg_size_to_int(pkg_size_L, true)
256
- end
257
- if part_from_name_C and x.match(part_from_name_C.split(' ')[0])
258
- puts "liquid_form in #{part_from_name_C} matched: #{x}" if $VERBOSE
259
- update_rule('liquid_form first_part')
260
- binding.pry if break_condition
261
- return pkg_size_to_int(pkg_size_L, true)
262
- end
263
- if einheit_M and x.eql?(einheit_M)
264
- puts "liquid_form in einheit_M #{einheit_M} matched: #{x}" if $VERBOSE
265
- update_rule('liquid_form einheit_M')
266
- @measure = x
267
- binding.pry if break_condition
268
- return pkg_size_to_int(pkg_size_L, Measurements.find{ |x| pkg_size_L.index(" #{x}")})
269
- end
270
- }
271
- Measurements.each{ |x|
272
- if pkg_size_L and pkg_size_L.split(' ').index(x)
273
- puts "measurement in pkg_size_L #{pkg_size_L} matched: #{x}" if $VERBOSE
274
- update_rule('measurement pkg_size_L')
275
- @measure = x
276
- binding.pry if break_condition
277
- return pkg_size_to_int(pkg_size_L, true)
278
- end
279
- }
280
- binding.pry if break_condition
281
- puts "Could not find anything for name_C #{part_from_name_C} pkg_size_L: #{pkg_size_L} einheit_M #{einheit_M}" if $VERBOSE
282
- update_rule('unbekannt')
283
- return 'unbekannt'
284
- rescue RegexpError => e
285
- puts "RegexpError for M: #{einheit_M} pkg_size_L #{pkg_size_L} C: #{part_from_name_C}"
286
- update_rule('RegexpError')
287
- return 'error'
288
- end
221
+ def getSellingUnits(part_from_name_c, pkg_size_l, einheit_m)
222
+ # break_condition = (defined?(Pry) && false) # /5 x 2500 ml/.match(pkg_size_l))
223
+ return pkgSizeToInt(pkg_size_l) unless part_from_name_c
224
+ part_from_name_c = part_from_name_c.gsub(/[()]/, "_")
225
+ MEASUREMENTS.each { |x|
226
+ if einheit_m && /^#{x}$/i.match(einheit_m)
227
+ puts "measurement in einheit_m #{einheit_m} matched: #{x}" if $VERBOSE
228
+ update_rule("measurement einheit_m")
229
+ @measure = x
230
+ # binding.pry if break_condition
231
+ return pkgSizeToInt(pkg_size_l, true)
232
+ end
233
+ }
234
+ FESTE_FORMEN.each { |x|
235
+ if part_from_name_c && (x.gsub(/[()]/, "_")).match(part_from_name_c)
236
+ puts "feste_form in #{part_from_name_c} matched: #{x}" if $VERBOSE
237
+ update_rule("feste_form name_C")
238
+ @measure = x
239
+ # binding.pry if break_condition
240
+ return pkgSizeToInt(pkg_size_l)
241
+ end
242
+ if einheit_m && x.eql?(einheit_m)
243
+ puts "feste_form in einheit_m #{einheit_m} matched: #{x}" if $VERBOSE
244
+ update_rule("feste_form einheit_m")
245
+ @measure = x
246
+ # binding.pry if break_condition
247
+ return pkgSizeToInt(pkg_size_l)
248
+ end
249
+ }
250
+ FLUIDFORMS.each { |x|
251
+ if part_from_name_c && x.match(part_from_name_c)
252
+ puts "liquid_form in #{part_from_name_c} matched: #{x}" if $VERBOSE
253
+ update_rule("liquid_form name_C")
254
+ @measure = x
255
+ # binding.pry if break_condition
256
+ return pkgSizeToInt(pkg_size_l, true)
257
+ end
258
+ if part_from_name_c && x.match(part_from_name_c.split(" ")[0])
259
+ puts "liquid_form in #{part_from_name_c} matched: #{x}" if $VERBOSE
260
+ update_rule("liquid_form first_part")
261
+ # binding.pry if break_condition
262
+ return pkgSizeToInt(pkg_size_l, true)
263
+ end
264
+ if einheit_m && x.eql?(einheit_m)
265
+ puts "liquid_form in einheit_m #{einheit_m} matched: #{x}" if $VERBOSE
266
+ update_rule("liquid_form einheit_m")
267
+ @measure = x
268
+ # binding.pry if break_condition
269
+ return pkgSizeToInt(pkg_size_l, MEASUREMENTS.find { |x| pkg_size_l.index(" #{x}") })
270
+ end
271
+ }
272
+ MEASUREMENTS.each { |x|
273
+ if pkg_size_l&.split(" ")&.index(x)
274
+ puts "measurement in pkg_size_l #{pkg_size_l} matched: #{x}" if $VERBOSE
275
+ update_rule("measurement pkg_size_l")
276
+ @measure = x
277
+ # binding.pry if break_condition
278
+ return pkgSizeToInt(pkg_size_l, true)
279
+ end
280
+ }
281
+ # binding.pry if break_condition
282
+ puts "Could not find anything for name_C #{part_from_name_c} pkg_size_l: #{pkg_size_l} einheit_m #{einheit_m}" if $VERBOSE
283
+ update_rule("unbekannt")
284
+ "unbekannt"
285
+ rescue RegexpError
286
+ puts "RegexpError for M: #{einheit_m} pkg_size_l #{pkg_size_l} C: #{part_from_name_c}"
287
+ update_rule("RegexpError")
288
+ "error"
289
289
  end
290
290
 
291
- def pkg_size_to_int(pkg_size, skip_last_part = false)
291
+ def pkgSizeToInt(pkg_size, skip_last_part = false)
292
292
  return pkg_size if pkg_size.is_a?(Integer)
293
293
  return 1 unless pkg_size
294
294
  parts = pkg_size.split(/\s*x\s*/i)
295
- parts = parts[0..-2] if skip_last_part and parts.size > 1
295
+ parts = parts[0..-2] if skip_last_part && (parts.size > 1)
296
296
  last_multiplier = parts[-1].to_i > 0 ? parts[-1].to_i : 1
297
297
  if parts.size == 3
298
- return parts[0].to_i * parts[1].to_i * last_multiplier
298
+ parts[0].to_i * parts[1].to_i * last_multiplier
299
299
  elsif parts.size == 2
300
- return parts[0].to_i * last_multiplier
300
+ parts[0].to_i * last_multiplier
301
301
  elsif parts.size == 1
302
- return last_multiplier
302
+ last_multiplier
303
303
  else
304
- return 1
304
+ 1
305
305
  end
306
306
  end
307
307
 
308
- def search_exact_galform(name)
308
+ def searchExactGalform(name)
309
309
  return nil unless name
310
- if idx = @@galenic_forms.values.find{|x| x.descriptions['de'] and x.descriptions['de'].downcase.eql?(name.downcase) } or
311
- idx = @@galenic_forms.values.find{|x| x.descriptions['fr'] and x.descriptions['fr'].downcase.eql?(name.downcase) } or
312
- idx = @@galenic_forms.values.find{|x| x.descriptions['en'] and x.descriptions['en'].downcase.eql?(name.downcase) }
310
+ if (idx = @@galenic_forms.values.find { |x| x.descriptions["de"] && x.descriptions["de"].downcase.eql?(name.downcase) }) ||
311
+ (idx = @@galenic_forms.values.find { |x| x.descriptions["fr"] && x.descriptions["fr"].downcase.eql?(name.downcase) }) ||
312
+ (idx = @@galenic_forms.values.find { |x| x.descriptions["en"] && x.descriptions["en"].downcase.eql?(name.downcase) })
313
313
  return idx
314
314
  end
315
- return nil
315
+ nil
316
316
  end
317
317
 
318
- def handle_unknown_galform(gal_form)
318
+ def handleUnknownGalform(gal_form)
319
319
  return if @galenic_form
320
320
  if gal_form
321
- @galenic_form = GalenicForm.new(0, {'de' => remove_duplicated_spaces(gal_form.gsub(' +', ' '))}, @@galenic_forms[UnknownGalenicForm] )
321
+ @galenic_form = GalenicForm.new(0, {"de" => remove_duplicated_spaces(gal_form.gsub(" +", " "))}, @@galenic_forms[UNKNOWN_GALENIC_FORM])
322
322
  @@new_galenic_forms << gal_form
323
323
  else
324
- @galenic_form = @@galenic_forms[UnknownGalenicForm]
324
+ @galenic_form = @@galenic_forms[UNKNOWN_GALENIC_FORM]
325
325
  end
326
326
  end
327
327
 
328
328
  def search_galenic_info(gal_form)
329
- if idx = search_exact_galform(gal_form)
329
+ if (idx = searchExactGalform(gal_form))
330
330
  return idx
331
331
  end
332
- if gal_form and gal_form.index(',')
332
+ if gal_form&.index(",")
333
333
  parts = gal_form.split(/\s+|,/)
334
- parts.each{
335
- |part|
336
- if idx = search_exact_galform(part)
334
+ parts.each { |part|
335
+ if (idx = searchExactGalform(part))
337
336
  return idx
338
337
  end
339
338
  }
340
339
  elsif gal_form
341
- if gal_form.eql?('capsule')
342
- idx = search_exact_galform('capsules')
340
+ if gal_form.eql?("capsule")
341
+ idx = searchExactGalform("capsules")
343
342
  return idx
344
343
  end
345
- if idx = search_exact_galform(gal_form)
344
+ if (idx = searchExactGalform(gal_form))
346
345
  return idx
347
346
  end
348
347
  end
349
- return nil
348
+ nil
350
349
  end
351
350
  end
352
351
  end