Skip to content

Commit d965a82

Browse files
authored
Merge pull request #6573 from NHSDigital/refactor-pds-feature-flags
Refactor PDS feature flags
2 parents 9494bf2 + fcb1be7 commit d965a82

33 files changed

Lines changed: 509 additions & 456 deletions

app/jobs/process_patient_changeset_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def perform(patient_changeset_id)
1919
if patient_changeset.import.changesets.pending.none?
2020
import = patient_changeset.import
2121

22-
if Flipper.enabled?(:import_search_pds)
22+
if Flipper.enabled?(:pds) && Flipper.enabled?(:pds_search_during_import)
2323
import.validate_pds_match_rate!
2424
return if import.low_pds_match_rate?
2525
end

app/lib/nhs/pds.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class InvalidSearchData < StandardError
3434

3535
class << self
3636
def get_patient(nhs_number)
37-
return unless Settings.pds.enabled
37+
return unless Flipper.enabled?(:pds)
38+
3839
NHS::API.connection.get(
3940
"personal-demographics/FHIR/R4/Patient/#{nhs_number}"
4041
)
@@ -55,7 +56,8 @@ def get_patient(nhs_number)
5556
end
5657

5758
def search_patients(attributes)
58-
return unless Settings.pds.enabled
59+
return unless Flipper.enabled?(:pds)
60+
5961
if (missing_attrs = (attributes.keys.map(&:to_s) - SEARCH_FIELDS)).any?
6062
raise "Unrecognised attributes: #{missing_attrs.join(", ")}"
6163
end

app/lib/update_patients_from_pds.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ def self.call(...) = new(...).call
2727
attr_reader :patients, :queue
2828

2929
def enqueue?
30-
@enqueue ||= Settings.pds.enqueue_bulk_updates
30+
Flipper.enabled?(:pds) && Flipper.enabled?(:pds_enqueue_bulk_updates)
3131
end
3232
end

app/models/patient_import.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def process_import!
4040
PatientChangeset.from_import_row(row:, import: self, row_number:)
4141
end
4242

43-
if Flipper.enabled?(:import_search_pds)
43+
if Flipper.enabled?(:pds) && Flipper.enabled?(:pds_search_during_import)
4444
process_no_postcode_changesets(self.changesets.without_postcode)
4545
if self.changesets.with_postcode.any?
4646
enqueue_pds_cascading_searches(self.changesets.with_postcode)
@@ -158,7 +158,7 @@ def process_no_postcode_changesets(changesets)
158158

159159
def enqueue_review_jobs(changesets)
160160
review_changesets =
161-
if Flipper.enabled?(:import_search_pds)
161+
if Flipper.enabled?(:pds) && Flipper.enabled?(:pds_search_during_import)
162162
changesets.with_postcode
163163
else
164164
changesets

config/feature_flags.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ import_choose_academic_year: >-
3939
import_concurrency_per_server: >-
4040
Controls whether to limit the concurrency of the import jobs to be global or to be per-server.
4141
42-
import_search_pds: Perform PDS lookups as part of the patient import processing.
43-
4442
ops_tools: Enable the operational support tools; timeline and graph.
4543

44+
pds: Main switch for PDS integration. Turning this off will disable all PDS-related features.
45+
46+
pds_enqueue_bulk_updates: >-
47+
Whether to enqueue jobs which updates a large number of patients with the data from PDS in bulk.
48+
49+
pds_search_during_import: Perform PDS lookups as part of the patient import processing.
50+
4651
sync_national_reporting_to_imms_api: >-
4752
Sync immunisations records uploaded as part of national reporting to the NHS Immunisations API.
4853

config/settings.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ immunisations_api:
4242
rate_limit_per_second: 20
4343

4444
pds:
45-
enabled: true
46-
enqueue_bulk_updates: true
4745
raise_unknown_gp_practice: true
4846
rate_limit_per_second: 50
4947

config/settings/development.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ nhs_api:
1818
disable_authentication: true
1919

2020
pds:
21-
enabled: false
22-
enqueue_bulk_updates: false
2321
rate_limit_per_second: 5
2422

2523
splunk:

config/settings/end_to_end.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ nhs_api:
1818
disable_authentication: true
1919

2020
pds:
21-
enabled: false
22-
enqueue_bulk_updates: false
2321
rate_limit_per_second: 5
2422

2523
splunk:

spec/features/cli_pds_get_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative "../../app/lib/mavis_cli"
44

5-
describe "mavis pds get" do
5+
describe "mavis pds get", :pds do
66
it "runs successfully" do
77
given_the_request_is_stubbed
88

spec/features/cli_pds_search_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_relative "../../app/lib/mavis_cli"
44

5-
describe "mavis pds search" do
5+
describe "mavis pds search", :pds do
66
it "runs successfully" do
77
given_the_request_is_stubbed
88

0 commit comments

Comments
 (0)