Use age_in_days for age calculations#1119
Open
labkey-martyp wants to merge 3 commits intorelease26.3-SNAPSHOTfrom
Open
Use age_in_days for age calculations#1119labkey-martyp wants to merge 3 commits intorelease26.3-SNAPSHOTfrom
labkey-martyp wants to merge 3 commits intorelease26.3-SNAPSHOTfrom
Conversation
labkey-bpatel
approved these changes
Apr 27, 2026
Contributor
labkey-bpatel
left a comment
There was a problem hiding this comment.
Looks good! Please review my comment.
| " CAST(CASE WHEN x.birth IS NULL OR x.effDate IS NULL THEN NULL\n" + | ||
| " ELSE age_in_days(x.birth, x.effDate) END AS INTEGER) AS AgeAtTimeDays,\n" + | ||
| " CAST(CASE WHEN x.birth IS NULL OR x.effDate IS NULL THEN NULL\n" + | ||
| " ELSE CONVERT(age_in_months(x.birth, x.effDate), INTEGER) END AS INTEGER) AS AgeAtTimeMonths,\n" + |
Contributor
There was a problem hiding this comment.
AgeAtTimeYearsRounded, AgeAtTimeDays, and AgeAtTimeMonths - these were previously cast as float (even though it produced whole number values first), but now they are integer -- is this intentional?
| " ELSE CAST(" + dateSql + " AS DATE) END AS effDate\n" + | ||
| " FROM \"" + schemaName + "\".\"" + queryName + "\" c\n" + | ||
| " LEFT JOIN \"" + ehrPath + "\".study.demographics d ON (d.Id = c." + idCol.getFieldKey().toSQLString() + ")\n" + | ||
| ") x" |
Contributor
There was a problem hiding this comment.
AgeClassAtTime semantics change looks like a great improvement!
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.
Rationale
The new age_in_days is consistent across postgres and sql server and more in-line with age as measuring calendar days. A few fixes and cleanups associated with age calculations as well.
Related Pull Requests
Changes