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

#5308 display age in years months days #5309

Merged
merged 4 commits into from
Dec 26, 2023

Conversation

arjunSussol
Copy link
Contributor

Fixes #5308

Change summary

If age below 1 year then it would be shown with months and days e.g. 3 months 23 days.

Testing

Steps to reproduce or otherwise test the changes of this PR:

  • Enter dob for a patient in current year
  • the age should be shown with months and days
  • If dob is more than one year then it will be shown with full number.

Related areas to think about

If there are any general areas of the codebase your changes might have side affects on, mention them here

@sanjeevsussol sanjeevsussol linked an issue Sep 11, 2023 that may be closed by this pull request
Copy link
Collaborator

@raviSussol raviSussol left a comment

Choose a reason for hiding this comment

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

Lgtm. A minor suggestion though.

}
return `${moment().diff(dob, 'years')}`;
}
return '';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is working fine but a more simpler form would be:

const calculateAge = dob => {
  if (!dob) return '';
  const ageDuration = moment.duration(moment().diff(dob));
  // If less than a year then `{months} {days}`
  return ageDuration.years() < 1 ? `${ageDuration.months()} months ${ageDuration.days()} days` : `${ageDuration.years()}`;
};

@GaryWilletts
Copy link

@arjunSussol this has been approved by PLM Sierra Leone, so needs to be merged now.

@arjunSussol arjunSussol merged commit e96d70a into develop Dec 26, 2023
@arjunSussol arjunSussol deleted the #5308-display-age-in-years-months-days branch December 26, 2023 09:25
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.

Display age below 1 year old in months and days
3 participants