Class: ODDB::State::Drugs::RecentRegs

Inherits:
Global show all
Includes:
ResultStateSort
Defined in:
src/state/drugs/recentregs.rb

Defined Under Namespace

Classes: PackageMonth

Constant Summary

VIEW =
View::Drugs::RecentRegs
DIRECT_EVENT =
:recent_registrations
LIMITED =
true

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 included from ResultStateSort

#sort

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) date (readonly)

Returns the value of attribute date



30
31
32
# File 'src/state/drugs/recentregs.rb', line 30

def date
  @date
end

- (Object) months (readonly)

Returns the value of attribute months



30
31
32
# File 'src/state/drugs/recentregs.rb', line 30

def months
  @months
end

- (Object) years (readonly)

Returns the value of attribute years



30
31
32
# File 'src/state/drugs/recentregs.rb', line 30

def years
  @years
end

Instance Method Details

- (Object) create_package_month(date)



58
59
60
# File 'src/state/drugs/recentregs.rb', line 58

def create_package_month(date)
  PackageMonth.new(date, regs_by_month(date), @session)
end

- (Object) init



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'src/state/drugs/recentregs.rb', line 34

def init
  @model = nil
  journals = @session.app.log_group(:swissmedic_journal)
  later = @session.app.log_group(:swissmedic)
  year = nil
  if(journals || later)
    if((month = @session.user_input(:month)) \
       && (year = @session.user_input(:year)))
      year = year.to_i
      @date = Date.new(year, month.to_i)
      @model = [
        create_package_month(@date)
      ]
    elsif(@date = later.newest_date || journals.newest_date)
      @model = [ create_package_month(@date) ]
      year = @date.year
    end
    @model.delete_if { |month| 
      month.package_count == 0
    }
    @years = (journals.years + later.years).uniq
    @months = year ? (journals.months(year) + later.months(year)).uniq : []
  end
end

- (Object) regs_by_month(month)



61
62
63
64
# File 'src/state/drugs/recentregs.rb', line 61

def regs_by_month(month)
  ODBA.cache.retrieve_from_index('date_index_registration',
    month.strftime('%Y-%m'))
end