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

Patients age is correctly defined #9680

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ export const formatPatientAge = (
abbreviated = false,
) => {
const suffixes = getRelativeDateSuffix(abbreviated);

const start = dayjs(
obj.date_of_birth
? new Date(obj.date_of_birth)
Expand All @@ -415,9 +414,7 @@ export const formatPatientAge = (
// Skip representing as no. of months/days if we don't know the date of birth
// since it would anyways be inaccurate.
if (!obj.date_of_birth) {
return abbreviated
? `Born ${obj.year_of_birth}`
: `Born on ${obj.year_of_birth}`;
return abbreviated ? `${obj.age} Y` : `Born on ${obj.year_of_birth}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if year_of_birth is undefined, and abbreviated is set to false, this would still have the same issue right?

instead let's check if age is null or not and show age if available, else fallback to year of birth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Is it correct?

Copy link
Member

@rithviknishad rithviknishad Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, let's keep old year of birth if age is not present (same as before). if backend gives us age, let's show age directly before reaching there.

Suggested change
return abbreviated ? `${obj.age} Y` : `Born on ${obj.year_of_birth}`;
if (age != null) return `${obj.age} Y`;
return abbreviated ? `Born ${obj.year_of_birth}` : `Born on ${obj.year_of_birth}`;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Is it what you meant?

Copy link
Member

@rithviknishad rithviknishad Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup! this one's better!

}

const month = end.diff(start, "month");
Expand Down
Loading