Skip to content

Impute end date for the encounter mart when null#1303

Open
andreas-homeward wants to merge 10 commits intotuva-health:mainfrom
andreas-homeward:update-end-date
Open

Impute end date for the encounter mart when null#1303
andreas-homeward wants to merge 10 commits intotuva-health:mainfrom
andreas-homeward:update-end-date

Conversation

@andreas-homeward
Copy link
Copy Markdown
Contributor

@andreas-homeward andreas-homeward commented Apr 11, 2026

Summary

  • Fixing encounters with length of stays that are >1000 days due to null end dates

Long Length of Stays

When there is a null end date, the order by in the partition to create a row_num will be last in some DBMS engines like Snowflake. This will then be flagged with a close flag. This open-ended end date will then include claims far into the future, resulting in length of stays over 1000 days long. The proposed fix is defaulting to the same day if there is no end date to ensure accurate average paid amounts and other statistics from being skewed by these outliers.

Notes

This PR was split from this PR originally: #1283

Relevant comment from @bradmontierth from the other PR: #1283 (comment)

regarding LOS to move once that PR is created, I'm not sure I follow on "null end dates cause large LOS"
A null end date should mostly cause the merge comparisons to fail, since expressions like dateadd(day, 1, aa.end_date) >= bb.start_date become null. That makes this look more like a grouping behavior change than an LOS inflation fix. Curious to see if you have other examples

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 11, 2026

Deploy Preview for thetuvaproject canceled.

Name Link
🔨 Latest commit 40b836c
🔍 Latest deploy log https://app.netlify.com/projects/thetuvaproject/deploys/69f27e6ed4deee0008512145

@andreas-homeward andreas-homeward changed the title Update end date for the encounter mart when null Impute end date for the encounter mart when null Apr 11, 2026
@aneiderhiser
Copy link
Copy Markdown
Collaborator

@andreas-homeward were you able to find any example counter to what @bradmontierth is suggesting in the comment above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 Ready for Review

Development

Successfully merging this pull request may close these issues.

4 participants