Module: ODDB::State::Admin::Root

Includes:
User
Included in:
StubResolvedRootState, TestRootState::TestState, StubResolvedRootState
Defined in:
src/state/admin/root.rb,
test/test_state/admin/root.rb,
src/state/global_predefine.rb,
test/test_state/admin/login.rb

Constant Summary

EVENT_MAP =
{
  :users            =>  State::Admin::Entities, 
}
RESOLVE_STATES =
{
  [:resolve] => StubResolvedRootState,
}

Constants included from User

RESOLVE_STATES

Instance Method Summary (collapse)

Methods included from User

#resolve_state, #user_navigation

Instance Method Details

- (Object) addresses



87
88
89
90
# File 'src/state/admin/root.rb', line 87

def addresses
  model = @session.app.address_suggestions.values
  State::Admin::Addresses.new(@session, model)
end

- (Object) commercial_forms



91
92
93
94
# File 'src/state/admin/root.rb', line 91

def commercial_forms
  State::Admin::CommercialForms.new(@session, 
                                    ODDB::CommercialForm.odba_extent)
end

- (Object) effective_substances



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

def effective_substances
  model = @session.substances.select { |sub| 
    sub.is_effective_form?
  }
  State::Substances::EffectiveSubstances.new(@session, model)
end

- (Object) fipi_overview



101
102
103
104
105
106
# File 'src/state/admin/root.rb', line 101

def fipi_overview
  if((pointer = @session.user_input(:pointer)) \
    && (company = pointer.resolve(@session.app)))
    State::Companies::FiPiOverview.new(@session, company)
  end
end

- (Object) galenic_groups



107
108
109
110
# File 'src/state/admin/root.rb', line 107

def galenic_groups
  model = @session.app.galenic_groups.values
  State::Admin::GalenicGroups.new(@session, model)
end

- (Object) indications



111
112
113
114
# File 'src/state/admin/root.rb', line 111

def indications
  model = @session.app.indications
  State::Admin::Indications.new(@session, model)
end

- (Boolean) limited?

Returns:

  • (Boolean)


115
116
117
# File 'src/state/admin/root.rb', line 115

def limited?
  false
end

- (Object) new_commercial_form



118
119
120
121
122
123
# File 'src/state/admin/root.rb', line 118

def new_commercial_form
  pointer = Persistence::Pointer.new(:commercial_form)
  cform = Persistence::CreateItem.new(pointer)
  cform.carry :packages, []
  State::Admin::CommercialForm.new(@session, cform)
end

- (Object) new_company



124
125
126
127
# File 'src/state/admin/root.rb', line 124

def new_company
  pointer = Persistence::Pointer.new(:company)
  State::Companies::RootCompany.new(@session, Persistence::CreateItem.new(pointer))
end

- (Object) new_fachinfo



128
129
130
131
132
133
# File 'src/state/admin/root.rb', line 128

def new_fachinfo
  if((pointer = @session.user_input(:pointer)) \
      && (registration = pointer.resolve(@session)))
    _new_fachinfo(registration)
  end
end

- (Object) new_galenic_form



134
135
136
137
138
139
140
141
# File 'src/state/admin/root.rb', line 134

def new_galenic_form
  pointer = @session.user_input(:pointer)
  model = pointer.resolve(@session.app)
  item = Persistence::CreateItem.new(pointer + [:galenic_form])
  item.carry(:galenic_group, model)
  item.carry(:sequences, [])
  State::Admin::GalenicForm.new(@session, item)
end

- (Object) new_galenic_group



142
143
144
145
# File 'src/state/admin/root.rb', line 142

def new_galenic_group
  pointer = Persistence::Pointer.new(:galenic_group)
  State::Admin::GalenicGroup.new(@session, Persistence::CreateItem.new(pointer))
end

- (Object) new_indication



146
147
148
149
150
# File 'src/state/admin/root.rb', line 146

def new_indication
  pointer = Persistence::Pointer.new([:indication])
  item = Persistence::CreateItem.new(pointer)
  State::Admin::Indication.new(@session, item)
