Class: Oddb2xml::Calc
- Inherits:
-
Object
- Object
- Oddb2xml::Calc
- 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.(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
-
#addition ⇒ Object
readonly
s.a.
-
#composition ⇒ Object
readonly
Returns the value of attribute composition.
-
#compositions ⇒ Object
readonly
Returns the value of attribute compositions.
-
#count ⇒ Object
readonly
s.a.
-
#galenic_form ⇒ Object
Returns the value of attribute galenic_form.
-
#measure ⇒ Object
readonly
s.a.
-
#multi ⇒ Object
readonly
s.a.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pkg_size ⇒ Object
Returns the value of attribute pkg_size.
-
#scale ⇒ Object
readonly
s.a.
-
#selling_units ⇒ Object
readonly
s.a.
-
#substances ⇒ Object
readonly
Returns the value of attribute substances.
-
#unit ⇒ Object
Returns the value of attribute unit.
Class Method Summary collapse
-
.check_for_value_and_units(what) ⇒ Object
Parse a string for a numerical value and unit, e.g.
- .dump_names_without_galenic_forms ⇒ Object
- .dump_new_galenic_forms ⇒ Object
- .get_galenic_form(name, lang = 'de') ⇒ Object
- .get_galenic_group(name, lang = 'de') ⇒ Object
- .report_conversion ⇒ Object
Instance Method Summary collapse
- #galenic_form__xxx ⇒ Object
- #galenic_group ⇒ Object
-
#headers ⇒ Object
helper for generating csv.
-
#initialize(name = nil, size = nil, unit = nil, active_substance = nil, composition = nil) ⇒ Calc
constructor
A new instance of Calc.
- #to_array ⇒ Object
Constructor Details
#initialize(name = 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 |
# File 'lib/oddb2xml/calc.rb', line 159 def initialize(name = nil, size = nil, unit = nil, active_substance = nil, composition= nil) @name = remove_duplicated_spaces(name) @pkg_size = remove_duplicated_spaces(size) @unit = unit # @pkg_size, @galenic_group, @galenic_form = search_galenic_info @composition = composition @measure = unit if unit and not @measure @measure = @galenic_form.description if @galenic_form and not @measure @galenic_form ||= @@galenic_forms[UnknownGalenicForm] unless composition @compositions = [] else @compositions = ParseUtil.parse_compositions(composition, active_substance) end end |
Instance Attribute Details
#addition ⇒ Object (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 |
#composition ⇒ Object (readonly)
Returns the value of attribute composition.
106 107 108 |
# File 'lib/oddb2xml/calc.rb', line 106 def composition @composition end |
#compositions ⇒ Object (readonly)
Returns the value of attribute compositions.
106 107 108 |
# File 'lib/oddb2xml/calc.rb', line 106 def compositions @compositions end |
#count ⇒ Object (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_form ⇒ Object
Returns the value of attribute galenic_form.
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def galenic_form @galenic_form end |
#measure ⇒ Object (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 |
#multi ⇒ Object (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 |
#name ⇒ Object (readonly)
Returns the value of attribute name.
106 107 108 |
# File 'lib/oddb2xml/calc.rb', line 106 def name @name end |
#pkg_size ⇒ Object
Returns the value of attribute pkg_size.
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def pkg_size @pkg_size end |
#scale ⇒ Object (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_units ⇒ Object (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 |
#substances ⇒ Object (readonly)
Returns the value of attribute substances.
106 107 108 |
# File 'lib/oddb2xml/calc.rb', line 106 def substances @substances end |
#unit ⇒ Object
Returns the value of attribute unit.
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def unit @unit end |
Class Method Details
.check_for_value_and_units(what) ⇒ Object
Parse a string for a numerical value and unit, e.g. 1.5 ml
295 296 297 298 299 300 301 302 |
# File 'lib/oddb2xml/calc.rb', line 295 def self.check_for_value_and_units(what) if m = /^([\d.]+)\s*(\D+)/.match(what) # return [m[1], m[2] ] return m[0].to_s else nil end end |
.dump_names_without_galenic_forms ⇒ Object
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_forms ⇒ Object
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_conversion ⇒ Object
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_form__xxx ⇒ Object
196 197 198 |
# File 'lib/oddb2xml/calc.rb', line 196 def galenic_form__xxx @galenic_form.description end |
#galenic_group ⇒ Object
177 178 179 |
# File 'lib/oddb2xml/calc.rb', line 177 def galenic_group @@galenic_groups[@galenic_form.galenic_group] end |
#headers ⇒ Object
helper for generating csv
182 183 184 185 186 187 188 |
# File 'lib/oddb2xml/calc.rb', line 182 def headers [ "name", "pkg_size", "selling_units", "measure", # "count", "multi", "addition", "scale", "unit", "galenic_form", "galenic_group" ] end |
#to_array ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/oddb2xml/calc.rb', line 189 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 |