Skip to content

Commit 3909a1a

Browse files
authored
Merge pull request #6211 from NHSDigital/revert-6165-alistair/imms-import-cache-patients
Revert "Match against patients in upload before DB in `ImmsImport`s"
2 parents 87ceb53 + a8dd5f3 commit 3909a1a

2 files changed

Lines changed: 16 additions & 19 deletions

File tree

app/models/immunisation_import.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,14 @@ def parse_row(data)
9292
end
9393

9494
def process_row(row)
95-
patient = row.set_patient(candidates: @all_patients)
95+
patient = row.set_patient(candidates: @patients_batch)
9696
vaccination_record = row.to_vaccination_record
9797

9898
count_column_to_increment = count_column(vaccination_record)
9999
return count_column_to_increment unless vaccination_record
100100

101101
@vaccination_records_batch.add(vaccination_record)
102102
@patients_batch.add(patient)
103-
@all_patients.add(patient)
104103

105104
if (patient_location = row.to_patient_location)
106105
@patient_locations_batch.add(patient_location)
@@ -118,7 +117,6 @@ def process_import!
118117

119118
@vaccination_records_batch = Set.new
120119
@patients_batch = Set.new
121-
@all_patients = Set.new
122120
@patient_locations_batch = Set.new
123121
@archive_reasons_batch = Set.new
124122

app/models/immunisation_import_row.rb

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,24 +504,23 @@ def existing_patients(candidates: nil)
504504
return
505505
end
506506

507-
if candidates.present?
508-
# Match against the in-memory list of patients so far in this upload, before matching against the database
509-
candidate_matches =
510-
PatientMatcher.from_enumerable(
511-
candidates,
512-
nhs_number: patient_nhs_number_value,
513-
given_name: patient_first_name.to_s,
514-
family_name: patient_last_name.to_s,
515-
date_of_birth: patient_date_of_birth.to_date,
516-
address_postcode: patient_postcode&.to_postcode,
517-
include_3_out_of_4_matches: false
518-
)
507+
database_matches =
508+
PatientMatcher.from_relation(
509+
Patient,
510+
nhs_number: patient_nhs_number_value,
511+
given_name: patient_first_name.to_s,
512+
family_name: patient_last_name.to_s,
513+
date_of_birth: patient_date_of_birth.to_date,
514+
address_postcode: patient_postcode&.to_postcode,
515+
include_3_out_of_4_matches: false
516+
)
519517

520-
return candidate_matches if candidate_matches.present?
521-
end
518+
return database_matches if database_matches.present?
519+
520+
return if candidates.blank?
522521

523-
PatientMatcher.from_relation(
524-
Patient,
522+
PatientMatcher.from_enumerable(
523+
candidates,
525524
nhs_number: patient_nhs_number_value,
526525
given_name: patient_first_name.to_s,
527526
family_name: patient_last_name.to_s,

0 commit comments

Comments
 (0)