def to_hash
data = Hash.new { |h, k| h[k] = [] }
return data unless @xml.size > 0
result = MedicalInformationsContent.parse(@xml.sub(STRIP_FOR_SAX_MACHINE, ""), lazy: true)
result.medicalInformation.each do |pac|
lang = pac.lang.to_s
next unless /de|fr/.match?(lang)
item = {}
item[:refdata] = true
item[:data_origin] = "swissmedic_info"
item[:name] = (name = pac.title) ? name : ""
item[:owner] = (ownr = pac.authHolder) ? ownr : ""
item[:style] = Nokogiri::HTML.fragment(pac.style).to_html(encoding: "UTF-8")
html = Nokogiri::HTML.fragment(pac.content.force_encoding("UTF-8"))
item[:paragraph] = html
numbers = /(\d{5})[,\s]*(\d{5})?|(\d{5})[,\s]*(\d{5})?[,\s]*(\d{5})?/.match(html)
if numbers
[$1, $2, $3].compact.each do |n|
item[:monid] = n
data[lang] << item
end
end
end
data
end