diff --git a/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json b/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json index 0d0de47233..5d49a5a1ec 100644 --- a/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json +++ b/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json @@ -3,7 +3,6 @@ "allow_import": 1, "allow_rename": 1, "creation": "2016-09-21 13:48:14.731437", - "default_view": "Tree", "description": "Healthcare Service Unit", "doctype": "DocType", "document_type": "Setup", @@ -243,7 +242,7 @@ ], "is_tree": 1, "links": [], - "modified": "2023-03-03 19:01:12.459553", + "modified": "2023-03-17 12:01:33.459553", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare Service Unit", diff --git a/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit_tree.js b/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit_tree.js index 570fce261b..24b8125f8b 100644 --- a/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit_tree.js +++ b/healthcare/healthcare/doctype/healthcare_service_unit/healthcare_service_unit_tree.js @@ -66,19 +66,19 @@ frappe.treeview_settings['Healthcare Service Unit'] = { ignore_fields: ['parent_healthcare_service_unit'], onrender: function (node) { if (node.data.occupied_of_available !== undefined) { - $("" + $("" + ' ' + node.data.occupied_of_available + '').insertBefore(node.$ul); } if (node.data && node.data.inpatient_occupancy !== undefined) { if (node.data.inpatient_occupancy == 1) { if (node.data.occupancy_status == 'Occupied') { - $("" + $("" + ' ' + node.data.occupancy_status + '').insertBefore(node.$ul); } if (node.data.occupancy_status == 'Vacant') { - $("" + $("" + ' ' + node.data.occupancy_status + '').insertBefore(node.$ul); } diff --git a/healthcare/healthcare/utils.py b/healthcare/healthcare/utils.py index 66117cc9c6..e1f36d4318 100644 --- a/healthcare/healthcare/utils.py +++ b/healthcare/healthcare/utils.py @@ -651,23 +651,25 @@ def get_children(doctype, parent=None, company=None, is_root=False): service_units = frappe.get_list(doctype, fields=fields, filters=filters) for each in service_units: - if each["expandable"] == 1: # group node - available_count = frappe.db.count( + if each["expandable"] != 1 or each["value"].startswith("All Healthcare Service Units"): + continue + + available_count = frappe.db.count( + "Healthcare Service Unit", + filters={"parent_healthcare_service_unit": each["value"], "inpatient_occupancy": 1}, + ) + + if available_count > 0: + occupied_count = frappe.db.count( "Healthcare Service Unit", - filters={"parent_healthcare_service_unit": each["value"], "inpatient_occupancy": 1}, + filters={ + "parent_healthcare_service_unit": each["value"], + "inpatient_occupancy": 1, + "occupancy_status": "Occupied", + }, ) - - if available_count > 0: - occupied_count = frappe.db.count( - "Healthcare Service Unit", - { - "parent_healthcare_service_unit": each["value"], - "inpatient_occupancy": 1, - "occupancy_status": "Occupied", - }, - ) - # set occupancy status of group node - each["occupied_of_available"] = str(occupied_count) + " Occupied of " + str(available_count) + # set occupancy status of group node + each["occupied_of_available"] = f"{str(occupied_count)} Occupied of {str(available_count)}" return service_units diff --git a/healthcare/hooks.py b/healthcare/hooks.py index 82b1a172c5..0db002babe 100644 --- a/healthcare/hooks.py +++ b/healthcare/hooks.py @@ -283,3 +283,7 @@ standard_queries = { "Healthcare Practitioner": "healthcare.healthcare.doctype.healthcare_practitioner.healthcare_practitioner.get_practitioner_list" } + +treeviews = [ + "Healthcare Service Unit", +]