From bd63f0056a2344ac8ce45ced25da6262b8dbf3e6 Mon Sep 17 00:00:00 2001 From: Jamsheer Date: Fri, 4 May 2018 18:13:28 +0530 Subject: [PATCH] Patient medical record updation and deletion fixes (#13891) --- erpnext/healthcare/doctype/consultation/consultation.py | 4 +++- erpnext/healthcare/doctype/lab_test/lab_test.py | 2 +- erpnext/healthcare/doctype/vital_signs/vital_signs.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/healthcare/doctype/consultation/consultation.py b/erpnext/healthcare/doctype/consultation/consultation.py index 69d7ecbd01..ebf80d69f4 100755 --- a/erpnext/healthcare/doctype/consultation/consultation.py +++ b/erpnext/healthcare/doctype/consultation/consultation.py @@ -113,9 +113,11 @@ def insert_consultation_to_medical_record(doc): def update_consultation_to_medical_record(consultation): medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s", (consultation.name)) - if(medical_record_id[0][0]): + if medical_record_id and medical_record_id[0][0]: subject = set_subject_field(consultation) frappe.db.set_value("Patient Medical Record", medical_record_id[0][0], "subject", subject) + else: + insert_consultation_to_medical_record(consultation) def delete_medical_record(consultation): frappe.db.sql("""delete from `tabPatient Medical Record` where reference_name = %s""", (consultation.name)) diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py index 6fd9535ecc..3ad8b53a2e 100644 --- a/erpnext/healthcare/doctype/lab_test/lab_test.py +++ b/erpnext/healthcare/doctype/lab_test/lab_test.py @@ -244,7 +244,7 @@ def insert_lab_test_to_medical_record(doc): def delete_lab_test_from_medical_record(self): medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s",(self.name)) - if(medical_record_id[0][0]): + if medical_record_id and medical_record_id[0][0]: frappe.delete_doc("Patient Medical Record", medical_record_id[0][0]) def create_item_line(test_code, sales_invoice): diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.py b/erpnext/healthcare/doctype/vital_signs/vital_signs.py index 436f79fcb9..dea848de79 100644 --- a/erpnext/healthcare/doctype/vital_signs/vital_signs.py +++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.py @@ -27,7 +27,7 @@ def insert_vital_signs_to_medical_record(doc): def delete_vital_signs_from_medical_record(doc): medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s",(doc.name)) - if(medical_record_id[0][0]): + if medical_record_id and medical_record_id[0][0]: frappe.delete_doc("Patient Medical Record", medical_record_id[0][0]) def set_subject_field(doc):