From 0de53c589d5f71900887696480f41bd1ca07b96b Mon Sep 17 00:00:00 2001 From: Aravind Date: Fri, 18 Oct 2024 11:02:17 +0530 Subject: [PATCH] fix(Patient Encounter): fetch department from lab test template for new service request (cherry picked from commit b5ce004823fc7812665a551d28e5dda8e98c9822) --- healthcare/public/js/healthcare_note.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/healthcare/public/js/healthcare_note.js b/healthcare/public/js/healthcare_note.js index c9737a19f1..0370cf6674 100644 --- a/healthcare/public/js/healthcare_note.js +++ b/healthcare/public/js/healthcare_note.js @@ -257,14 +257,23 @@ healthcare.Orders = class Orders { "options": "order_template_type", "depends_on": "eval:doc.order_template_type;", "reqd": 1, + onchange: function(frm) { + let field_name = (d.get_value("order_template_type") == "Lab Test Template") ? "department" : "medical_department"; + frappe.db.get_value(d.get_value("order_template_type"), d.get_value("order_template"), field_name) + .then(r => { + if (r.message) { + d.set_value("department", r.message[field_name]); + } + }); + } }, { - "fetch_from": "order_template.medical_department", "fieldname": "department", "fieldtype": "Link", "label": "Department", "options": "Medical Department", - "depends_on": "eval:doc.order_template_type=='Clinical Procedure Template';", + "depends_on": "eval: doc.order_template", + "read_only": 1, }, { "fieldname": "column_break_4",