Class: Oddb2xml::Calc

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb2xml/calc.rb

Constant Summary collapse

FluidForms =
[
'Ampulle(n)',
'Beutel',
'Bolus/Boli',
'Bq',
'Dose(n)',
'Durchstechflasche(n)',
'Einmaldosenbehälter',
'Einzeldose(n)',
'Fertigspritze',
'Fertigspritze(n)',
'Flasche(n)',
'I.E.',
'Infusionskonzentrat',
'Infusionslösung',
'Infusionsemulsion',
'Inhalationen',
'Inhalator',
'Injektions-Set',
'Injektions-Sets',
'Injektor(en), vorgefüllt/Pen',
'Klistier(e)',
'MBq',
'Pipetten',
'Sachet(s)',
'Spritze(n)',
'Sprühstösse',
'Stechampulle (Lyophilisat) und Ampulle (Solvens)',
'Stechampulle',
'Suspension',
'Zylinderampulle(n)',
'cartouches',
'dose(s)',
'flacon perforable',
'sacchetto',
'vorgefüllter Injektor',
]
FesteFormen =
[
  'Depotabs',
  'Dragée(s)',
  'Generator mit folgenden Aktivitäten:',
  'Filmtabletten',
  'Gerät',
  'Kapsel(n)',
  'Kautabletten',
  'Lutschtabletten',
  'Kugeln',
  'Ovulum',
  'Packung(en)',
  'Pflaster',
  'Schmelzfilme',
  'Set',
  'Strips',
  'Stück',
  'Suppositorien',
  'Tablette(n)',
  'Tüchlein',
  'Urethrastab',
  'Vaginalzäpfchen',
  'comprimé',
  'comprimé pelliculé',
  'comprimés',
  'comprimés à libération modifiée',
  'comprimés à croquer sécables',
  'imprägnierter Verband',
  'magensaftresistente Filmtabletten',
  'ovale Körper',
  'tube(s)',
]
Measurements =
[ 'g', 'kg', 'l', 'mg', 'ml', 'cm', 'GBq']
Others =
['Kombipackung', 'emballage combiné' ]
UnknownGalenicForm =
140
UnknownGalenicGroup =
1
Data_dir =
File.expand_path(File.join(File.dirname(__FILE__),'..','..', 'data'))
@@galenic_groups =
YAML.load_file(File.join(Data_dir, 'gal_groups.yaml'))
@@galenic_forms =
YAML.load_file(File.join(Data_dir, 'gal_forms.yaml'))
@@new_galenic_forms =
[]
@@names_without_galenic_forms =
[]
@@rules_counter =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition = nil) ⇒ Calc

Returns a new instance of Calc.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/oddb2xml/calc.rb', line 159

def initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition= nil)
  @column_c = column_c ? column_c.gsub(/\s\s+/, ' ') : nil
  @name, gal_form =  ParseGalenicForm.from_string(column_c)
  gal_form = gal_form.gsub(/\s\s+/, ' ').sub(' / ', '/') if gal_form
  @galenic_form = search_galenic_info(gal_form)
  @pkg_size = remove_duplicated_spaces(size)
  @unit = unit
  @selling_units = get_selling_units(@name, @pkg_size, @unit)
  @composition = composition
  @measure = unit if unit and not @measure
  unless @galenic_form
    parts = column_c.split(/\s+|,|\-/)
    parts.each{
      |part|
      if idx = search_exact_galform(part)
        @galenic_form = idx
        break
      end
    }
  end if column_c
  if @measure and not @galenic_form
    @galenic_form ||= search_exact_galform(@measure)
    @galenic_form ||= search_exact_galform(@measure.sub('(n)', 'n'))
  end
  handle_unknown_galform(gal_form)
  @measure = @galenic_form.description if @galenic_form and not @measure

  unless composition
    @compositions = []
  else
    @compositions = ParseUtil.parse_compositions(composition, active_substance)
  end
end

Instance Attribute Details

#additionObject (readonly)

s.a. commercial_form in oddb.org/src/model/part.rb



107
108
109
# File 'lib/oddb2xml/calc.rb', line 107

def addition
  @addition
end

#column_cObject (readonly)

Returns the value of attribute column_c.



106
107
108
# File 'lib/oddb2xml/calc.rb', line 106

def column_c
  @column_c
end

#compositionObject (readonly)

Returns the value of attribute composition.



106
107
108
# File 'lib/oddb2xml/calc.rb', line 106

def composition
  @composition
end

#compositionsObject (readonly)

Returns the value of attribute compositions.



106
107
108
# File 'lib/oddb2xml/calc.rb', line 106

def compositions
  @compositions
end

#countObject (readonly)

s.a. commercial_form in oddb.org/src/model/part.rb



