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" ]
- FESTE_FORMEN =
[ "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é"]
- UNKNOWN_GALENIC_FORM =
140
- UNKNOWN_GALENIC_GROUP =
1
- DATA_DIR =
File.(File.join(File.dirname(__FILE__), "..", "..", "data"))
- @@galenic_groups =
YAML.safe_load_file(File.join(DATA_DIR, "gal_groups.yaml"), permitted_classes: [ Oddb2xml::GalenicForm, Oddb2xml::GalenicGroup, Symbol])
- @@galenic_forms =
YAML.safe_load_file(File.join(DATA_DIR, "gal_forms.yaml"), permitted_classes: [ Oddb2xml::GalenicForm, Oddb2xml::GalenicGroup, Symbol])
- @@new_galenic_forms =
[]
- @@names_without_galenic_forms =
[]
- @@rules_counter =
{}
Instance Attribute Summary collapse
-
#addition ⇒ Object
readonly
s.a.
-
#column_c ⇒ Object
readonly
Returns the value of attribute column_c.
-
#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
- .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_group ⇒ Object
-
#headers ⇒ Object
helper for generating csv.
-
#initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition = nil) ⇒ Calc
constructor
A new instance of Calc.
- #to_array ⇒ Object
Constructor Details
#initialize(column_c = nil, size = nil, unit = nil, active_substance = nil, composition = nil) ⇒ Calc
Returns a new instance of Calc.
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 192 193 |
# File 'lib/oddb2xml/calc.rb', line 160 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 = getSellingUnits(@name, @pkg_size, @unit) @composition = composition @measure = unit if unit && !@measure if column_c unless @galenic_form parts = column_c.split(/\s+|,|-/) parts.each { |part| if (idx = searchExactGalform(part)) @galenic_form = idx break end } end end if @measure && !@galenic_form @galenic_form ||= searchExactGalform(@measure) @galenic_form ||= searchExactGalform(@measure.sub("(n)", "n")) end handleUnknownGalform(gal_form) @measure = @galenic_form.description if @galenic_form && !@measure @compositions = if composition ParseUtil.parse_compositions(composition, active_substance) else [] end end |
Instance Attribute Details
#addition ⇒ Object (readonly)
s.a. commercial_form in oddb.org/src/model/part.rb
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def addition @addition end |
#column_c ⇒ Object (readonly)
Returns the value of attribute column_c.
104 105 106 |
# File 'lib/oddb2xml/calc.rb', line 104 def column_c @column_c end |
#composition ⇒ Object (readonly)
Returns the value of attribute composition.
104 105 106 |
# File 'lib/oddb2xml/calc.rb', line 104 def composition @composition end |
#compositions ⇒ Object (readonly)
Returns the value of attribute compositions.
104 105 106 |
# File 'lib/oddb2xml/calc.rb', line 104 def compositions @compositions end |
#count ⇒ Object (readonly)
s.a. commercial_form in oddb.org/src/model/part.rb
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def count @count end |
#galenic_form ⇒ Object
Returns the value of attribute galenic_form.
103 104 105 |
# File 'lib/oddb2xml/calc.rb', line 103 def galenic_form @galenic_form end |
#measure ⇒ Object (readonly)
s.a. commercial_form in oddb.org/src/model/part.rb
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def measure @measure end |
#multi ⇒ Object (readonly)
s.a. commercial_form in oddb.org/src/model/part.rb
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def multi @multi end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
104 105 106 |
# File 'lib/oddb2xml/calc.rb', line 104 def name @name end |
#pkg_size ⇒ Object
Returns the value of attribute pkg_size.
103 104 105 |
# File 'lib/oddb2xml/calc.rb', line 103 def pkg_size @pkg_size end |
#scale ⇒ Object (readonly)
s.a. commercial_form in oddb.org/src/model/part.rb
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def scale @scale end |
#selling_units ⇒ Object (readonly)
s.a. commercial_form in oddb.org/src/model/part.rb
105 106 107 |
# File 'lib/oddb2xml/calc.rb', line 105 def selling_units @selling_units end |
#substances ⇒ Object (readonly)
Returns the value of attribute substances.
104 105 106 |
# File 'lib/oddb2xml/calc.rb', line 104 def substances @substances end |
#unit ⇒ Object
Returns the value of attribute unit.
103 104 105 |
# File 'lib/oddb2xml/calc.rb', line 103 def unit @unit end |
Class Method Details
.dump_names_without_galenic_forms ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/oddb2xml/calc.rb', line 144 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
136 137 138 139 140 141 142 |
# File 'lib/oddb2xml/calc.rb', line 136 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
126 127 128 129 130 131 132 133 134 |
# File 'lib/oddb2xml/calc.rb', line 126 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 && galenic_form.descriptions[lang].eql?(name.sub(" / ", "/")) return galenic_form end } @@galenic_forms[UNKNOWN_GALENIC_FORM] end |
.get_galenic_group(name, lang = "de") ⇒ Object
106 107 108 109 110 111 |
# File 'lib/oddb2xml/calc.rb', line 106 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
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/oddb2xml/calc.rb', line 113 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_group ⇒ Object
195 196 197 |
# File 'lib/oddb2xml/calc.rb', line 195 def galenic_group @@galenic_groups[@galenic_form.galenic_group] end |
#headers ⇒ Object
helper for generating csv
200 201 202 203 204 205 |
# File 'lib/oddb2xml/calc.rb', line 200 def headers ["name", "pkg_size", "selling_units", "measure", # "count", "multi", "addition", "scale", "unit", "galenic_form", "galenic_group"] end |
#to_array ⇒ Object
207 208 209 210 211 212 |
# File 'lib/oddb2xml/calc.rb', line 207 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 |