29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/oddb/import/whocc.rb', line 29
def import_document(doc)
REXML::XPath.each(doc, '//rs:data/rw:row',
"rs" => 'urn:schemas-microsoft-com:rowset',
"rw" => '#RowsetSchema') { |row|
attrs = row.attributes
code = attrs['ATCCode']
atc = Drugs::Atc.find_by_code(code) || Drugs::Atc.new(code)
adm = attrs['AdmCode']
= attrs['DDDComment']
ddd = atc.ddds.find { |candidate|
adm == candidate.administration \
&& == candidate.
} || Drugs::Ddd.new(adm)
ddd. =
unit = attrs['UnitType']
unit = UNIT_REPLACEMENTS.fetch(unit, unit)
ddd.dose = Drugs::Dose.new(attrs['DDD'], unit)
ddd.atc = atc
ddd.save
atc.save
}
end
|