class Team
Schema Information
Table name: teams
id :bigint not null, primary key careplus_namespace :string careplus_password :string careplus_staff_code :string careplus_staff_type :string careplus_username :string careplus_venue_code :string days_before_consent_reminders :integer default(7), not null days_before_consent_requests :integer default(21), not null email :string name :text not null national_reporting_cut_off_date :date phone :string phone_instructions :string privacy_notice_url :string privacy_policy_url :string programme_types :enum not null, is an Array type :integer not null workgroup :string not null created_at :datetime not null updated_at :datetime not null organisation_id :bigint not null reply_to_id :uuid
Indexes
index_teams_on_name (name) UNIQUE index_teams_on_organisation_id (organisation_id) index_teams_on_programme_types (programme_types) USING gin index_teams_on_workgroup (workgroup) UNIQUE
Foreign Keys
fk_rails_... (organisation_id => organisations.id)
Constants
- NATIONAL_REPORTING_YEAR_GROUPS
- NIVS_SWITCH_OFF_DELAY_DAYS
-
The number of days after the national reporting cut-off date when users will lose access to NIVS
Public Instance Methods
Source
# File app/models/team.rb, line 170 def careplus_enabled? careplus_staff_code.present? && careplus_staff_type.present? && careplus_venue_code.present? end
Source
# File app/models/team.rb, line 175 def eligible_for_automated_careplus_reports? careplus_enabled? && careplus_username.present? && careplus_password.present? && careplus_namespace.present? end
Source
# File app/models/team.rb, line 136 def generic_clinic @generic_clinic ||= generic_clinics.preload(:team_locations).sole end
Source
# File app/models/team.rb, line 140 def home_educated_school @home_educated_school ||= generic_schools .includes(:team_locations) .where(urn: Location::URN_HOME_EDUCATED) .sole end
Source
# File app/models/team.rb, line 166 def is_sais_team? has_point_of_care_access? || has_national_reporting_access? end
Source
# File app/models/team.rb, line 134 def to_param = workgroup def generic_clinic @generic_clinic ||= generic_clinics.preload(:team_locations).sole end def home_educated_school @home_educated_school ||= generic_schools .includes(:team_locations) .where(urn: Location::URN_HOME_EDUCATED) .sole end def unknown_school @unknown_school ||= generic_schools .includes(:team_locations) .where(urn: Location::URN_UNKNOWN) .sole end def year_groups(academic_year: nil) return NATIONAL_REPORTING_YEAR_GROUPS if has_national_reporting_access? academic_year ||= AcademicYear.pending location_programme_year_groups .joins(:location_year_group) .where(location_year_group: { academic_year: }) .pluck_year_groups end def is_sais_team? has_point_of_care_access? || has_national_reporting_access? end def careplus_enabled? careplus_staff_code.present? && careplus_staff_type.present? && careplus_venue_code.present? end def eligible_for_automated_careplus_reports? careplus_enabled? && careplus_username.present? && careplus_password.present? && careplus_namespace.present? end end
Source
# File app/models/team.rb, line 148 def unknown_school @unknown_school ||= generic_schools .includes(:team_locations) .where(urn: Location::URN_UNKNOWN) .sole end
Source
# File app/models/team.rb, line 156 def year_groups(academic_year: nil) return NATIONAL_REPORTING_YEAR_GROUPS if has_national_reporting_access? academic_year ||= AcademicYear.pending location_programme_year_groups .joins(:location_year_group) .where(location_year_group: { academic_year: }) .pluck_year_groups end