From f4ea4586620df2e1eeec0de71b9c3e26cb622972 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 --- 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 8ec1acad04..e61656e459 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",