From 0abec034dfd233c21504d9f611f56f2c05296981 Mon Sep 17 00:00:00 2001 From: Jamsheer Date: Wed, 15 Nov 2017 13:53:50 +0530 Subject: [PATCH] Healthcare hotfix (#11586) * On Cancel Consultation - Open Appointment - Delete Medical Record * Add Filter on Account Selection - is_group: 0 * Patient Medical Record - List view Fixes * Update consultation.py --- .../doctype/consultation/consultation.py | 20 +++++++++++++------ .../healthcare_settings.js | 2 ++ .../patient_medical_record.json | 13 ++++++------ .../healthcare/doctype/physician/physician.js | 1 + 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/erpnext/healthcare/doctype/consultation/consultation.py b/erpnext/healthcare/doctype/consultation/consultation.py index 11b5ed233a..69d7ecbd01 100755 --- a/erpnext/healthcare/doctype/consultation/consultation.py +++ b/erpnext/healthcare/doctype/consultation/consultation.py @@ -8,12 +8,12 @@ from frappe import _ from frappe.model.document import Document from frappe.utils import getdate import json -from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account +from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account class Consultation(Document): def on_update(self): if(self.appointment): - frappe.db.set_value("Patient Appointment",self.appointment,"status","Closed") + frappe.db.set_value("Patient Appointment", self.appointment, "status", "Closed") update_consultation_to_medical_record(self) def after_insert(self): @@ -23,6 +23,11 @@ class Consultation(Document): if not self.diagnosis or not self.symptoms: frappe.throw("Diagnosis and Complaints cannot be left blank") + def on_cancel(self): + if(self.appointment): + frappe.db.set_value("Patient Appointment", self.appointment, "status", "Open") + delete_medical_record(self) + def set_sales_invoice_fields(company, patient): sales_invoice = frappe.new_doc("Sales Invoice") sales_invoice.customer = frappe.get_value("Patient", patient, "customer") @@ -87,8 +92,8 @@ def create_invoice_items(physician, invoice, company): item_line.qty = 1 item_line.uom = "Nos" item_line.conversion_factor = 1 - item_line.income_account = get_income_account(physician,company) - op_consulting_charge = frappe.get_value("Physician",physician,"op_consulting_charge") + item_line.income_account = get_income_account(physician, company) + op_consulting_charge = frappe.get_value("Physician", physician, "op_consulting_charge") if op_consulting_charge: item_line.rate = op_consulting_charge item_line.amount = op_consulting_charge @@ -107,10 +112,13 @@ def insert_consultation_to_medical_record(doc): medical_record.save(ignore_permissions=True) 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)) + medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s", (consultation.name)) if(medical_record_id[0][0]): subject = set_subject_field(consultation) - frappe.db.set_value("Patient Medical Record",medical_record_id[0][0],"subject",subject) + frappe.db.set_value("Patient Medical Record", medical_record_id[0][0], "subject", subject) + +def delete_medical_record(consultation): + frappe.db.sql("""delete from `tabPatient Medical Record` where reference_name = %s""", (consultation.name)) def set_subject_field(consultation): subject = "No Diagnosis " diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js index 75b0584f1f..8e98fee87e 100644 --- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js +++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.js @@ -9,6 +9,7 @@ frappe.ui.form.on('Healthcare Settings', { filters: { 'account_type': 'Receivable', 'company': d.company, + 'is_group': 0 } }; }); @@ -18,6 +19,7 @@ frappe.ui.form.on('Healthcare Settings', { filters: { 'root_type': 'Income', 'company': d.company, + 'is_group': 0 } }; }); diff --git a/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json b/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json index 9cbcf7b9b7..6edc0cc085 100644 --- a/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json +++ b/erpnext/healthcare/doctype/patient_medical_record/patient_medical_record.json @@ -56,7 +56,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, "label": "Patient", "length": 0, @@ -174,7 +174,7 @@ "ignore_xss_filter": 1, "in_filter": 0, "in_global_search": 0, - "in_list_view": 1, + "in_list_view": 0, "in_standard_filter": 0, "label": "Subject", "length": 0, @@ -236,7 +236,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, "label": "Datetime", "length": 0, @@ -266,7 +266,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, "label": "Reference DocType", "length": 0, @@ -297,7 +297,7 @@ "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, "label": "Reference Name", "length": 0, @@ -389,7 +389,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-10-04 16:09:55.597866", + "modified": "2017-11-15 12:48:59.945615", "modified_by": "Administrator", "module": "Healthcare", "name": "Patient Medical Record", @@ -425,6 +425,7 @@ "show_name_in_global_search": 1, "sort_field": "modified", "sort_order": "DESC", + "title_field": "patient", "track_changes": 1, "track_seen": 1 } \ No newline at end of file diff --git a/erpnext/healthcare/doctype/physician/physician.js b/erpnext/healthcare/doctype/physician/physician.js index 37389fe36a..c607f232fd 100755 --- a/erpnext/healthcare/doctype/physician/physician.js +++ b/erpnext/healthcare/doctype/physician/physician.js @@ -9,6 +9,7 @@ frappe.ui.form.on('Physician', { filters: { 'root_type': 'Income', 'company': d.company, + 'is_group': 0 } }; });