Skip to content

Commit

Permalink
Removed loading file for blood products and vaccines
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Jan 11, 2016
1 parent dba6594 commit c95ecce
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 224 deletions.
5 changes: 5 additions & 0 deletions History.txt
@@ -1,3 +1,8 @@
=== 2.3.2 /11.01.2016

* File from swissmedic for blood products and vaccines has no longer a field Kühlkette. Therefore no longer downloading it.
* Set oddb_article COOL for all blod products and vaccines

=== 2.3.1 /15.12.2015

* Deactivate (Pseudo-)Migel. Updated corresponding tests
Expand Down
11 changes: 3 additions & 8 deletions lib/oddb2xml/builder.rb
Expand Up @@ -35,7 +35,7 @@ module Oddb2xml
}
class Builder
attr_accessor :subject, :refdata, :items, :flags, :lppvs,
:actions, :migel, :orphan, :fridge,
:actions, :migel, :orphan,
:infos, :packs, :infos_zur_rose,
:ean14, :tag_suffix,
:companies, :people,
Expand All @@ -53,7 +53,6 @@ def initialize(args = {})
@infos_zur_rose = {} # zurrose
@actions = []
@orphan = []
@fridge = []
@ean14 = false
@companies = []
@people = []
Expand Down Expand Up @@ -831,10 +830,7 @@ def build_article
xml.LIMPTS pac[:limitation_points] unless pac[:limitation_points].empty?
end
#xml.GRDFR
if no8 and !no8.empty? and
no8.to_s =~ /(\d{5})(\d{3})/
xml.COOL 1 if @fridge.include?($1.to_s)
end
xml.COOL 1 if ppac && /Blutprodukte|impfstoffe/.match(ppac[:list_code])
#xml.TEMP
if ean
flag = (ppac && !ppac[:drug_index].empty?) ? true : false
Expand Down Expand Up @@ -1260,8 +1256,7 @@ def build_dat
else
'3'
end
row << "%#{DAT_LEN[:CLAG]}s" % if ((no8 && no8.to_s =~ /(\d{5})(\d{3})/) and
@fridge.include?($1.to_s))
row << "%#{DAT_LEN[:CLAG]}s" % if ppac && /Blutproduct|impfstoffe/.match(ppac[:list_code]) # COOL
'1'
else
'0'
Expand Down
11 changes: 4 additions & 7 deletions lib/oddb2xml/cli.rb
Expand Up @@ -31,8 +31,7 @@ def initialize(args)
@migel = {} # [addition] additional Non Pharma products from files repo
@actions = [] # [addition] interactions from epha
@orphan = [] # [addition] Orphaned drugs from Swissmedic xls
@fridge = [] # [addition] ReFridge drugs from Swissmedic xls
# addres
# addresses
@companies = [] # betrieb
@people = [] # medizinalperson
@_message = false
Expand All @@ -52,9 +51,7 @@ def run
if @options[:fi]
threads << download(:fachinfo) # swissmedic-info
end
[:orphan, :fridge].each do |type|
threads << download(type) # swissmedic
end
threads << download(:orphan) # swissmedic
threads << download(:interaction) # epha
end
if @options[:nonpharma]
Expand Down Expand Up @@ -116,7 +113,7 @@ def build
builder.infos = @infos
builder.packs = @packs
# additional sources
%w[actions orphan fridge migel infos_zur_rose].each do |addition|
%w[actions orphan migel infos_zur_rose].each do |addition|
builder.send("#{addition}=".intern, self.instance_variable_get("@#{addition}"))
end
end
Expand Down Expand Up @@ -179,7 +176,7 @@ def download(what, type=nil)
@infos
end
end
when :orphan, :fridge
when :orphan
var = what.to_s
begin # instead of Thread.new do
downloader = SwissmedicDownloader.new(what)
Expand Down
3 changes: 0 additions & 3 deletions lib/oddb2xml/downloader.rb
Expand Up @@ -262,9 +262,6 @@ def initialize(type=:orphan, options = {})
when :orphan
action = "arzneimittel/00156/00221/00222/00223/00224/00227/00228/index.html?lang=de"
@xpath = "//div[@id='sprungmarke10_3']//a[@title='Humanarzneimittel']"
when :fridge
action = "arzneimittel/00156/00221/00222/00235/index.html?lang=de"
@xpath = "//div[@id='sprungmarke10_2']//a[@title='Excel-Version']"
when :package
action = "arzneimittel/00156/00221/00222/00230/index.html?lang=de"
@xpath = "//div[@id='sprungmarke10_7']//a[@title='Excel-Version Zugelassene Verpackungen*']"
Expand Down
13 changes: 1 addition & 12 deletions lib/oddb2xml/extractor.rb
Expand Up @@ -214,18 +214,6 @@ def to_arry
data << sprintf("%05d", number)
end
end
when :fridge
row_explanation = 9
col_zulassung = 0
col_cool = 12
explanation = @sheet[row_explanation]
raise "Could not find Zulassungsnummer in column #{col_zulassung} of #{@filename}" unless /Zul.*Nr/.match(explanation[col_zulassung].value)
raise "Could not find Kühlkette in column #{col_cool}" unless /Kühlkette/.match(explanation[col_cool].value)
@sheet.each do |row|
if row[col_zulassung] and number = row[col_zulassung].value and row[col_cool] and row[col_cool].value.to_s.downcase == 'x'
data << sprintf("%05d", number)
end
end
end
cleanup_file
# puts "found #{data.uniq.size} entities for type #{@type}"
Expand Down Expand Up @@ -492,6 +480,7 @@ def to_hash
data[ean13] = {
:line => line.chomp,
:ean => ean13,
:clag => line[73],
:vat => line[96],
:description => line[10..59].sub(/\s+$/, ''),
:quantity => '',
Expand Down
Binary file removed spec/data/swissmedic_fridge.xlsx
Binary file not shown.
18 changes: 0 additions & 18 deletions spec/downloader_spec.rb
Expand Up @@ -264,24 +264,6 @@ def unzip_files(zipfile_name, directory=Dir.pwd)
end
end
end
context 'fridge' do
before(:each) do
VCR.eject_cassette
VCR.insert_cassette('oddb2xml', :tag => :swissmedic, :exclusive => false)
common_before
@downloader = Oddb2xml::SwissmedicDownloader.new(:fridge)
end
after(:each) do common_after end
context 'download_by for fridge xls' do
let(:bin) {
@downloader.download
}
it 'should return valid Binary-String' do
expect(bin).to be_a String
expect(bin.bytes).not_to be nil
end
end
end
context 'package' do
before(:each) do
VCR.eject_cassette
Expand Down
9 changes: 0 additions & 9 deletions spec/extractor_spec.rb
Expand Up @@ -216,15 +216,6 @@ def get_pack_by_ean13(ean13)
end
end

context 'can parse swissmedic_fridge.xlsx' do
it {
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
@packs = Oddb2xml::SwissmedicExtractor.new(@filename, :fridge).to_arry
expect(@packs.size).to eq 16
expect(@packs[0]).to eq("58618")
expect(@packs[1]).to eq("00696")
}
end
context 'can parse swissmedic_orphans.xls' do
it {
@filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
Expand Down
167 changes: 0 additions & 167 deletions spec/fixtures/vcr_cassettes/oddb2xml.json

Large diffs are not rendered by default.

0 comments on commit c95ecce

Please sign in to comment.