Skip to content

Commit 80cb3e4

Browse files
committed
Add sync_national_reporting_to_imms_api feature ...
... flag We're planning to dual-run the national reporting upload with teams, and during that period we'll want to ensure we don't actually send the vaccination records to the imms api. Jira-Issue: MAV-2733
1 parent 018e3e2 commit 80cb3e4

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

app/models/concerns/vaccination_record_sync_to_nhs_immunisations_api_concern.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ module VaccinationRecordSyncToNHSImmunisationsAPIConcern
77
scope :with_correct_source_for_nhs_immunisations_api,
88
-> do
99
includes(:patient).then do
10-
it.sourced_from_service.or(it.sourced_from_bulk_upload)
10+
if Flipper.enabled?(:sync_national_reporting_to_imms_api)
11+
it.sourced_from_service.or(it.sourced_from_bulk_upload)
12+
else
13+
it.sourced_from_service
14+
end
1115
end
1216
end
1317

@@ -34,7 +38,11 @@ module VaccinationRecordSyncToNHSImmunisationsAPIConcern
3438
end
3539

3640
def correct_source_for_nhs_immunisations_api?
37-
(sourced_from_service? || sourced_from_bulk_upload?)
41+
sourced_from_service? ||
42+
(
43+
Flipper.enabled?(:sync_national_reporting_to_imms_api) &&
44+
sourced_from_bulk_upload?
45+
)
3846
end
3947

4048
def sync_status

config/feature_flags.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ reporting_api: Enables the Commissioner reporting component to authenticate to M
4343
Authorization Code Flow (https://datatracker.ietf.org/doc/html/rfc6749#section-4.1), and retrieve
4444
statistics from /api/reporting/
4545

46+
sync_national_reporting_to_imms_api: |
47+
Sync immunisations records uploaded as part of national reporting to the NHS
48+
Immunisations API.
49+
4650
testing_api: Basic API useful for automated testing.
4751

4852
mmrv: Adds support for MMRV vaccinations

spec/features/import_vaccination_records_bulk_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def and_sending_to_nhs_immunisations_api_is_enabled
8686
Flipper.enable(:imms_api_integration)
8787
Flipper.enable(:imms_api_sync_job, Programme.flu)
8888
Flipper.enable(:imms_api_sync_job, Programme.hpv)
89+
Flipper.enable(:sync_national_reporting_to_imms_api)
8990

9091
@stubbed_post_request =
9192
stub_immunisations_api_post(Random.uuid, Random.uuid)

spec/models/concerns/vaccination_record_sync_to_nhs_immunisations_api_concern_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
describe "with_correct_source_for_nhs_immunisations_api scope" do
7575
subject { VaccinationRecord.with_correct_source_for_nhs_immunisations_api }
7676

77+
before { Flipper.enable(:sync_national_reporting_to_imms_api) }
78+
7779
let!(:vaccination_record) do
7880
create(:vaccination_record, programme:, session:)
7981
end
@@ -90,6 +92,16 @@
9092
end
9193

9294
it { should include(vaccination_record) }
95+
96+
context "with the sync_national_reporting_to_imms_api feature flag disabled" do
97+
before { Flipper.disable(:sync_national_reporting_to_imms_api) }
98+
99+
let!(:vaccination_record) do
100+
create(:vaccination_record, :sourced_from_bulk_upload, programme:)
101+
end
102+
103+
it { should_not include(vaccination_record) }
104+
end
93105
end
94106

95107
context "when vaccination record was part of a historical upload" do
@@ -112,6 +124,8 @@
112124
describe "#correct_source_to_nhs_immunisations_api?" do
113125
subject { vaccination_record.correct_source_for_nhs_immunisations_api? }
114126

127+
before { Flipper.enable(:sync_national_reporting_to_imms_api) }
128+
115129
context "when the vaccination record is eligible to sync" do
116130
it { should be true }
117131
end
@@ -139,6 +153,12 @@
139153
end
140154

141155
it { should be true }
156+
157+
context "with the sync_national_reporting_to_imms_api feature flag disabled" do
158+
before { Flipper.disable(:sync_national_reporting_to_imms_api) }
159+
160+
it { should be false }
161+
end
142162
end
143163

144164
context "a vaccination record created because patient is already vaccinated" do

0 commit comments

Comments
 (0)