Skip to content

Commit

Permalink
Update SMCAT to use Packungen.xls
Browse files Browse the repository at this point in the history
  • Loading branch information
Yasuhiro Asaka committed Feb 1, 2013
1 parent 36b905b commit 1858c67
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
11 changes: 10 additions & 1 deletion lib/oddb2xml/builder.rb
Expand Up @@ -489,6 +489,11 @@ def build_article
if obj[:seq]
bg_pac = obj[:seq][:packages][de_pac[:pharmacode]]
end
if de_pac[:ean].length == 13
num = de_pac[:ean][4,8].intern # :swissmedic_number5
elsif bg_pac
num = bg_pac[:swissmedic_number8].intern
end
xml.ART('DT' => '') {
xml.PHAR de_pac[:pharmacode] unless de_pac[:pharmacode].empty?
#xml.GRPCD
Expand All @@ -497,8 +502,12 @@ def build_article
if obj[:seq]
xml.PRDNO obj[:seq][:product_key] unless obj[:seq][:product_key].empty?
end
if bg_pac
if bg_pac # bag xml
xml.SMCAT bg_pac[:swissmedic_category] unless bg_pac[:swissmedic_category].empty?
elsif @packs[num] and @packs[num][:swissmedic_category] # Packungen.xls
xml.SMCAT @packs[num][:swissmedic_category]
end
if bg_pac
xml.SMNO bg_pac[:swissmedic_number8] unless bg_pac[:swissmedic_number8].empty?
end
#xml.HOSPCD
Expand Down
19 changes: 9 additions & 10 deletions lib/oddb2xml/cli.rb
Expand Up @@ -31,9 +31,9 @@ def initialize(args)
end
def run
threads = []
# swissmedic-info
if @options[:format] != :dat
if @options[:fi]
# swissmedic-info
threads << Thread.new do
downloader = SwissmedicInfoDownloader.new
xml = downloader.download
Expand All @@ -59,15 +59,6 @@ def run
@actions = EphaExtractor.new(str).to_arry
end
end
else # dat
# swissmedic - package
threads << Thread.new do
downloader = SwissmedicDownloader.new(:packages)
bin = downloader.download
@mutex.synchronize do
@packs = SwissmedicExtractor.new(bin, :packages).to_hash
end
end
end
if @options[:nonpharma]
# NonPharma.xls - files
Expand All @@ -77,6 +68,14 @@ def run
@migel = MigelExtractor.new(bin).to_hash
end
end
# swissmedic - package
threads << Thread.new do
downloader = SwissmedicDownloader.new(:packages)
bin = downloader.download
@mutex.synchronize do
@packs = SwissmedicExtractor.new(bin, :packages).to_hash
end
end
# bm - files
threads << Thread.new do
downloader = BMUpdateDownloader.new
Expand Down

0 comments on commit 1858c67

Please sign in to comment.