Skip to content

Commit 4d84280

Browse files
committed
Enqueue PatientNHSNumberLookupWithPendingChangesJob
At the same time as looking up the NHS number we should look up the NHS number on any pending changes to highlight this if the NHS number should be different.
1 parent a6ef49b commit 4d84280

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

app/lib/update_patients_from_pds.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ def call
1515
else
1616
PatientUpdateFromPDSJob.set(queue:).perform_later(patient)
1717
end
18+
19+
if patient.pending_changes.present?
20+
PatientNHSNumberLookupWithPendingChangesJob.set(queue:).perform_later(
21+
patient
22+
)
23+
end
1824
end
1925
end
2026

spec/lib/update_patients_from_pds_spec.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@
99
after { Settings.reload! }
1010

1111
before do
12-
create_list(:patient, 2)
13-
create_list(:patient, 2, nhs_number: nil)
12+
create_list(:patient, 2, pending_changes: { given_name: "New given name" })
13+
create_list(
14+
:patient,
15+
2,
16+
nhs_number: nil,
17+
pending_changes: {
18+
given_name: "New given name"
19+
}
20+
)
1421
end
1522

1623
context "when disabled" do
@@ -25,13 +32,19 @@
2532
expect { call }.to have_enqueued_job(PatientNHSNumberLookupJob)
2633
.on_queue(:pds)
2734
.exactly(2)
28-
.times
35+
.times.and have_enqueued_job(PatientNHSNumberLookupWithPendingChangesJob)
36+
.on_queue(:pds)
37+
.exactly(4)
38+
.times
2939
end
3040

3141
it "queues a job for each patient with an NHS number" do
3242
expect { call }.to have_enqueued_job(PatientUpdateFromPDSJob)
3343
.on_queue(:pds)
3444
.exactly(2)
35-
.times
45+
.times.and have_enqueued_job(PatientNHSNumberLookupWithPendingChangesJob)
46+
.on_queue(:pds)
47+
.exactly(4)
48+
.times
3649
end
3750
end

0 commit comments

Comments
 (0)