107
108
109
# File 'lib/oddb2xml/calc.rb', line 107

def count
  @count
end

#galenic_formObject

Returns the value of attribute galenic_form.



105
106
107
# File 'lib/oddb2xml/calc.rb', line 105

def galenic_form
  @galenic_form
end

#measureObject (readonly)

s.a. commercial_form in oddb.org/src/model/part.rb



107
108
109
# File 'lib/oddb2xml/calc.rb', line 107

def measure
  @measure
end

#multiObject (readonly)

s.a. commercial_form in oddb.org/src/model/part.rb



107
108
109
# File 'lib/oddb2xml/calc.rb', line 107

def multi
  @multi
end

#nameObject (readonly)

Returns the value of attribute name.



106
107
108
# File 'lib/oddb2xml/calc.rb', line 106

def name
  @name
end

#pkg_sizeObject

Returns the value of attribute pkg_size.



105
106
107
# File 'lib/oddb2xml/calc.rb', line 105

def pkg_size
  @pkg_size
end

#scaleObject (readonly)

s.a. commercial_form in oddb.org/src/model/part.rb



107
108
109
# File 'lib/oddb2xml/calc.rb', line 107

def scale
  @scale
end

#selling_unitsObject (readonly)

s.a. commercial_form in oddb.org/src/model/part.rb



107
108
109
# File 'lib/oddb2xml/calc.rb', line 107

def selling_units
  @selling_units
end

#substancesObject (readonly)

Returns the value of attribute substances.



106
107
108
# File 'lib/oddb2xml/calc.rb', line 106

def substances
  @substances
end

#unitObject

Returns the value of attribute unit.



105
106
107
# File 'lib/oddb2xml/calc.rb', line 105

def unit
  @unit
end

Class Method Details

.dump_names_without_galenic_formsObject



147
148
149
150
151
152
153
# File 'lib/oddb2xml/calc.rb', line 147

def self.dump_names_without_galenic_forms
  if @@names_without_galenic_forms.size > 0
    "\n\n\nThe following products did not have a galenic form in column Präparateliste\n"+ @@names_without_galenic_forms.sort.uniq.join("\n")
  else
    "\n\n\nColumn Präparateliste has everywhere a name\n"
  end
end

.dump_new_galenic_formsObject



140
141
142
143
144
145
146
# File 'lib/oddb2xml/calc.rb', line 140

def self.dump_new_galenic_forms
  if @@new_galenic_forms.size > 0
    "\n\n\nAdded the following galenic_forms\n"+ @@new_galenic_forms.uniq.join("\n")
  else
    "\n\n\nNo new galenic forms added"
  end
end

.get_galenic_form(name, lang = 'de') ⇒ Object



130
131
132
133
134
135
136
137
138
# File 'lib/oddb2xml/calc.rb', line 130

def self.get_galenic_form(name, lang = 'de')
  @@galenic_forms.values.collect { |galenic_form|
    return galenic_form if galenic_form.descriptions[lang].eql?(name)
    if name and galenic_form.descriptions[lang].eql?(name.sub(' / ', '/'))
      return galenic_form
    end
  }
  @@galenic_forms[UnknownGalenicForm]
end

.get_galenic_group(name, lang = 'de') ⇒ Object



108
109
110
111
112
113
# File 'lib/oddb2xml/calc.rb', line 108

def self.get_galenic_group(name, lang = 'de')
  @@galenic_groups.values.collect { |galenic_group|
    return galenic_group if galenic_group.descriptions[lang].eql?(name)
  }
  @@galenic_groups[1]
end

.report_conversionObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/oddb2xml/calc.rb', line 115

def self.report_conversion
  lines = [ '', '',
            'Report of used conversion rules',
            '-------------------------------',
            ''
            ]
  @@rules_counter.each{
    | key, value|
      lines << "#{key}: #{value} occurrences"
  }
  lines << ''
  lines << ''
  lines
end

Instance Method Details

#galenic_groupObject



193
194
195
# File 'lib/oddb2xml/calc.rb', line 193

def galenic_group
  @@galenic_groups[@galenic_form.galenic_group]
end

#headersObject

helper for generating csv



198
199
200
201
202
203
204
# File 'lib/oddb2xml/calc.rb', line 198

def headers
  [ "name", "pkg_size", "selling_units", "measure",
    # "count", "multi", "addition", "scale", "unit",
    "galenic_form",
    "galenic_group"
    ]
end

#to_arrayObject



205
206
207
208
209
210
211
# File 'lib/oddb2xml/calc.rb', line 205

def to_array
  [ @name, @pkg_size, @selling_units, @measure,
    # @count, @multi, @addition, @scale, @unit,
    galenic_form  ? galenic_form.description  : '' ,
    galenic_group ? galenic_group.description : ''
    ]
end