Class: ODDB::State::Admin::AssignDeprivedSequence

Inherits:
Global show all
Defined in:
src/state/admin/root.rb,
src/state/admin/assign_deprived_sequence.rb

Direct Known Subclasses

AssignPatinfo

Defined Under Namespace

Classes: DeprivedSequenceFacade

Constant Summary

VIEW =
View::Admin::AssignDeprivedSequence

Constants inherited from Global

HOME_STATE, ZONE

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 Method Summary (collapse)

Methods inherited from Global

#zone_navigation

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 LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Method Details

- (Object) _patinfo_deprived_sequences



112
113
114
115
116
117
118
119
# File 'src/state/admin/assign_deprived_sequence.rb', line 112

def _patinfo_deprived_sequences
  if(respond_to?(:patinfo_deprived_sequences) \
    && @previous.direct_event == :patinfo_deprived_sequences)
    patinfo_deprived_sequences
  else
    @previous
  end
end

- (Object) assign_deprived_sequence



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'src/state/admin/assign_deprived_sequence.rb', line 51

def assign_deprived_sequence
  if(allowed?(@model.sequence) && !@session.error? \
    && (pointer = @session.user_input(:patinfo_pointer)))
    values = {:pdf_patinfo => nil, :patinfo => nil}
    if(pointer.last_step == [:pdf_patinfo])
      values.store(:pdf_patinfo, @session.resolve(pointer))
    else
      values.store(:patinfo, pointer)
    end
    @session.app.update(@model.pointer, values, unique_email)
    _patinfo_deprived_sequences
  else
    err = create_error(:e_no_sequence_selected, :pointers, nil)
    @errors.store(:pointers, err)
    self
  end
end

- (Object) init



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'src/state/admin/assign_deprived_sequence.rb', line 38

def init
  super
  @model = DeprivedSequenceFacade.new(@model)
  if((match = /^[\w\d]+/u.match(@model.name_base)) \
    && match[0].size > 3)
    sequences = named_sequences(match[0])
    if sequences.empty? || sequences.size > 15
      @warnings.clear
      sequences = @model.sequence.registration.sequences.values
    end
    @model.sequences = sequences
  end
end

- (Object) named_sequences(name)



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'src/state/admin/assign_deprived_sequence.rb', line 68

def named_sequences(name)
  if(name.size < 3)
    add_warning(:w_name_to_short,:name, name)
    []
  else
    seqs = @session.app.search_sequences(name.downcase)
    seqs = seqs.select { |seq|
      allowed?(seq)
    }
    if(seqs.size > 50)
      add_warning(:w_too_many_sequences, :name, nil)
      seqs[0,50]
    else
      seqs
    end
  end
end

- (Object) preview



104
105
106
107
108
109
110
111
# File 'src/state/admin/assign_deprived_sequence.rb', line 104

def preview 
  if(lang = @session.user_input(:language_select))
    doc = @model.languages[lang]
    State::Admin::PatinfoPreview.new(@session, doc)
  else
    self
  end
end

- (Object) search_sequences



85
86
87
88
89
90
91
92
93
94
# File 'src/state/admin/assign_deprived_sequence.rb', line 85

def search_sequences
  name = @session.user_input(:search_query)
  if(name.is_a? String)
    @model.sequences = named_sequences(name)
  else
    err = create_error(:e_name_to_short, :name, name)
    @errors.store(name, err)
  end
  self
end

- (Object) shadow



95
96
97
98
99
100
# File 'src/state/admin/assign_deprived_sequence.rb', line 95

def shadow
  if(allowed?(:patinfo_shadow))
    @session.app.update(@model.pointer, {:patinfo_shadow => true}, unique_email)
    _patinfo_deprived_sequences
  end
end

- (Object) symbol



101
102
103
# File 'src/state/admin/assign_deprived_sequence.rb', line 101

def symbol
  :name_base
end