MDA-1305: Change Duplicate Detection Logic In TAF For FTX Records - #352
Open
rnama wants to merge 5 commits into
Open
MDA-1305: Change Duplicate Detection Logic In TAF For FTX Records#352rnama wants to merge 5 commits into
rnama wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the FTX segment’s duplicate-detection and final-claim matching logic to avoid dropping valid FTX records by including PMT_OR_RCPMT_DT (payment/receipt date) in the de-dup key and claim-family join, with null-safe comparisons.
Changes:
- Added
PMT_OR_RCPMT_DTto the_nodupsgrouping key for FTX extraction. - Updated the
_nodupsjoin-back and the claim-family join to include a null-safe payment-date comparison. - Normalized claim-family
SUBMTG_STATE_CDviatrim(upper(...))and aliasedPYMT_OR_RCPMT_DTtoPMT_OR_RCPMT_DTfor joins.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hls0231
approved these changes
Aug 5, 2026
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
taf/FTX/FTX.py:60
- The de-dup key groups by the raw
PMT_OR_RCPMT_DT, but the join back to the base table compares payment dates usingcoalesce(..., to_date('1960-01-01')). If the source data mixes NULLs and the sentinel1960-01-01for the same claim key, both groups can passcount(...) = 1, and the coalescing join will match them as equal (causing duplicate rows / row multiplication). Make the de-dup key use the same null-normalized expression as the join predicate so NULL and sentinel are treated consistently.
,SUBMTG_STATE_CD
,ORGNL_CLM_NUM
,ADJSTMT_CLM_NUM
,ADJSTMT_IND
,PMT_OR_RCPMT_DT
taf/FTX/FTX.py:96
CLM_FMLY_{_2x_segment}groups by the rawPYMT_OR_RCPMT_DT(aliased toPMT_OR_RCPMT_DT), but the join to FTX uses a null-normalized comparison viacoalesce(..., to_date('1960-01-01')). If the claim family table contains both NULL and the sentinel date for the same claim key, the CTE can keep multiple rows (eachcount(...) = 1) that later match as equal in the join, producing duplicates. Coalesce the claim-family payment date in the CTE so grouping and join semantics are aligned.
,trim(upper(SUBMTG_STATE_CD)) as SUBMTG_STATE_CD
,COALESCE(UPPER(ADJSTMT_IND),'X') as ADJSTMT_IND
,PYMT_OR_RCPMT_DT as PMT_OR_RCPMT_DT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
We are making this change to prevent valid FTX records from being incorrectly dropped during the TAF build.
The current FTX duplicate-detection/final-claim matching logic does not include a date in its key, which can cause distinct claims in the same claim family to be treated as duplicates when multiple final claims exist. Other claims files avoid this issue by including the adjudication date in the key, but FTX does not contain an adjudication date.
To align FTX behavior with other claims files and preserve valid records, this change adds
PMT_OR_RCPMT_DT(payment/receipt date) to the duplicate-detection key and final-claim matching logic, with null-safe handling.Associated Jira Tickets
Scope
Changes Included
PMT_OR_RCPMT_DTto the FTX deduplication key.PYMT_OR_RCPMT_DT AS PMT_OR_RCPMT_DTSUBMTG_STATE_CDusing:Implementation Reference
FTX.py:57FTX.py:91FTX.py:115Change Size Summary