Skip to content

Commit

Permalink
fix(patient): error in age calculation
Browse files Browse the repository at this point in the history
(cherry picked from commit 9258c1c)
  • Loading branch information
YamirHaidar authored and akashkrishna619 committed Apr 16, 2024
1 parent c6adae1 commit 07fce5c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions healthcare/healthcare/doctype/patient/patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ let create_medical_record = function (frm) {
};

let get_age = function (birth) {
let ageMS = Date.parse(Date()) - Date.parse(birth);
let age = new Date();
age.setTime(ageMS);
let years = age.getFullYear() - 1970;
return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
let birth_moment = moment(birth);
let current_moment = moment(Date());
let diff = moment.duration(current_moment.diff(birth_moment));
return `${diff.years()} ${__('Year(s)')} ${diff.months()} ${__('Month(s)')} ${diff.days()} ${__('Day(s)')}`
};

let create_vital_signs = function (frm) {
Expand Down

0 comments on commit 07fce5c

Please sign in to comment.