From 7cbc7946af0e2b8506657583ebfb07579a39c7fc Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 28 Jul 2020 14:11:12 +0530 Subject: [PATCH 1/2] fix: validate check out and check in time for inpatient occupancy --- .../doctype/inpatient_record/inpatient_record.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py index cf63b65f4d..cbcb24faee 100644 --- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe, json from frappe import _ -from frappe.utils import today, now_datetime, getdate +from frappe.utils import today, now_datetime, getdate, get_datetime from frappe.model.document import Document from frappe.desk.reportview import get_match_cond @@ -30,6 +30,11 @@ class InpatientRecord(Document): (getdate(self.discharge_ordered_date) < getdate(self.scheduled_date)): frappe.throw(_('Expected and Discharge dates cannot be less than Admission Schedule date')) + for entry in self.inpatient_occupancies: + if entry.check_in and entry.check_out and \ + get_datetime(entry.check_in) > get_datetime(entry.check_out): + frappe.throw(_('Check Out datetime cannot be less than Check In datetime for entry #{0}').format(entry.idx)) + def validate_already_scheduled_or_admitted(self): query = """ select name, status From a695971596d715f14c537ad4960af148336a157b Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Tue, 28 Jul 2020 20:15:29 +0530 Subject: [PATCH 2/2] fix: show the standard validation message Co-authored-by: Marica --- erpnext/healthcare/doctype/inpatient_record/inpatient_record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py index cbcb24faee..69356baad5 100644 --- a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py +++ b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py @@ -33,7 +33,7 @@ class InpatientRecord(Document): for entry in self.inpatient_occupancies: if entry.check_in and entry.check_out and \ get_datetime(entry.check_in) > get_datetime(entry.check_out): - frappe.throw(_('Check Out datetime cannot be less than Check In datetime for entry #{0}').format(entry.idx)) + frappe.throw(_('Row #{0}: Check Out datetime cannot be less than Check In datetime').format(entry.idx)) def validate_already_scheduled_or_admitted(self): query = """