fix: date validation on inpatient record, else condition removing on clinical prcd templ which is not req
diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py
index 141329b..7cec362 100644
--- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py
+++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py
@@ -63,10 +63,11 @@
item_code=%s""",(self.template, self.rate, self.item))
def create_item_from_template(doc):
+ disabled = 1
+
if(doc.is_billable == 1):
disabled = 0
- else:
- disabled = 1
+
#insert item
item = frappe.get_doc({
"doctype": "Item",
diff --git a/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py b/erpnext/healthcare/doctype/inpatient_record/inpatient_record.py
index c107cd7..835b38b 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
from frappe import _
-from frappe.utils import today, now_datetime
+from frappe.utils import today, now_datetime, getdate
from frappe.model.document import Document
from frappe.desk.reportview import get_match_cond
@@ -15,11 +15,20 @@
frappe.db.set_value("Patient", self.patient, "inpatient_record", self.name)
def validate(self):
+ self.validate_dates()
self.validate_already_scheduled_or_admitted()
if self.status == "Discharged":
frappe.db.set_value("Patient", self.patient, "inpatient_status", None)
frappe.db.set_value("Patient", self.patient, "inpatient_record", None)
+ def validate_dates(self):
+ if (getdate(self.scheduled_date) < getdate(today())) or \
+ (getdate(self.admitted_datetime) < getdate(today())):
+ frappe.throw(_("Scheduled and Admitted dates can not be less than today"))
+ if (getdate(self.expected_discharge) < getdate(self.scheduled_date)) or \
+ (getdate(self.discharge_date) < getdate(self.scheduled_date)):
+ frappe.throw(_("Expected and Discharge dates cannot be less than Admission Schedule date"))
+
def validate_already_scheduled_or_admitted(self):
query = """
select name, status