Skip to content

Commit 2404f98

Browse files
authored
Merge pull request #4745 from nhsuk/revert-4597-deduplicate-parents
Revert "Deduplicate parents with same email in same file"
2 parents d88d9e5 + 3df5404 commit 2404f98

3 files changed

Lines changed: 3 additions & 23 deletions

File tree

app/jobs/commit_patient_changesets_job.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def import_patients_and_parents(changesets, import)
6060
changesets.each(&:assign_patient_id)
6161
PatientChangeset.import(changesets, on_duplicate_key_update: :all)
6262

63-
deduplicate_parents!(parents, relationships)
6463
Parent.import(parents.to_a, on_duplicate_key_update: :all)
6564
link_records_to_import(import, Parent, parents)
6665

@@ -94,25 +93,6 @@ def deduplicate_patients!(patients, relationships)
9493
patients.uniq!
9594
end
9695

97-
def deduplicate_parents!(parents, relationships)
98-
@parents_by_email ||= {}
99-
parents.reject! do |parent|
100-
next false if parent.email.blank?
101-
102-
existing_parent = @parents_by_email[parent.email]
103-
if parent.persisted? || existing_parent.nil?
104-
@parents_by_email[parent.email] = parent
105-
next false
106-
else
107-
relationships
108-
.select { _1.parent == parent }
109-
.each { _1.parent = existing_parent }
110-
next true
111-
end
112-
end
113-
parents.uniq!
114-
end
115-
11696
def import_school_moves(changesets, import)
11797
school_moves = changesets.map(&:school_move).compact.uniq(&:patient)
11898

spec/features/import_child_pds_lookup_extravaganza_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,10 @@ def then_school_moves_are_created_appropriately
701701

702702
def and_all_parent_relationships_are_established
703703
expect(Parent.count).to eq(7)
704-
expect(ParentRelationship.count).to eq(8)
704+
expect(ParentRelationship.count).to eq(7)
705705

706706
father_relationships = ParentRelationship.where(type: "father")
707-
expect(father_relationships.count).to eq(4) # John Tweedle, Mike HomeDad, Robert Samson
707+
expect(father_relationships.count).to eq(3) # John Tweedle, Mike HomeDad, Robert Samson
708708

709709
mother_relationships = ParentRelationship.where(type: "mother")
710710
expect(mother_relationships.count).to eq(2) # Mary Tweedle, Linda Samson

spec/fixtures/cohort_import/pds_extravaganza.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ CHILD_SCHOOL_URN,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHO
88
123456,Jane Doe,,,01234567896,,,,,Oliver,Green,,2010-08-15,8,789 Silent Street,,London,SW1W 8JL,9435753868
99
123456,,,,,,,,,Lara,Williams,,2010-05-15,8,,,,B1 1AA,
1010
123456,,,,,,,,,Lucy,McCarthy,,2010-08-16,8,789 Silent Street,,London,SW7 5LE,9435815065
11-
123456,Mike HomeDad,Father,mike@home.com,01234567895,,,,,Maia,Smith,,2010-08-16,8,790 Silent Street,,London,W2 3PE,9435789102
11+
123456,,,,,,,,,Maia,Smith,,2010-08-16,8,790 Silent Street,,London,W2 3PE,9435789102
1212
123456,,,,,,,,,Caroline,Richard,,2010-05-15,8,,,,B1 1AA,
1313
123456,,,,,,,,,Caroline,Richard,,2010-05-15,8,,,,B1 1AA,

0 commit comments

Comments
 (0)