Skip to content

Commit

Permalink
Add totals row to 526EZ Claim Submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
tycol7 committed Sep 4, 2024
1 parent 904b662 commit ce77d49
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ def perform

private

def get_monthly_claims_by_consumer_by_status(monthly_claims_by_cid_by_status, monthly_pact_claims_by_cid)
totals_row = Hash.new(0)

monthly_claims_by_consumer_by_status = monthly_claims_by_cid_by_status.map do |cid, column_counts|
column_counts[:totals] = column_counts.values.sum
column_counts[:pact_count] = monthly_pact_claims_by_cid[cid]

column_counts.symbolize_keys!

column_counts.each do |column, count|
totals_row[column] += count
end

{ ClaimsApi::CidMapper.new(cid:).name => column_counts }
end

monthly_claims_by_consumer_by_status.tap do |claims_rows|
claims_rows << { 'Totals' => totals_row } unless totals_row.empty?
end
end

def monthly_claims_totals
monthly_claims_consumers = ClaimsApi::AutoEstablishedClaim.where(created_at: @from..@to)
monthly_pact_claims = ClaimsApi::ClaimSubmission.where(created_at: @from..@to,
Expand All @@ -38,13 +59,7 @@ def monthly_claims_totals
hash[cid] += 1 if cid
end

monthly_claims_by_cid_by_status.map do |cid, status_counts|
status_counts[:totals] = status_counts.values.sum
status_counts[:pact_count] = monthly_pact_claims_by_cid[cid]
{
ClaimsApi::CidMapper.new(cid:).name => status_counts.deep_symbolize_keys
}
end
get_monthly_claims_by_consumer_by_status(monthly_claims_by_cid_by_status, monthly_pact_claims_by_cid)
end
end
end
18 changes: 14 additions & 4 deletions modules/claims_api/spec/sidekiq/report_monthly_submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@

context 'with one claims consumer and one PACT claim' do
let(:claim_setup) { :setup_one_claim_one_pact_claim }
let(:expected_totals) { [{ 'VA TurboClaim' => { established: 1, totals: 1, pact_count: 1 } }] }
let(:expected_totals) do
[{ 'VA TurboClaim' => { established: 1, totals: 1, pact_count: 1 } },
{ 'Totals' => { established: 1, totals: 1, pact_count: 1 } }]
end

def setup_one_claim_one_pact_claim
claim = create(:auto_established_claim, :status_established, cid: '0oa9uf05lgXYk6ZXn297')
Expand All @@ -51,7 +54,10 @@ def setup_one_claim_one_pact_claim

context 'with one claims consumer and no PACT claims' do
let(:claim_setup) { :setup_one_claim_no_pact_claims }
let(:expected_totals) { [{ 'VA TurboClaim' => { established: 1, totals: 1, pact_count: 0 } }] }
let(:expected_totals) do
[{ 'VA TurboClaim' => { established: 1, totals: 1, pact_count: 0 } },
{ 'Totals' => { established: 1, totals: 1, pact_count: 0 } }]
end

def setup_one_claim_no_pact_claims
create(:auto_established_claim, :status_established, cid: '0oa9uf05lgXYk6ZXn297')
Expand All @@ -64,7 +70,8 @@ def setup_one_claim_no_pact_claims
let(:claim_setup) { :setup_two_claims_one_pact_claim }
let(:expected_totals) do
[{ 'VA TurboClaim' => { established: 1, totals: 1, pact_count: 1 } },
{ 'VA.gov' => { errored: 1, totals: 1, pact_count: 0 } }]
{ 'VA.gov' => { errored: 1, totals: 1, pact_count: 0 } },
{ 'Totals' => { established: 1, errored: 1, totals: 2, pact_count: 1 } }]
end

def setup_two_claims_one_pact_claim
Expand All @@ -78,7 +85,10 @@ def setup_two_claims_one_pact_claim

context 'with one claims consumer and multiple claims' do
let(:claim_setup) { :setup_one_consumer_multiple_claims }
let(:expected_totals) { [{ 'VA TurboClaim' => { established: 2, errored: 1, totals: 3, pact_count: 0 } }] }
let(:expected_totals) do
[{ 'VA TurboClaim' => { established: 2, errored: 1, totals: 3, pact_count: 0 } },
{ 'Totals' => { established: 2, errored: 1, totals: 3, pact_count: 0 } }]
end

def setup_one_consumer_multiple_claims
cid = '0oa9uf05lgXYk6ZXn297'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def unsuccessful_claims_submissions
def claims_totals
[
{ 'consumer 1' => { pending: 2, errored: 1, totals: 3, pact_count: 2 } },
{ 'consumer 2' => { pending: 3, errored: 3, totals: 6, pact_count: 1 } }
{ 'consumer 2' => { pending: 3, errored: 3, totals: 6, pact_count: 1 } },
{ 'Totals' => { pending: 5, errored: 4, totals: 9, pact_count: 3 } }
]
end

Expand Down

0 comments on commit ce77d49

Please sign in to comment.