Skip to content

Commit

Permalink
populate covered individuls properly when they switch from UQHP to AQHP
Browse files Browse the repository at this point in the history
  • Loading branch information
saipraveen18 committed Jan 2, 2025
1 parent aa737d9 commit 2744408
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def fetch_member_ehb_premium(enrolled_member, premium_schedule, insurance_policy

def get_enrolled_members_by_tax_household_for(enrollments_for_month, tax_household)
enrs_thhs = fetch_enrollments_tax_households(enrollments_for_month)
valid_enr_thh = if enrs_thhs.size > 1
valid_enr_thh = if enrs_thhs.size > 1 && tax_household.is_aqhp
enrs_thhs.select do |enr_thh|
valid_enrollment_tax_household?(enr_thh, tax_household) && enr_thh.tax_household.is_aqhp
end
Expand Down Expand Up @@ -563,7 +563,7 @@ def fetch_thh_members_from_enr_thhs(enr_thhs, tax_household)
return tax_household.tax_household_members unless tax_household.is_aqhp

enr_thhs_for_month = enr_thhs.select do |enr_thh|
enr_thh.tax_household.is_aqhp && valid_enrollment_tax_household?(enr_thh, tax_household)
valid_enrollment_tax_household?(enr_thh, tax_household)
end
enrolled_thh_members_person_ids = enr_thhs_for_month&.flat_map(&:tax_household)
&.flat_map(&:tax_household_members)&.uniq(&:person_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,9 @@
let!(:premium_schedule_2_enrollment_1) do
FactoryBot.create(:premium_schedule, enrolled_member: enrollment_1.dependents.first)
end
let!(:aqhp_tax_household_1) { FactoryBot.create(:tax_household, is_aqhp: false) }
let!(:aqhp_tax_household_2) { FactoryBot.create(:tax_household, is_aqhp: true) }
let!(:aqhp_tax_household_3) { FactoryBot.create(:tax_household, is_aqhp: true) }

let!(:uqp_thh_1_sub_tax_household_member) do
FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household_1, person: subscriber_person,
is_tax_filer: true)
end
let!(:uqhp_thh_1_dep_tax_household_member) do
FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household_1, person: dependent_person,
is_tax_filer: false)
end

let!(:aqhp_thh_2_sub_tax_household_member) do
FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household_2, person: subscriber_person,
is_tax_filer: true)
Expand All @@ -430,10 +420,6 @@
is_tax_filer: true)
end

let!(:uqhp_enrollment_tax_household_1) do
FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_1.id, tax_household_id: aqhp_tax_household_1.id)
end

let!(:aqhp_enrollment_tax_household_2) do
FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_1.id, tax_household_id: aqhp_tax_household_2.id)
end
Expand All @@ -452,8 +438,8 @@
end

it "should return correct members for each tax_household" do
expect(@result[:aptc_csr_tax_households].first[:covered_individuals].count).to eq 1
expect(@result[:aptc_csr_tax_households].first[:covered_individuals].count).to eq 1
expect(@result[:aptc_csr_tax_households][0][:covered_individuals].count).to eq 1
expect(@result[:aptc_csr_tax_households][1][:covered_individuals].count).to eq 1
end
end

Expand Down Expand Up @@ -577,6 +563,95 @@
end
end

context 'UQHP mid month member drop' do
let(:subscriber_person) { FactoryBot.create(:people_person) }
let(:dependent_person) { FactoryBot.create(:people_person) }
let!(:glue_subscriber_person) { FactoryBot.create(:person, authority_member_id: subscriber_person.hbx_id) }
let!(:glue_dependent_person) { FactoryBot.create(:person, authority_member_id: dependent_person.hbx_id) }
let(:enrollment_1_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) }
let(:enrollment_2_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) }
let(:enrollment_2_dependents) { FactoryBot.build(:enrolled_member, person: dependent_person) }
let(:product) do
FactoryBot.create(:insurance_product, ehb: 0.9959)
end
let(:insurance_policy) do
FactoryBot.create(:insurance_policy,
insurance_product: product,
start_on: Date.new(year, 1, 1),
end_on: Date.new(year, 12, 31))
end

let!(:enrollment_1) do
FactoryBot.create(:enrollment, start_on: Date.new(year, 1, 1),
effectuated_on: Date.new(year, 1, 1),
end_on: Date.new(year, 7, 23),
created_at: Time.now,
insurance_policy: insurance_policy,
subscriber: enrollment_1_subscriber,
dependents: [enrollment_2_dependents])
end
let!(:enrollment_2) do
FactoryBot.create(:enrollment, start_on: Date.new(year, 7, 24),
effectuated_on: Date.new(year, 7, 24),
created_at: Time.now,
insurance_policy: insurance_policy,
subscriber: enrollment_2_subscriber)
end
let!(:premium_schedule_enrollment) do
FactoryBot.create(:premium_schedule, enrolled_member: enrollment_1.subscriber,
premium_amount: 100.0, benchmark_ehb_premium_amount: 100.0)
end
let!(:premium_schedule_2_enrollment) do
FactoryBot.create(:premium_schedule, enrolled_member: enrollment_1.dependents.first,
premium_amount: 50.0, benchmark_ehb_premium_amount: 50.0)
end
let!(:premium_schedule_3_enrollment) do
FactoryBot.create(:premium_schedule, enrolled_member: enrollment_2.subscriber,
premium_amount: 100.0, benchmark_ehb_premium_amount: 100.0)
end

let!(:uqhp_tax_household_1) { FactoryBot.create(:tax_household, is_aqhp: false) }
let!(:uqhp_tax_household_2) { FactoryBot.create(:tax_household, is_aqhp: false) }

let!(:uqhp_thh_1_sub_tax_household_member) do
FactoryBot.create(:tax_household_member, tax_household: uqhp_tax_household_1, person: subscriber_person,
is_tax_filer: true)
end
let!(:uqhp_thh_1_dep_tax_household_member) do
FactoryBot.create(:tax_household_member, tax_household: uqhp_tax_household_1, person: dependent_person,
is_tax_filer: false)
end
let!(:uqhp_thh_2_dep_tax_household_member) do
FactoryBot.create(:tax_household_member, tax_household: uqhp_tax_household_2, person: subscriber_person,
is_tax_filer: true)
end
let!(:uqhp_enrollment_tax_household_1) do
FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_1.id, tax_household_id: uqhp_tax_household_1.id)
end
let!(:uqhp_enrollment_tax_household_2) do
FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_2.id, tax_household_id: uqhp_tax_household_2.id)
end

before :each do
@result_call = subject.call({ insurance_policy: insurance_policy })
@result = @result_call.value!
end

it "should should publish the event" do
expect(@result_call.success?).to be_truthy
expect(@result[:aptc_csr_tax_households].first[:covered_individuals].count).to eq 2
end

it "should round down ehb premium value" do
july_coverage_info = @result[:aptc_csr_tax_households].first[:months_of_year][6][:coverage_information]
premium = july_coverage_info.dig(:total_premium, :cents)
expect(Money.new(premium).to_f).to eq 135.35
jan_coverage_info = @result[:aptc_csr_tax_households].first[:months_of_year][0][:coverage_information]
premium = jan_coverage_info.dig(:total_premium, :cents)
expect(Money.new(premium).to_f).to eq 148.00
end
end

context 'rounding down member premiums' do
let(:subscriber_person) { FactoryBot.create(:people_person) }
let!(:glue_subscriber_person) { FactoryBot.create(:person, authority_member_id: subscriber_person.hbx_id) }
Expand Down

0 comments on commit 2744408

Please sign in to comment.