|
5 | 5 | # Table name: teams |
6 | 6 | # |
7 | 7 | # id :bigint not null, primary key |
| 8 | +# careplus_integration_enabled_at :datetime |
8 | 9 | # careplus_namespace :string |
9 | 10 | # careplus_password :string |
10 | 11 | # careplus_staff_code :string |
|
30 | 31 | # |
31 | 32 | # Indexes |
32 | 33 | # |
| 34 | +# index_teams_on_careplus_integration_enabled_at (careplus_integration_enabled_at) |
33 | 35 | # index_teams_on_name (name) UNIQUE |
34 | 36 | # index_teams_on_organisation_id (organisation_id) |
35 | 37 | # index_teams_on_programme_types (programme_types) USING gin |
@@ -99,8 +101,12 @@ class Team < ApplicationRecord |
99 | 101 | .where.not(careplus_username: nil) |
100 | 102 | .where.not(careplus_password: nil) |
101 | 103 | end |
| 104 | + scope :careplus_integration_enabled, |
| 105 | + -> { where.not(careplus_integration_enabled_at: nil) } |
102 | 106 | scope :eligible_for_automated_careplus_reports, |
103 | | - -> { careplus_enabled.has_careplus_credentials } |
| 107 | + -> do |
| 108 | + careplus_enabled.has_careplus_credentials.careplus_integration_enabled |
| 109 | + end |
104 | 110 |
|
105 | 111 | enum :type, |
106 | 112 | { point_of_care: 0, national_reporting: 1, support: 2 }, |
@@ -174,6 +180,7 @@ def careplus_enabled? |
174 | 180 |
|
175 | 181 | def eligible_for_automated_careplus_reports? |
176 | 182 | careplus_enabled? && careplus_username.present? && |
177 | | - careplus_password.present? && careplus_namespace.present? |
| 183 | + careplus_password.present? && careplus_namespace.present? && |
| 184 | + careplus_integration_enabled_at.present? |
178 | 185 | end |
179 | 186 | end |
0 commit comments