We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d88d9e5 + 3df5404 commit 2404f98Copy full SHA for 2404f98
3 files changed
app/jobs/commit_patient_changesets_job.rb
@@ -60,7 +60,6 @@ def import_patients_and_parents(changesets, import)
60
changesets.each(&:assign_patient_id)
61
PatientChangeset.import(changesets, on_duplicate_key_update: :all)
62
63
- deduplicate_parents!(parents, relationships)
64
Parent.import(parents.to_a, on_duplicate_key_update: :all)
65
link_records_to_import(import, Parent, parents)
66
@@ -94,25 +93,6 @@ def deduplicate_patients!(patients, relationships)
94
93
patients.uniq!
95
end
96
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
113
- parents.uniq!
114
115
116
def import_school_moves(changesets, import)
117
school_moves = changesets.map(&:school_move).compact.uniq(&:patient)
118
spec/features/import_child_pds_lookup_extravaganza_spec.rb
@@ -701,10 +701,10 @@ def then_school_moves_are_created_appropriately
701
702
def and_all_parent_relationships_are_established
703
expect(Parent.count).to eq(7)
704
- expect(ParentRelationship.count).to eq(8)
+ expect(ParentRelationship.count).to eq(7)
705
706
father_relationships = ParentRelationship.where(type: "father")
707
- expect(father_relationships.count).to eq(4) # John Tweedle, Mike HomeDad, Robert Samson
+ expect(father_relationships.count).to eq(3) # John Tweedle, Mike HomeDad, Robert Samson
708
709
mother_relationships = ParentRelationship.where(type: "mother")
710
expect(mother_relationships.count).to eq(2) # Mary Tweedle, Linda Samson
spec/fixtures/cohort_import/pds_extravaganza.csv
@@ -8,6 +8,6 @@ CHILD_SCHOOL_URN,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHO
8
123456,Jane Doe,,,01234567896,,,,,Oliver,Green,,2010-08-15,8,789 Silent Street,,London,SW1W 8JL,9435753868
9
123456,,,,,,,,,Lara,Williams,,2010-05-15,8,,,,B1 1AA,
10
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
+123456,,,,,,,,,Maia,Smith,,2010-08-16,8,790 Silent Street,,London,W2 3PE,9435789102
12
123456,,,,,,,,,Caroline,Richard,,2010-05-15,8,,,,B1 1AA,
13
0 commit comments