Module: ODDB::View::Admin::SwissmedicSource

Included in:
PackageComposite, RegistrationComposite, RootActiveAgentComposite, SequenceComposite, Drugs::PackageComposite
Defined in:
src/view/admin/swissmedic_source.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) format_source(keys, source, str = '')



8
9
10
11
12
13
14
15
16
17
18
# File 'src/view/admin/swissmedic_source.rb', line 8

def format_source(keys, source, str='')
  keys.each { |key| 
    value = source[key]
    case key
    when :import_date, :registration_date, :expiry_date
      value = value && value.strftime('%d.%m.%Y')
    end
    str << sprintf("%-32s: %s\n", @lookandfeel.lookup(key){ key.to_s }, value)
  }
  str
end

- (Object) package_source(package, keys = nil)



49
50
51
52
53
54
55
56
57
58
59
# File 'src/view/admin/swissmedic_source.rb', line 49

def package_source(package, keys = nil)
  if(source = package.swissmedic_source)
    keys ||= [ :import_date, :iksnr, :seqnr, :name_base, :company,
               :product_group, :index_therapeuticus, :production_science,
               :registration_date, :expiry_date, :ikscd, :size, :unit,
               :ikscat, :substances, :composition ]
    format_source(keys, source)
  else
    package.source.to_s
  end
end

- (Object) registration_source(registration)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'src/view/admin/swissmedic_source.rb', line 19

def registration_source(registration)
  if(sourced = registration.packages.find { |pac| pac.swissmedic_source })
    keys = [ :import_date, :iksnr, :company, :product_group,
             :index_therapeuticus, :production_science, :registration_date,
             :expiry_date ]
    seqkeys = [ :seqnr, :name_base, :substances, :composition ]
    source = format_source(keys, sourced.swissmedic_source)
    registration.sequences.sort.each { |seqnr, seq|
      source << "\n" << sequence_source(seq, seqkeys)
    }
    source
  else
    registration.source.to_s
  end
end

- (Object) sequence_source(sequence, keys = nil)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'src/view/admin/swissmedic_source.rb', line 34

def sequence_source(sequence, keys = nil)
  if(sourced = sequence.packages.values.find { |pac| pac.swissmedic_source })
    keys ||= [ :import_date, :iksnr, :seqnr, :name_base, :company,
               :product_group, :index_therapeuticus, :production_science,
               :registration_date, :expiry_date, :substances, :composition ]
    packeys = [ :ikscd, :size, :unit, :ikscat ]
    source = format_source(keys, sourced.swissmedic_source)
    sequence.packages.sort.each { |ikscd, pac| 
      source << "\n" << package_source(pac, packeys)
    }.compact
    source
  else
    sequence.source.to_s
  end
end