Class: ODDB::State::Interactions::Basket

Inherits:
Global show all
Defined in:
src/state/interactions/basket.rb,
test/test_state/interactions/basket.rb

Direct Known Subclasses

EmptyBasket

Defined Under Namespace

Classes: Check, ObservedInteraction

Constant Summary

VIEW =
View::Interactions::Basket
DIRECT_EVENT =
:interaction_basket
LIMITED =
false

Constants inherited from Global

HOME_STATE, ZONE, ZONE_NAVIGATION

Constants inherited from Global

DIRECT_EVENT, GLOBAL_MAP, HOME_STATE, LIMITED, PRINT_STATES, READONLY_STATES, RESOLVE_STATES, REVERSE_MAP, VIEW, ZONE_NAVIGATION

Constants included from UmlautSort

FILTER_PAIRS

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Global

#limit_state

Methods inherited from Global

#_search_drugs, #_search_drugs_state, #_trigger, #add_to_interaction_basket, #allowed?, #atc_chooser, #checkout, #clear_interaction_basket, #creditable?, #direct_request_path, #doctorlist, #download, #export_csv, #extend, #fachinfo, #feedbacks, #help_navigation, #home_navigation, #home_state, #hospitallist, #interaction_basket, #limit_state, #limited?, #logout, #navigation, #notify, #password_reset, #paypal_return, #powerlink, #print, #proceed_download, #proceed_poweruser, #resolve, #resolve_state, #rss, #search, #show, #snapback_event, #sort, #sponsorlink, #suggest_address, #switch, #unique_email, #user_input, #user_navigation, #ywesee_contact, #zone_navigation, #zones

Methods included from Admin::LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Attribute Details

- (Object) model (readonly)

Returns the value of attribute model



15
16
17
# File 'test/test_state/interactions/basket.rb', line 15

def model
  @model
end

Instance Method Details

- (Object) _observed_interactions(sub, other)



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'src/state/interactions/basket.rb', line 97

def _observed_interactions(sub, other)
  keys = (other.names - sub.names).join('|').gsub(' ', '[\s-]')
  return [] if(keys.empty?)
  ptrn = /(^|[\s\(])((#{Regexp.escape(keys)})[esn]{0,2})([\s,.\)-]|$)/iu
  found = []
  match = nil
  sub.sequences.each { |seq|
    if(seq.substances.size == 1 && (fi = seq.fachinfo) \
       && (doc = fi.send(@session.language)) && (chapter = doc.interactions) \
       && (match = chapter.match(ptrn)))
      found.push(ObservedInteraction.new(other, fi, ptrn.source, match[2]))
    end
  }
  found.uniq
end

- (Object) _observed_interactions_chemical(sub, other)



83
84
85
86
87
88
89
# File 'src/state/interactions/basket.rb', line 83

def _observed_interactions_chemical(sub, other)
  values = _observed_interactions(sub, other)
  sub.chemical_forms.each { |chm|
    values += _observed_interactions_chemical(chm, other)
  }
  values
end

- (Object) _observed_interactions_effective(sub, other)



90
91
92
93
94
95
96
# File 'src/state/interactions/basket.rb', line 90

def _observed_interactions_effective(sub, other)
  values = _observed_interactions(sub, other)
  if(sub.has_effective_form? && !sub.is_effective_form?)
    values += _observed_interactions_effective(sub.effective_form, other)
  end
  values
end

- (Object) calculate_interactions



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'src/state/interactions/basket.rb', line 62

def calculate_interactions
  subs = @session.interaction_basket
  @model = subs.collect { |sub|
    check = Check.new(sub)
    (subs - [sub]).each { |other|
      sub.interactions_with(other).each { |interaction|
        check.add_interaction(interaction)
      }
      observed_interactions(sub, other).each { |observed|
        check.add_interaction(observed)
      }
    }
    check
  }
end

- (Object) delete



59
60
61
# File 'src/state/interactions/basket.rb', line 59

def delete
  init
end

- (Object) init



55
56
57
58
# File 'src/state/interactions/basket.rb', line 55

def init
  @model = [] 
  calculate_interactions
end

- (Object) observed_interactions(sub, other)



77
78
79
80
81
82
# File 'src/state/interactions/basket.rb', line 77

def observed_interactions(sub, other)
  values = _observed_interactions_chemical(sub, other)
  values += _observed_interactions_effective(sub, other)
  values.uniq!
  values
end