end

- (Object) new_registration



151
152
153
154
155
156
157
158
159
160
161
# File 'src/state/admin/root.rb', line 151

def new_registration
  pointer = Persistence::Pointer.new(:registration)
  item = Persistence::CreateItem.new(pointer)
  item.carry :sequences, {}
  item.carry :packages, []
  if(@model.is_a?(Company))
    item.carry(:company, @model)
    item.carry(:company_name, @model.name)
  end
  State::Admin::Registration.new(@session, item)
end

- (Object) new_substance



162
163
164
165
166
167
168
# File 'src/state/admin/root.rb', line 162

def new_substance
  pointer = Persistence::Pointer.new(:substance)
  item = Persistence::CreateItem.new(pointer)
  item.carry(:synonyms, [])
  item.carry(:connection_keys, [])
  State::Substances::Substance.new(@session, item)
end

- (Object) new_user



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'src/state/admin/root.rb', line 169

def new_user
  pointer = Persistence::Pointer.new(:user)
  user = Persistence::CreateItem.new(pointer)
  case @model.odba_instance
  when ODDB::Company # and not: ODDB::State::Companies::Company
    aff = OpenStruct.new
    aff.name = 'CompanyUser'
    user.carry(:affiliations, [aff])
    user.carry(:association, @model.pointer.to_yus_privilege)
    user.carry(:name, @model.contact_email)
    if(fullname = @model.contact)
      first, last = fullname.split(' ', 2)
      user.carry(:name_first, first)
      user.carry(:name_last, last)
    end
  else
    user.carry(:affiliations, [])
  end
  State::Admin::Entity.new(@session, user)
end

- (Object) orphaned_fachinfos



189
190
191
192
# File 'src/state/admin/root.rb', line 189

def  orphaned_fachinfos
  model = @session.app.orphaned_fachinfos.values
  State::Admin::OrphanedFachinfos.new(@session, model)
end

- (Object) orphaned_patinfos



193
194
195
196
# File 'src/state/admin/root.rb', line 193

def orphaned_patinfos
  model = @session.app.orphaned_patinfos.values
  State::Admin::OrphanedPatinfos.new(@session, model)
end

- (Object) patinfo_deprived_sequences



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'src/state/admin/root.rb', line 197

def patinfo_deprived_sequences 
  model = []
  @session.app.registrations.each_value { |reg|
    sequences = reg.sequences.values
    candidates = sequences.select { |seq|
      !seq.patinfo_shadow \
        && seq.patinfo.nil? \
        && seq.active? \
        && !seq.packages.empty? \
        && (gf = seq.galenic_form) \
        && (gg = gf.galenic_group) \
        && !/^In[jf]/u.match(gg.de)
    }
    #if (candidates.size < sequences.size)
      model += candidates
    #end
  }
  State::Admin::PatinfoDeprivedSequences.new(@session, model)
end

- (Object) patinfo_stats



216
217
218
# File 'src/state/admin/root.rb', line 216

def patinfo_stats
  State::Admin::PatinfoStats.new(@session,[])
end


219
220
221
222
223
# File 'src/state/admin/root.rb', line 219

def 
  pointer = Persistence::Pointer.new([:sponsor, @session.flavor])
  model = pointer.resolve(@session.app) || Persistence::CreateItem.new(pointer)
  State::Admin::.new(@session, model)
end

- (Object) substances



224
225
226
227
# File 'src/state/admin/root.rb', line 224

def substances
  model = @session.substances
  State::Substances::Substances.new(@session, model)
end

- (Object) user



228
229
230
231
232
# File 'src/state/admin/root.rb', line 228

def user
  name = @session.user_input(:name)
  user = @session.user.find_entity(name)
  State::Admin::Entity.new(@session, user)
end

- (Object) zones



233
234
235
# File 'src/state/admin/root.rb', line 233

def zones
  [:admin, :analysis, :doctors, :interactions, :drugs, :migel, :user, :hospitals, :substances, :companies]
end