diff --git a/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb b/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb index 8d695060..a71e8fc2 100644 --- a/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb +++ b/app/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload.rb @@ -556,7 +556,9 @@ def fetch_thh_members_from_enr_thhs(enr_thhs, tax_household) return thh_members_from_enr_thhs if enr_thhs.present? && !tax_household.is_aqhp return tax_household.tax_household_members unless tax_household.is_aqhp - enr_thhs_for_month = enr_thhs.select { |enr_thh| valid_enrollment_tax_household?(enr_thh, tax_household) } + enr_thhs_for_month = enr_thhs.select do |enr_thh| + enr_thh.tax_household.is_aqhp && valid_enrollment_tax_household?(enr_thh, tax_household) + end enr_thhs_for_month&.flat_map(&:tax_household)&.flat_map(&:tax_household_members)&.uniq(&:person_id) || thh_members_from_enr_thhs diff --git a/app/operations/irs_groups/calculate_dental_premium_for_enrolled_children.rb b/app/operations/irs_groups/calculate_dental_premium_for_enrolled_children.rb index b7435dbf..58447531 100644 --- a/app/operations/irs_groups/calculate_dental_premium_for_enrolled_children.rb +++ b/app/operations/irs_groups/calculate_dental_premium_for_enrolled_children.rb @@ -79,10 +79,7 @@ def total_premium(dental_product) end # Finalize members based on Age - members = members.select do |member| - age_function = AcaEntities::Functions::AgeOn.new(on_date: @enrollment.effectuated_on) - age_function.call(member.dob) < 19 - end + members = fetch_valid_child_members(members) members_premium = members.reduce(0.00) do |sum, member| (sum + member.premium_schedule.premium_amount).round(2) @@ -95,7 +92,10 @@ def total_premium(dental_product) # The maximum is for 3 children so we return premium for primary_enrollee_two_dependent. def family_premium(dental_product) - case primary_tier_value + child_members = fetch_valid_child_members(@child_members) + return 0.0 if child_members.blank? + + case primary_tier_value(child_members) when 'primary_enrollee' dental_product.primary_enrollee when 'primary_enrollee_one_dependent' @@ -106,8 +106,8 @@ def family_premium(dental_product) end # The maximum is for 3 children so we return premium for primary_enrollee_two_dependent. - def primary_tier_value - case @child_members.count + def primary_tier_value(child_members) + case child_members.count when 1 'primary_enrollee' when 2 @@ -117,6 +117,13 @@ def primary_tier_value end end + def fetch_valid_child_members(members) + members.select do |member| + age_function = AcaEntities::Functions::AgeOn.new(on_date: @enrollment.effectuated_on) + age_function.call(member.dob) < 19 + end + end + def fetch_dental_policy insurance_policies = @enrollment.insurance_policy.irs_group.aca_individual_insurance_policies insurance_policies.detect do |insurance_policy| diff --git a/app/operations/reports/generate_rcno_report.rb b/app/operations/reports/generate_rcno_report.rb index 98d943ed..cecac71a 100644 --- a/app/operations/reports/generate_rcno_report.rb +++ b/app/operations/reports/generate_rcno_report.rb @@ -340,7 +340,7 @@ def relation_to_subscriber_indicator end def exchange_assigned_subscriber_id - return [nil, @rcni_row[16], "U"] if @rcni_row[16].blank? && @overall_flag == "U" + return [nil, @rcni_row[16], "U"] if @overall_flag == "U" # If Subscriber, Member, or Policy are not found return [nil, @rcni_row[16], "D"] if @overall_flag == "R" @@ -359,7 +359,7 @@ def exchange_assigned_subscriber_id end def exchange_assigned_member_id - return [nil, @rcni_row[17], "U"] if @rcni_row[17].blank? && @overall_flag == "U" + return [nil, @rcni_row[17], "U"] if @overall_flag == "U" # If Subscriber, Member, or Policy are not found return [nil, @rcni_row[17], "D"] if @overall_flag == "R" @@ -433,7 +433,7 @@ def issuer_assigned_member_id end def exchange_assigned_policy_number - return [nil, @rcni_row[20], "U"] if @rcni_row[20].blank? && @overall_flag == "U" + return [nil, @rcni_row[20], "U"] if @overall_flag == "U" # If Subscriber, Member, or Policy are not found return [nil, @rcni_row[20], "D"] if @overall_flag == "R" @@ -616,7 +616,7 @@ def qhp_id_match end def benefit_start_date - return [nil, @rcni_row[37], "U"] if @rcni_row[37].blank? && @overall_flag == "U" + return [nil, @rcni_row[37], "U"] if @overall_flag == "U" # If Subscriber, Member, or Policy are not found return [nil, @rcni_row[37], "D"] if @overall_flag == "R" diff --git a/bearer.yml b/bearer.yml index b711a672..80db8869 100644 --- a/bearer.yml +++ b/bearer.yml @@ -2,6 +2,32 @@ disable-version-check: false report: exclude-fingerprint: # False positives for example connection url in mongoid.yml + - f91d14852b7392b729c5bfa8282aae79_0 + - 90b18ca30d297d4d0939209d6ab764b1_0 + # default amqp not actually used in production + - cf870ae7052bb5731210ae8c0c53092c_0 + - 2d04d7c8b4ee5d3e593887310559866b_0 + # reviewed these operations: + # app/event_source/subscribers/families/found_by_subscriber.rb + # app/operations/data_stores/contract_holder_sync_jobs/process_response_event.rb + # app/operations/integrations/events/build.rb + # determined the above operations/subscribers do not log sensitive data and therefore may be ignored as false positives. + # The reason we made this determination is because the only potentially sensitive data being logged is a cv3 family payload which currently we already consider protected under our current encryption scheme. + # However, if these operations change, they will need to be reviewed again + - 88973a7416419e2845c06e0be825b556_0 + # postgresql is not used in production. This is a legacy schema that does not store actual data. We did not delete file because the specs will break. If we ever actually use postgres, we will need to revisit this exclusion + - a6e77c6d42db8f03ffbe5acae290f72c_0 + - a6e77c6d42db8f03ffbe5acae290f72c_1 + - a6e77c6d42db8f03ffbe5acae290f72c_2 + # # this report is not triggered via web interface. Can only be triggered by an admin on the command line + - c93b0a613ceb859f60b4991c33e2d73f_0 + - c93b0a613ceb859f60b4991c33e2d73f_1 + - c93b0a613ceb859f60b4991c33e2d73f_2 + - c93b0a613ceb859f60b4991c33e2d73f_3 + - c93b0a613ceb859f60b4991c33e2d73f_4 + - c93b0a613ceb859f60b4991c33e2d73f_5 + - c93b0a613ceb859f60b4991c33e2d73f_6 + - c93b0a613ceb859f60b4991c33e2d73f_7 format: "" no-color: false output: "" diff --git a/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb b/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb index ea79e64a..b558e58d 100644 --- a/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb +++ b/spec/operations/insurance_policies/aca_individuals/insurance_policies/construct_cv3_payload_spec.rb @@ -390,4 +390,70 @@ expect(@result[:aptc_csr_tax_households].second[:covered_individuals][0][:coverage_end_on]).to eq enrollment_2.end_on end end + + context "fetch_thh_members_from_enr_thhs" do + let(:enrollment_1_subscriber) { FactoryBot.build(:enrolled_member, person: subscriber_person) } + let(:enrollment_1_dependents) { FactoryBot.build(:enrolled_member, person: dependent_person) } + + let!(:enrollment_1) do + FactoryBot.create(:enrollment, start_on: Date.new(year, 1, 1), + effectuated_on: Date.new(year, 1, 1), + created_at: Time.now, + insurance_policy: insurance_policy, + subscriber: enrollment_1_subscriber, + dependents: [enrollment_1_dependents]) + end + let!(:premium_schedule_1_enrollment_1) { FactoryBot.create(:premium_schedule, enrolled_member: enrollment_1.subscriber) } + 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) + end + + let!(:aqhp_thh_3_dep_tax_household_member) do + FactoryBot.create(:tax_household_member, tax_household: aqhp_tax_household_3, person: dependent_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: 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 + + let!(:aqhp_enrollment_tax_household_3) do + FactoryBot.create(:enrollments_tax_households, enrollment_id: enrollment_1.id, tax_household_id: aqhp_tax_household_3.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 + 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 + end + end end diff --git a/spec/operations/irs_groups/calculate_dental_premium_for_enrolled_children_spec.rb b/spec/operations/irs_groups/calculate_dental_premium_for_enrolled_children_spec.rb index d2c1a494..e784cb9e 100644 --- a/spec/operations/irs_groups/calculate_dental_premium_for_enrolled_children_spec.rb +++ b/spec/operations/irs_groups/calculate_dental_premium_for_enrolled_children_spec.rb @@ -93,4 +93,18 @@ expect(subject.success.to_f).to eq(primary_enrollee_two_dependent) end end + + context 'with only 1 dependent who was 19 at start of coverage' do + let(:dependent5) do + FactoryBot.build(:enrolled_member, + person: FactoryBot.create(:people_person), + dob: Date.new(year - 19, 1, 1)) + end + + let(:dependents) { [dependent5] } + + it 'return should 0' do + expect(subject.success.to_f).to eq(0.0) + end + end end