209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/oddb2xml/extractor.rb', line 209
def to_hash
data = {}
result = SwissRegArticles.parse(@xml.sub(STRIP_FOR_SAX_MACHINE, ""), lazy: true)
result.Article.each do |article|
article_type = article.MedicinalProduct.ProductClassification.ProductClass
if article_type != @type
next
end
ean13 = @type == "PHARMA" ? article.PackagedProduct.DataCarrierIdentifier : article.MedicinalProduct.Identifier
if ean13.size < 13
puts "Refdata #{@type} use 13 chars not #{ean13.size} for #{ean13}" if $VERBOSE
ean13 = ean13.rjust(13, "0")
end
if ean13.size == 14 && ean13[0] == "0"
puts "Refdata #{@type} remove leading '0' for #{ean13}" if $VERBOSE
ean13 = ean13[1..-1]
end
item = {}
item[:ean13] = ean13
item[:no8] = article.PackagedProduct.RegulatedAuthorisationIdentifier || ""
item[:data_origin] = "refdata"
item[:refdata] = true
item[:_type] = @type.downcase.to_sym
item[:last_change] = ""
item[:desc_de] = ""
item[:desc_fr] = ""
item[:desc_it] = ""
article.PackagedProduct.Name.each do |name|
if name.Language == "DE"
item[:desc_de] = name.FullName
elsif name.Language == "FR"
item[:desc_fr] = name.FullName
elsif name.Language == "IT"
item[:desc_it] = name.FullName
end
end
item[:atc_code] = article.MedicinalProduct.ProductClassification.Atc || ""
item[:company_name] = article.PackagedProduct.Holder.Name || ""
item[:company_ean] = article.PackagedProduct.Holder.Identifier || ""
data[ean13] = item
end
data
end
|