Class: Oddb2xml::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb2xml/cli.rb

Constant Summary collapse

SUBJECTS =
%w[product article]
ADDITIONS =
%w[substance limitation interaction code]
OPTIONALS =
%w[fi fi_product]
LANGUAGES =

EN does not exist

%w[DE FR]

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Cli

Returns a new instance of Cli.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/oddb2xml/cli.rb', line 20

def initialize(args)
  @options = args
  Oddb2xml.save_options(@options)
  @mutex = Mutex.new
  # product
  @items = {} # Items from Preparations.xml in BAG
  @index = {} # Base index from swissINDEX
  @flags = {} # narcotics flag files repo
  @lppvs = {} # lppv.txt from files repo
  @infos = {} # [option] FI from SwissmedicInfo
  @packs = {} # [option] Packungen from Swissmedic for dat
  @infos_zur_rose  = {} # [addition] infos_zur_rose and other infos from zurrose transfer.txt
  @migel   = {} # [addition] additional Non Pharma products from files repo
  @actions = [] # [addition] interactions from epha
  @orphans = [] # [addition] Orphaned drugs from Swissmedic xls
  @fridges = [] # [addition] ReFridge drugs from Swissmedic xls
  # addres
  @companies = [] # betrieb
  @people    = [] # medizinalperson
  LANGUAGES.each do |lang|
    @index[lang] = {}
  end
  @_message = false
end

Instance Method Details

#runObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/oddb2xml/cli.rb', line 44

def run
  threads = []
  if @options[:calc] and not @options[:extended]
    threads << download(:package) # swissmedic
  elsif @options[:address]
    [:company, :person].each do |type|
      threads << download(type) # medregbm.admin
    end
  else
    if @options[:format] != :dat
      if @options[:fi]
        threads << download(:fachinfo) # swissmedic-info
      end
      [:orphan, :fridge].each do |type|
        threads << download(type) # swissmedic
      end
      threads << download(:interaction) # epha
    end
    if @options[:nonpharma]
      threads << download(:migel) # oddb2xml_files
    end
    threads << download(:zurrose)
    threads << download(:package) # swissmedic
    threads << download(:bm_update) # oddb2xml_files
    threads << download(:lppv) # oddb2xml_files
    threads << download(:bag) # bag.e-mediat
    LANGUAGES.each do |lang|
      types.each do |type|
        threads << download(:index, type, lang) # swissindex
      end
    end
  end
  begin
    threads.map(&:join)
  rescue SystemExit
    @mutex.synchronize do
      if @_message
        puts "(Aborted)"
        puts "Please install SSLv3 CA certificates on your machine."
        puts "You can check with `ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'`."
        puts "See README."
      end
    end
    exit
  end
  build
  compress if @options[:compress_ext]
  report
end