Skip to content

Commit

Permalink
Add name and dob check to matching claims
Browse files Browse the repository at this point in the history
A requirement is to trigger a "multiple claims with matching details"
warning if there is another claim with a matching name and date of
birth. This check is to work across all policies.
  • Loading branch information
rjlynch committed Sep 27, 2024
1 parent 2a09444 commit 12eb8b8
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/models/claim/matching_attribute_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class MatchingAttributeFinder
CLAIM_ATTRIBUTE_GROUPS_TO_MATCH = [
["email_address"],
["national_insurance_number"],
["bank_account_number", "bank_sort_code", "building_society_roll_number"]
["bank_account_number", "bank_sort_code", "building_society_roll_number"],
["first_name", "surname", "date_of_birth"]
].freeze

def initialize(source_claim)
Expand Down
54 changes: 51 additions & 3 deletions spec/models/claim/matching_attribute_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
describe "#matching_claims for ECP/LUP claims" do
let!(:source_claim) {
create(:claim,
first_name: "Genghis",
surname: "Khan",
date_of_birth: Date.new(1162, 5, 31),
national_insurance_number: "QQ891011C",
email_address: "[email protected]",
bank_account_number: "34682151",
Expand All @@ -17,6 +20,9 @@
let!(:student_loans_claim) {
create(:claim,
:submitted,
first_name: "Genghis",
surname: "Khan",
date_of_birth: Date.new(1162, 5, 31),
national_insurance_number: "QQ891011C",
email_address: "[email protected]",
bank_account_number: "34682151",
Expand All @@ -30,6 +36,9 @@
let!(:lup_claim) {
create(:claim,
:submitted,
first_name: "Genghis",
surname: "Khan",
date_of_birth: Date.new(1162, 5, 31),
national_insurance_number: "QQ891011C",
email_address: "[email protected]",
bank_account_number: "34682151",
Expand All @@ -50,6 +59,9 @@
describe "#matching_claims" do
let(:source_claim) {
create(:claim,
first_name: "Genghis",
surname: "Khan",
date_of_birth: Date.new(1162, 5, 31),
national_insurance_number: "QQ891011C",
email_address: "[email protected]",
bank_account_number: "34682151",
Expand Down Expand Up @@ -172,6 +184,39 @@

expect(matching_claims).to be_empty
end

it "does not include a claim with a matching name" do
create(
:claim,
:submitted,
first_name: source_claim.first_name,
surname: source_claim.surname
)

expect(matching_claims).to be_empty
end

it "does not include a claim with a matching date of birth" do
create(
:claim,
:submitted,
date_of_birth: source_claim.date_of_birth
)

expect(matching_claims).to be_empty
end

it "includes a claim with a matching name and date of birth" do
claim_with_matching_attributes = create(
:claim,
:submitted,
first_name: source_claim.first_name,
surname: source_claim.surname,
date_of_birth: source_claim.date_of_birth
)

expect(matching_claims).to eq([claim_with_matching_attributes])
end
end

describe "matching_claims - blank trn" do
Expand All @@ -193,7 +238,8 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
surname: Faker::Name.last_name
)
}

Expand Down Expand Up @@ -221,7 +267,8 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
surname: Faker::Name.last_name
)
}

Expand Down Expand Up @@ -253,7 +300,8 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
surname: Faker::Name.last_name
)
}

Expand Down
2 changes: 1 addition & 1 deletion spec/models/claim_checking_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
end

it "includes a task for payroll gender when a payroll gender task has previously been completed" do
claim.tasks << create(:task, name: "payroll_gender")
create(:task, name: "payroll_gender", claim: claim)

expect(checking_tasks.applicable_task_names).to match_array(applicable_tasks + %w[payroll_gender])
end
Expand Down
4 changes: 3 additions & 1 deletion spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
:claim,
:submitted,
policy: policy,
eligibility: eligibility
eligibility: eligibility,
first_name: Faker::Name.first_name,
surname: Faker::Name.last_name
)
}

Expand Down

0 comments on commit 12eb8b8

Please sign in to comment.