Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplciate claims in list #3298

Merged
merged 3 commits into from
Oct 10, 2024
Merged

Conversation

rjlynch
Copy link
Contributor

@rjlynch rjlynch commented Oct 10, 2024

The awaiting provider verification scope joins to notes, claims can have
more than one note, if they do duplicate claims are returned from the
query. To resolve this we call distinct on the claim id. Claims have a
couple of JSON columns so we can't use the distinct method directly,
instead we have to explicitly use distinct with the claim.id. We also
need to wrap the whole query in a where clause so when we chain on a
count rails generates the correct SQL rather than something like
SELECT COUNT(count_column) FROM (SELECT DISTINCT ON (claims.id), claims.id)
Additionally we have to make sure to include submitted_at in the
distinct clause as some of the scopes used to build the query include
order by submitted_at clauses.

@rjlynch rjlynch force-pushed the CAPT-1853/fix-duplicate-claims-showing branch from 161cdba to 8dc06dd Compare October 10, 2024 13:03
The awaiting provider verification scope joins to notes, claims can have
more than one note, if they do duplicate claims are returned from the
query. To resolve this we call distinct on the claim id. Claims have a
couple of JSON columns so we can't use the `distinct` method directly,
instead we have to explicitly use distinct with the claim.id. We also
need to wrap the whole query in a where clause so when we chain on a
`count` rails generates the correct SQL rather than something like
`SELECT COUNT(count_column) FROM (SELECT DISTINCT ON (claims.id), claims.id)`
Additionally we have to make sure to include `submitted_at` in the
distinct clause as some of the scopes used to build the query include
order by submitted_at clauses.
We move the order clause to where it's needed rather than having it on
every call to `payrollable`, this lets us simplify the distinct clause
as we no longer need to include the `submitted_at` in the distinct.
@rjlynch rjlynch force-pushed the CAPT-1853/fix-duplicate-claims-showing branch from 94aebf2 to 256ae4d Compare October 10, 2024 14:11
Need to eager load the other models AFTER we dedup the clams in the
query
@rjlynch rjlynch merged commit 8c441a6 into master Oct 10, 2024
14 checks passed
@rjlynch rjlynch deleted the CAPT-1853/fix-duplicate-claims-showing branch October 10, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants