Skip to content

Commit ead5d7a

Browse files
authored
Merge pull request #4392 from nhsuk/pds-fuzzy-search-history
Remove redundant PDS fuzzy search with history
2 parents cdc4670 + 4ff4418 commit ead5d7a

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

app/jobs/process_patient_changesets_job.rb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def steps
7979
too_many_matches: :no_fuzzy_without_history
8080
},
8181
no_fuzzy_without_history: {
82-
no_matches: :fuzzy_without_history,
82+
no_matches: :fuzzy,
8383
one_match: :save_nhs_number_if_unique,
8484
too_many_matches: :give_up,
8585
format_query: ->(query) { query.merge(history: false) }
@@ -98,28 +98,21 @@ def steps
9898
format_query: ->(query) { query[:given_name][3..] = "*" }
9999
},
100100
no_fuzzy_with_wildcard_family_name: {
101-
no_matches: :fuzzy_without_history,
102-
one_match: :fuzzy_without_history,
103-
too_many_matches: :fuzzy_without_history,
104-
skip_step: :fuzzy_without_history,
101+
no_matches: :fuzzy,
102+
one_match: :fuzzy,
103+
too_many_matches: :fuzzy,
104+
skip_step: :fuzzy,
105105
format_query: ->(query) { query[:family_name][3..] = "*" }
106106
},
107-
fuzzy_without_history: {
108-
no_matches: :fuzzy_with_history,
109-
one_match: :save_nhs_number_if_unique,
110-
too_many_matches: :save_nhs_number_if_unique,
111-
format_query: ->(query) do
112-
query[:fuzzy] = true
113-
query[:history] = false
114-
end
115-
},
116-
fuzzy_with_history: {
107+
fuzzy: {
117108
no_matches: :give_up,
118109
one_match: :save_nhs_number_if_unique,
119110
too_many_matches: :save_nhs_number_if_unique,
120111
format_query: ->(query) do
121112
query[:fuzzy] = true
122-
query[:history] = true
113+
# For fuzzy searches, history is the default. We get an error if we
114+
# try to set it to true explicitly
115+
query[:history] = nil
123116
end
124117
}
125118
}

app/models/pds_search_result.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class PDSSearchResult < ApplicationRecord
3636
no_fuzzy_with_wildcard_postcode: 3,
3737
no_fuzzy_with_wildcard_given_name: 4,
3838
no_fuzzy_with_wildcard_family_name: 5,
39-
fuzzy_without_history: 6,
40-
fuzzy_with_history: 7
39+
fuzzy: 6
4140
},
4241
validate: true
4342

spec/features/import_child_pds_lookup_extravaganza_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,15 +797,14 @@ def then_maia_has_the_uploaded_nhs_number
797797

798798
def and_maia_has_multiple_pds_search_results
799799
maia = Patient.find_by(given_name: "Maia", family_name: "Smith")
800-
expect(maia.pds_search_results.count).to eq(6)
800+
expect(maia.pds_search_results.count).to eq(5)
801801
expect(maia.pds_search_results.pluck(:step)).to eq(
802802
%w[
803803
no_fuzzy_with_history
804804
no_fuzzy_with_wildcard_postcode
805805
no_fuzzy_with_wildcard_given_name
806806
no_fuzzy_with_wildcard_family_name
807-
fuzzy_without_history
808-
fuzzy_with_history
807+
fuzzy
809808
]
810809
)
811810
end

spec/jobs/process_patient_changesets_job_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
end
6161

6262
context "when a later fuzzy search finds a match" do
63-
let(:step) { :fuzzy_without_history }
63+
let(:step) { :fuzzy }
6464

6565
before do
6666
patient_changeset["pending_changes"]["search_results"] = [
@@ -85,7 +85,7 @@
8585
end
8686

8787
context "when fuzzy search returns conflicting NHS numbers" do
88-
let(:step) { :fuzzy_without_history }
88+
let(:step) { :fuzzy }
8989

9090
before do
9191
patient_changeset["pending_changes"]["search_results"] = [

0 commit comments

Comments
 (0)