Skip to content

Commit

Permalink
fix(patient): error in age calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
YamirHaidar authored and akashkrishna619 committed Apr 15, 2024
1 parent 7e8ae54 commit 9258c1c
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 9258c1c

Please sign in to comment.