diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py index ed9eae3529..ad32e94631 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py @@ -69,33 +69,10 @@ def validate_service_item(item, msg): def get_practitioner_list(doctype, txt, searchfield, start, page_len, filters=None): fields = ["name", "first_name", "mobile_phone"] - match_conditions = build_match_conditions("Healthcare Practitioner") - match_conditions = "and {}".format(match_conditions) if match_conditions else "" - if filters: - filter_conditions = get_filters_cond(doctype, filters, []) - match_conditions += "{}".format(filter_conditions) + filters = { + 'name': ("like", "%%%s%%" % txt) + } - return frappe.db.sql("""select %s from `tabHealthcare Practitioner` where docstatus < 2 - and (%s like %s or first_name like %s) - and active = 1 - {match_conditions} - order by - case when name like %s then 0 else 1 end, - case when first_name like %s then 0 else 1 end, - name, first_name limit %s, %s""".format( - match_conditions=match_conditions) % - ( - ", ".join(fields), - frappe.db.escape(searchfield), - "%s", "%s", "%s", "%s", "%s", "%s" - ), - ( - "%%%s%%" % frappe.db.escape(txt), - "%%%s%%" % frappe.db.escape(txt), - "%%%s%%" % frappe.db.escape(txt), - "%%%s%%" % frappe.db.escape(txt), - start, - page_len - ) - ) + return frappe.get_all("Healthcare Practitioner", fields = fields, + filters = filters, start=start, page_length=page_len, order_by="name, first_name", as_list=1)