From 197165ff4051cf1decff54f63f7b64177cbd96f6 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 26 Mar 2020 17:29:50 +0530 Subject: [PATCH] fix: codacy --- .../desk_page/healthcare/healthcare.json | 7 +++-- .../clinical_procedure/clinical_procedure.js | 4 +-- .../clinical_procedure/clinical_procedure.py | 2 +- .../clinical_procedure_list.js | 6 ++--- .../test_clinical_procedure.py | 3 +-- .../clinical_procedure_template.py | 1 - .../doctype/fee_validity/fee_validity.py | 2 -- .../doctype/fee_validity/test_fee_validity.py | 3 +-- .../healthcare_practitioner.py | 3 +-- .../healthcare_service_unit.json | 7 +++-- .../healthcare_service_unit_type.py | 3 ++- erpnext/healthcare/doctype/patient/patient.py | 2 +- .../patient_appointment.py | 4 +-- .../test_patient_appointment.py | 6 ++--- .../patient_encounter/patient_encounter.py | 4 +-- .../doctype/vital_signs/vital_signs.js | 4 --- .../patient_appointment_analytics.py | 1 + erpnext/healthcare/utils.py | 5 ++-- .../patient_registration.js | 2 +- .../patient_registration.json | 26 +++++++++---------- 20 files changed, 42 insertions(+), 53 deletions(-) diff --git a/erpnext/healthcare/desk_page/healthcare/healthcare.json b/erpnext/healthcare/desk_page/healthcare/healthcare.json index 320fd742ae..54798ba08f 100644 --- a/erpnext/healthcare/desk_page/healthcare/healthcare.json +++ b/erpnext/healthcare/desk_page/healthcare/healthcare.json @@ -40,8 +40,7 @@ "charts": [ { "chart_name": "Patient Appointments", - "label": "Patient Appointments", - "size": "Full" + "label": "Patient Appointments" } ], "charts_label": "", @@ -54,7 +53,7 @@ "idx": 0, "is_standard": 1, "label": "Healthcare", - "modified": "2020-03-12 16:30:36.952979", + "modified": "2020-03-26 16:10:44.629795", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare", @@ -81,7 +80,7 @@ "format": "{} Vacant", "is_query_report": 0, "link_to": "Healthcare Service Unit", - "stats_filter": "{\n \"occupancy_status\": \"Vacant\"\n}", + "stats_filter": "{\n \"occupancy_status\": \"Vacant\",\n \"is_group\": 0\n}", "type": "DocType" }, { diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js index 2d17f751ef..5f36bdd95c 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js +++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js @@ -84,7 +84,7 @@ frappe.ui.form.on('Clinical Procedure', { if (r.message) { frappe.show_alert({ message: __('Stock Entry {0} created', - ['' + r.message + '']), + ['' + r.message + '']), indicator: 'green' }); frm.reload_doc(); @@ -261,7 +261,7 @@ frappe.ui.form.on('Clinical Procedure', { }, callback: function(data) { if (data.message) { - frm.doc.items = [] + frm.doc.items = []; $.each(data.message, function(i, v) { let item = frm.add_child('items'); item.item_code = v.item_code; diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py index 181c0e356c..db3afc8807 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py +++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import cint, flt, nowdate, nowtime, cstr +from frappe.utils import flt, nowdate, nowtime, cstr from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_account from erpnext.healthcare.doctype.lab_test.lab_test import create_sample_doc from erpnext.stock.stock_ledger import get_previous_sle diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure_list.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure_list.js index 44646a253a..c8601f9677 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure_list.js +++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure_list.js @@ -2,9 +2,9 @@ frappe.listview_settings['Clinical Procedure'] = { get_indicator: function(doc) { var colors = { 'Completed': 'green', - 'In Progress': 'orange', - 'Pending': 'orange', - 'Cancelled': 'grey' + 'In Progress': 'orange', + 'Pending': 'orange', + 'Cancelled': 'grey' }; return [__(doc.status), colors[doc.status], 'status,=,' + doc.status]; } diff --git a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py index 9c65e12fa1..207351ff20 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py +++ b/erpnext/healthcare/doctype/clinical_procedure/test_clinical_procedure.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import unittest import frappe -from frappe.utils import nowdate from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_healthcare_docs, create_clinical_procedure_template class TestClinicalProcedure(unittest.TestCase): @@ -33,7 +32,7 @@ class TestClinicalProcedure(unittest.TestCase): procedure = create_procedure(procedure_template, patient, practitioner) result = procedure.start_procedure() if result == 'insufficient stock': - material_receipt = procedure.make_material_receipt(submit=True) + procedure.make_material_receipt(submit=True) result = procedure.start_procedure() self.assertEqual(procedure.status, 'In Progress') result = procedure.complete_procedure() 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 4b2d96e589..bd9a5ac3d9 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py +++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py @@ -7,7 +7,6 @@ import frappe, json from frappe import _ from frappe.model.document import Document from frappe.model.rename_doc import rename_doc -from frappe.utils import nowdate class ClinicalProcedureTemplate(Document): def validate(self): diff --git a/erpnext/healthcare/doctype/fee_validity/fee_validity.py b/erpnext/healthcare/doctype/fee_validity/fee_validity.py index 594d2b7ffa..058bc97192 100644 --- a/erpnext/healthcare/doctype/fee_validity/fee_validity.py +++ b/erpnext/healthcare/doctype/fee_validity/fee_validity.py @@ -14,8 +14,6 @@ class FeeValidity(Document): self.set_start_date() def update_status(self): - valid_till = getdate(self.valid_till) - start_date = getdate(self.start_date) if self.visited >= self.max_visits: self.status = 'Completed' else: diff --git a/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py b/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py index 237034b216..fbb2530611 100644 --- a/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py +++ b/erpnext/healthcare/doctype/fee_validity/test_fee_validity.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import frappe import unittest -from frappe.utils.make_random import get_random -from frappe.utils import nowdate, add_days, getdate +from frappe.utils import nowdate, add_days from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_healthcare_docs, create_appointment test_dependencies = ["Company"] diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py index 9bc68b6c5c..0c13b6af9d 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document -from frappe import throw, _ -from frappe.utils import cstr +from frappe import _ from erpnext.accounts.party import validate_party_accounts from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address from frappe.model.naming import append_number_if_name_exists diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json index 07efd43aa4..ea4ae846f7 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json +++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json @@ -9,6 +9,7 @@ "doctype": "DocType", "document_type": "Setup", "editable_grid": 1, + "engine": "InnoDB", "field_order": [ "healthcare_service_unit_name", "parent_healthcare_service_unit", @@ -100,7 +101,7 @@ "fieldtype": "Select", "label": "Occupancy Status", "no_copy": 1, - "options": "Vacant\nOccupied", + "options": "\nVacant\nOccupied", "read_only": 1 }, { @@ -158,13 +159,11 @@ "report_hide": 1 } ], - "is_tree": 1, "links": [], - "modified": "2020-01-30 18:03:29.031351", + "modified": "2020-03-26 16:13:08.675952", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare Service Unit", - "nsm_parent_field": "parent_healthcare_service_unit", "owner": "Administrator", "permissions": [ { diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py index 49d06d5963..196cd04790 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py @@ -49,7 +49,8 @@ class HealthcareServiceUnitType(Document): def item_price_exists(doc): - if frappe.db.exists({'doctype': 'Item Price', 'item_code': doc.item_code}): + item_price = frappe.db.exists({'doctype': 'Item Price', 'item_code': doc.item_code}) + if len(item_price): return item_price[0][0] return False diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index fc63b19976..071c5b1169 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import cint, cstr, getdate, flt +from frappe.utils import cint, cstr, getdate import dateutil from frappe.model.naming import set_name_by_naming_series from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account, send_registration_sms diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py index 16ab90844d..9f77738573 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document import json -from frappe.utils import getdate, add_days, get_time +from frappe.utils import getdate, get_time from frappe.model.mapper import get_mapped_doc from frappe import _ import datetime @@ -174,7 +174,7 @@ def cancel_appointment(appointment_id): if sales_invoice and cancel_sales_invoice(sales_invoice): msg = _('Appointment {0} and Sales Invoice {1} cancelled').format(appointment.name, sales_invoice.name) else: - msg = _('Appointment Cancelled. Please review and cancel the invoice {0}').format(fee_validity.ref_invoice) + msg = _('Appointment Cancelled. Please review and cancel the invoice {0}').format(sales_invoice.name) else: fee_validity = manage_fee_validity(appointment) msg = _('Appointment Cancelled.') diff --git a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py index 025f052658..2a2f0455f6 100644 --- a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import unittest import frappe from erpnext.healthcare.doctype.patient_appointment.patient_appointment import update_status -from frappe.utils import nowdate, add_days, getdate +from frappe.utils import nowdate, add_days from frappe.utils.make_random import get_random class TestPatientAppointment(unittest.TestCase): @@ -72,13 +72,13 @@ def create_healthcare_docs(): medical_department = frappe.new_doc('Medical Department') medical_department.department = '_Test Medical Department' medical_department.save(ignore_permissions=True) - department = medical_department.name + medical_department = medical_department.name if not practitioner: practitioner = frappe.new_doc('Healthcare Practitioner') practitioner.first_name = '_Test Healthcare Practitioner' practitioner.gender = 'Female' - practitioner.department = department + practitioner.department = medical_department practitioner.op_consulting_charge = 500 practitioner.save(ignore_permissions=True) practitioner = practitioner.name diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py index 2aea072d88..c2258c8fe3 100644 --- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py +++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py @@ -14,14 +14,14 @@ class PatientEncounter(Document): update_encounter_medical_record(self) def after_insert(self): - insert_encounter_medical_record(self) + insert_encounter_to_medical_record(self) def on_cancel(self): if self.appointment: frappe.db.set_value('Patient Appointment', self.appointment, 'status', 'Open') delete_medical_record(self) -def insert_encounter_medical_record(doc): +def insert_encounter_to_medical_record(doc): subject = set_subject_field(doc) medical_record = frappe.new_doc('Patient Medical Record') medical_record.patient = doc.patient diff --git a/erpnext/healthcare/doctype/vital_signs/vital_signs.js b/erpnext/healthcare/doctype/vital_signs/vital_signs.js index a2290bf22b..78509e0323 100644 --- a/erpnext/healthcare/doctype/vital_signs/vital_signs.js +++ b/erpnext/healthcare/doctype/vital_signs/vital_signs.js @@ -2,10 +2,6 @@ // For license information, please see license.txt frappe.ui.form.on('Vital Signs', { - refresh: function(frm) { - - }, - height: function(frm) { if (frm.doc.height && frm.doc.weight) { calculate_bmi(frm); diff --git a/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py b/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py index f2cfd757c0..16af55d74d 100644 --- a/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py +++ b/erpnext/healthcare/report/patient_appointment_analytics/patient_appointment_analytics.py @@ -13,6 +13,7 @@ def execute(filters=None): class Analytics(object): def __init__(self, filters=None): + """Patient Appointment Analytics Report""" self.filters = frappe._dict(filters or {}) self.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] self.get_period_date_ranges() diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py index 42d37fe3fc..7e319687d8 100644 --- a/erpnext/healthcare/utils.py +++ b/erpnext/healthcare/utils.py @@ -4,10 +4,9 @@ from __future__ import unicode_literals import frappe -import datetime from frappe import _ import math -from frappe.utils import time_diff_in_hours, rounded, getdate, add_days +from frappe.utils import time_diff_in_hours, rounded from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_income_account from erpnext.healthcare.doctype.fee_validity.fee_validity import create_fee_validity from erpnext.healthcare.doctype.lab_test.lab_test import create_multiple @@ -171,7 +170,7 @@ def get_clinical_procedures_to_invoice(patient): for prescription in procedure_prescriptions: if frappe.db.get_value('Clinical Procedure Template', prescription.procedure, 'is_billable'): - items_to_invoice.append({ + clinical_procedures_to_invoice.append({ 'reference_type': 'Procedure Prescription', 'reference_name': prescription.name, 'service': frappe.db.get_value('Clinical Procedure Template', prescription.procedure, 'item') diff --git a/erpnext/healthcare/web_form/patient_registration/patient_registration.js b/erpnext/healthcare/web_form/patient_registration/patient_registration.js index 699703c579..7da3f1fb41 100644 --- a/erpnext/healthcare/web_form/patient_registration/patient_registration.js +++ b/erpnext/healthcare/web_form/patient_registration/patient_registration.js @@ -1,3 +1,3 @@ frappe.ready(function() { // bind events here -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/erpnext/healthcare/web_form/patient_registration/patient_registration.json b/erpnext/healthcare/web_form/patient_registration/patient_registration.json index 46b5fb7183..9ed92de16f 100644 --- a/erpnext/healthcare/web_form/patient_registration/patient_registration.json +++ b/erpnext/healthcare/web_form/patient_registration/patient_registration.json @@ -19,7 +19,7 @@ "is_standard": 1, "login_required": 0, "max_attachment_size": 0, - "modified": "2020-03-03 01:07:46.147376", + "modified": "2020-03-26 17:25:15.361918", "modified_by": "Administrator", "module": "Healthcare", "name": "patient-registration", @@ -306,12 +306,12 @@ "allow_read_on_all_link_options": 0, "default": "0", "fieldname": "tobacco_past_use", - "fieldtype": "Select", + "fieldtype": "Check", "hidden": 0, - "label": "Do you have a history of Tobacco Consumption?", + "label": "Check if you have a history of Tobacco Consumption", "max_length": 0, "max_value": 0, - "options": "Yes\nNo", + "options": "", "read_only": 0, "reqd": 0, "show_in_filter": 0 @@ -320,12 +320,12 @@ "allow_read_on_all_link_options": 0, "default": "0", "fieldname": "tobacco_current_use", - "fieldtype": "Select", + "fieldtype": "Check", "hidden": 0, - "label": "Do you consume Tobacco in the present? ", + "label": "Check if you consume Tobacco", "max_length": 0, "max_value": 0, - "options": "Yes\nNo", + "options": "", "read_only": 0, "reqd": 0, "show_in_filter": 0 @@ -334,12 +334,12 @@ "allow_read_on_all_link_options": 0, "default": "0", "fieldname": "alcohol_past_use", - "fieldtype": "Select", + "fieldtype": "Check", "hidden": 0, - "label": "Do you have a history of Alcohol Consumption?", + "label": "Check if you have a history of Alcohol Consumption", "max_length": 0, "max_value": 0, - "options": "Yes\nNo", + "options": "", "read_only": 0, "reqd": 0, "show_in_filter": 0 @@ -348,12 +348,12 @@ "allow_read_on_all_link_options": 0, "default": "0", "fieldname": "alcohol_current_use", - "fieldtype": "Select", + "fieldtype": "Check", "hidden": 0, - "label": "Do you consume Alcohol in the present? ", + "label": "Check if you consume Alcohol", "max_length": 0, "max_value": 0, - "options": "Yes\nNo", + "options": "", "read_only": 0, "reqd": 0, "show_in_filter": 0