From 7190e1e4bbe27a46b6c47e63c80e34d76b917d55 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 3 Nov 2020 13:45:12 +0530 Subject: [PATCH] fix: Inpatient Medication Order and Entry fixes --- .../inpatient_medication_entry.js | 13 +++++++++++++ .../inpatient_medication_entry.json | 4 +++- .../inpatient_medication_entry.py | 6 +++++- .../inpatient_medication_order.js | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js index b953b8adff..f523cf21bd 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.js @@ -21,6 +21,19 @@ frappe.ui.form.on('Inpatient Medication Entry', { } }; }); + + frm.set_query('warehouse', () => { + return { + filters: { + company: frm.doc.company + } + }; + }); + }, + + patient: function(frm) { + if (frm.doc.patient) + frm.set_value('service_unit', ''); }, get_medication_orders: function(frm) { diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json index 5d80251b71..dd4c423a9e 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.json @@ -67,6 +67,7 @@ }, { "collapsible": 1, + "collapsible_depends_on": "eval: doc.__islocal", "fieldname": "filters_section", "fieldtype": "Section Break", "label": "Filters" @@ -93,6 +94,7 @@ "options": "Patient" }, { + "depends_on": "eval:!doc.patient", "fieldname": "service_unit", "fieldtype": "Link", "label": "Healthcare Service Unit", @@ -178,7 +180,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-09-30 23:40:45.528715", + "modified": "2020-11-03 13:22:37.820707", "modified_by": "Administrator", "module": "Healthcare", "name": "Inpatient Medication Entry", diff --git a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py index 2385893109..23e75196ee 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py +++ b/erpnext/healthcare/doctype/inpatient_medication_entry/inpatient_medication_entry.py @@ -199,6 +199,7 @@ class InpatientMedicationEntry(Document): def get_pending_medication_orders(entry): filters, values = get_filters(entry) + to_remove = [] data = frappe.db.sql(""" SELECT @@ -225,7 +226,10 @@ def get_pending_medication_orders(entry): doc['service_unit'] = get_current_healthcare_service_unit(inpatient_record) if entry.service_unit and doc.service_unit != entry.service_unit: - data.remove(doc) + to_remove.append(doc) + + for doc in to_remove: + data.remove(doc) return data diff --git a/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.js b/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.js index c51f3cf882..690e2e7a90 100644 --- a/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.js +++ b/erpnext/healthcare/doctype/inpatient_medication_order/inpatient_medication_order.js @@ -12,7 +12,8 @@ frappe.ui.form.on('Inpatient Medication Order', { frm.set_query('patient', () => { return { filters: { - 'inpatient_record': ['!=', ''] + 'inpatient_record': ['!=', ''], + 'inpatient_status': 'Admitted' } }; });