From e1e4810a466f1146fafde434216a043f8857be07 Mon Sep 17 00:00:00 2001 From: David Angulo Date: Mon, 25 Jan 2021 08:29:11 -0600 Subject: [PATCH 1/4] feat: Make patient age translateable --- .../doctype/clinical_procedure/clinical_procedure.js | 2 +- erpnext/healthcare/doctype/lab_test/lab_test.js | 2 +- erpnext/healthcare/doctype/patient/patient.js | 4 ++-- erpnext/healthcare/doctype/patient/patient.py | 2 +- .../doctype/patient_appointment/patient_appointment.js | 2 +- .../healthcare/doctype/patient_encounter/patient_encounter.js | 2 +- .../healthcare/doctype/sample_collection/sample_collection.js | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js index 1d4411d73de..f68da9b9ba1 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js +++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js @@ -364,7 +364,7 @@ let calculate_age = function(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)'; + return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`; }; // List Stock items diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.js b/erpnext/healthcare/doctype/lab_test/lab_test.js index f1634c12949..bb7976ccfac 100644 --- a/erpnext/healthcare/doctype/lab_test/lab_test.js +++ b/erpnext/healthcare/doctype/lab_test/lab_test.js @@ -258,5 +258,5 @@ var calculate_age = function (dob) { var age = new Date(); age.setTime(ageMS); var years = age.getFullYear() - 1970; - return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)'; + return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`; }; diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js index 490f2475001..15e203a824f 100644 --- a/erpnext/healthcare/doctype/patient/patient.js +++ b/erpnext/healthcare/doctype/patient/patient.js @@ -50,7 +50,7 @@ frappe.ui.form.on('Patient', { $(frm.fields_dict['age_html'].wrapper).html(''); } if(frm.doc.dob){ - $(frm.fields_dict['age_html'].wrapper).html('AGE : ' + get_age(frm.doc.dob)); + $(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${get_age(frm.doc.dob)}`); } } }); @@ -65,7 +65,7 @@ frappe.ui.form.on('Patient', 'dob', function(frm) { } else { let age_str = get_age(frm.doc.dob); - $(frm.fields_dict['age_html'].wrapper).html('AGE : ' + age_str); + $(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${age_str}`); } } else { diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index 63dd8d4793a..8603f974c39 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -108,7 +108,7 @@ class Patient(Document): if self.dob: dob = getdate(self.dob) age = dateutil.relativedelta.relativedelta(getdate(), dob) - age_str = str(age.years) + ' year(s) ' + str(age.months) + ' month(s) ' + str(age.days) + ' day(s)' + age_str = str(age.years) + ' ' + _("Years(s)") + ' ' + str(age.months) + ' ' + _("Month(s)") + ' ' + str(age.days) + ' ' + _("Day(s)") return age_str def invoice_patient_registration(self): diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index 3d5073b13e7..750ecdb3546 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -596,5 +596,5 @@ let calculate_age = function(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)'; + return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`; }; diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js index e960f0a9c40..aaeaa692e63 100644 --- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js +++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js @@ -358,5 +358,5 @@ let calculate_age = function(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)'; + return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`; }; diff --git a/erpnext/healthcare/doctype/sample_collection/sample_collection.js b/erpnext/healthcare/doctype/sample_collection/sample_collection.js index 03903912358..ddf8285bc6d 100644 --- a/erpnext/healthcare/doctype/sample_collection/sample_collection.js +++ b/erpnext/healthcare/doctype/sample_collection/sample_collection.js @@ -36,5 +36,5 @@ var calculate_age = function(birth) { var age = new Date(); age.setTime(ageMS); var years = age.getFullYear() - 1970; - return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)'; + return `${years} ${__('Years(s)')} ${age.getMonth()} ${__('Month(s)')} ${age.getDate()} ${__('Day(s)')}`; }; From 358153b04b81e1fbf3fc92bae06369a31509a7f3 Mon Sep 17 00:00:00 2001 From: David Angulo Date: Tue, 9 Mar 2021 13:19:12 -0600 Subject: [PATCH 2/4] fix sider --- erpnext/healthcare/doctype/patient/patient.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js index 15e203a824f..49478cc3608 100644 --- a/erpnext/healthcare/doctype/patient/patient.js +++ b/erpnext/healthcare/doctype/patient/patient.js @@ -49,6 +49,7 @@ frappe.ui.form.on('Patient', { if(!frm.doc.dob){ $(frm.fields_dict['age_html'].wrapper).html(''); } + if(frm.doc.dob){ $(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${get_age(frm.doc.dob)}`); } From 06e99dfe7b1619aaced3157cc24785a0b845d5b5 Mon Sep 17 00:00:00 2001 From: David Angulo Date: Tue, 9 Mar 2021 13:23:48 -0600 Subject: [PATCH 3/4] fix sider --- erpnext/healthcare/doctype/patient/patient.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js index 49478cc3608..ff237d38243 100644 --- a/erpnext/healthcare/doctype/patient/patient.js +++ b/erpnext/healthcare/doctype/patient/patient.js @@ -46,11 +46,10 @@ frappe.ui.form.on('Patient', { } }, onload: function (frm) { - if(!frm.doc.dob){ + if(!frm.doc.dob) { $(frm.fields_dict['age_html'].wrapper).html(''); } - - if(frm.doc.dob){ + if(frm.doc.dob) { $(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${get_age(frm.doc.dob)}`); } } From fe0f46c5b3cfd6175872e0764c247beb25e3db4e Mon Sep 17 00:00:00 2001 From: David Angulo Date: Tue, 9 Mar 2021 13:28:08 -0600 Subject: [PATCH 4/4] fix sider --- erpnext/healthcare/doctype/patient/patient.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js index ff237d38243..bce42e51d07 100644 --- a/erpnext/healthcare/doctype/patient/patient.js +++ b/erpnext/healthcare/doctype/patient/patient.js @@ -46,10 +46,10 @@ frappe.ui.form.on('Patient', { } }, onload: function (frm) { - if(!frm.doc.dob) { + if (!frm.doc.dob) { $(frm.fields_dict['age_html'].wrapper).html(''); } - if(frm.doc.dob) { + if (frm.doc.dob) { $(frm.fields_dict['age_html'].wrapper).html(`${__('AGE')} : ${get_age(frm.doc.dob)}`); } }