diff --git a/erpnext/config/healthcare.py b/erpnext/config/healthcare.py index 756d22e416b..2b461273ad4 100644 --- a/erpnext/config/healthcare.py +++ b/erpnext/config/healthcare.py @@ -2,131 +2,68 @@ from __future__ import unicode_literals from frappe import _ def get_data(): - return [ - { - "label": _("Consultation"), - "icon": "icon-star", - "items": [ - { - "type": "doctype", - "name": "Patient Appointment", - "label": _("Patient Appointment"), - }, - { - "type": "doctype", - "name": "Patient Encounter", - "label": _("Patient Encounter"), - }, - { - "type": "doctype", - "name": "Vital Signs", - "label": _("Vital Signs"), - "description": _("Record Patient Vitals"), - }, - { - "type": "page", - "name": "patient_history", - "label": _("Patient History"), - }, - { - "type": "page", - "name": "appointment-analytic", - "label": _("Appointment Analytics"), - }, - { - "type": "doctype", - "name": "Clinical Procedure", - "label": _("Clinical Procedure"), - }, - { - "type": "doctype", - "name": "Inpatient Record", - "label": _("Inpatient Record"), - } - ] - }, - { - "label": _("Laboratory"), - "icon": "icon-list", - "items": [ - { - "type": "doctype", - "name": "Lab Test", - "label": _("Lab Test"), - }, - { - "type": "doctype", - "name": "Sample Collection", - "label": _("Sample Collection"), - }, - { - "type": "report", - "name": "Lab Test Report", - "is_query_report": True, - "label": _("Lab Test Report"), - } - ] - }, { "label": _("Masters"), - "icon": "icon-list", "items": [ { "type": "doctype", "name": "Patient", "label": _("Patient"), - "onboard": 1, + "onboard": 1 }, { "type": "doctype", "name": "Healthcare Practitioner", "label": _("Healthcare Practitioner"), - "onboard": 1, + "onboard": 1 }, { "type": "doctype", "name": "Practitioner Schedule", "label": _("Practitioner Schedule"), - }, - { - "type": "doctype", - "name": "Medical Code Standard", - "label": _("Medical Code Standard"), - }, - { - "type": "doctype", - "name": "Medical Code", - "label": _("Medical Code"), - "onboard": 1, - }, - { - "type": "doctype", - "name": "Healthcare Service Unit", - "label": _("Healthcare Service Unit") - } - ] - }, - { - "label": _("Settings"), - "icon": "icon-cog", - "items": [ - { - "type": "doctype", - "name": "Healthcare Settings", - "label": _("Healthcare Settings"), - "onboard": 1, + "onboard": 1 }, { "type": "doctype", "name": "Medical Department", "label": _("Medical Department"), }, + { + "type": "doctype", + "name": "Healthcare Service Unit Type", + "label": _("Healthcare Service Unit Type") + }, + { + "type": "doctype", + "name": "Healthcare Service Unit", + "label": _("Healthcare Service Unit") + }, + { + "type": "doctype", + "name": "Medical Code Standard", + "label": _("Medical Code Standard") + }, + { + "type": "doctype", + "name": "Medical Code", + "label": _("Medical Code") + } + ] + }, + { + "label": _("Consultation Setup"), + "items": [ { "type": "doctype", "name": "Appointment Type", "label": _("Appointment Type"), }, + { + "type": "doctype", + "name": "Clinical Procedure Template", + "label": _("Clinical Procedure Template") + }, { "type": "doctype", "name": "Prescription Dosage", @@ -137,6 +74,36 @@ def get_data(): "name": "Prescription Duration", "label": _("Prescription Duration") }, + { + "type": "doctype", + "name": "Antibiotic", + "label": _("Antibiotic") + } + ] + }, + { + "label": _("Consultation"), + "items": [ + { + "type": "doctype", + "name": "Patient Appointment", + "label": _("Patient Appointment") + }, + { + "type": "doctype", + "name": "Clinical Procedure", + "label": _("Clinical Procedure") + }, + { + "type": "doctype", + "name": "Patient Encounter", + "label": _("Patient Encounter") + }, + { + "type": "doctype", + "name": "Vital Signs", + "label": _("Vital Signs") + }, { "type": "doctype", "name": "Complaint", @@ -147,40 +114,104 @@ def get_data(): "name": "Diagnosis", "label": _("Diagnosis") }, + { + "type": "doctype", + "name": "Fee Validity", + "label": _("Fee Validity") + } + ] + }, + { + "label": _("Settings"), + "items": [ + { + "type": "doctype", + "name": "Healthcare Settings", + "label": _("Healthcare Settings"), + "onboard": 1 + } + ] + }, + { + "label": _("Laboratory Setup"), + "items": [ + { + "type": "doctype", + "name": "Lab Test Template", + "label": _("Lab Test Template") + }, { "type": "doctype", "name": "Lab Test Sample", - "label": _("Lab Test Sample"), + "label": _("Lab Test Sample") }, { "type": "doctype", "name": "Lab Test UOM", "label": _("Lab Test UOM") }, - { - "type": "doctype", - "name": "Antibiotic", - "label": _("Antibiotic") - }, { "type": "doctype", "name": "Sensitivity", "label": _("Sensitivity") + } + ] + }, + { + "label": _("Laboratory"), + "items": [ + { + "type": "doctype", + "name": "Lab Test", + "label": _("Lab Test") }, { "type": "doctype", - "name": "Lab Test Template", - "label": _("Lab Test Template") + "name": "Sample Collection", + "label": _("Sample Collection") }, { "type": "doctype", - "name": "Clinical Procedure Template", - "label": _("Clinical Procedure Template"), + "name": "Dosage Form", + "label": _("Dosage Form") + } + ] + }, + { + "label": _("Records and History"), + "items": [ + { + "type": "page", + "name": "patient_history", + "label": _("Patient History"), }, { "type": "doctype", - "name": "Healthcare Service Unit Type", - "label": _("Healthcare Service Unit Type") + "name": "Patient Medical Record", + "label": _("Patient Medical Record") + }, + { + "type": "doctype", + "name": "Inpatient Record", + "label": _("Inpatient Record") + } + ] + }, + { + "label": _("Reports"), + "items": [ + { + "type": "report", + "is_query_report": True, + "name": "Patient Appointment Analytics", + "doctype": "Patient Appointment" + }, + { + "type": "report", + "is_query_report": True, + "name": "Lab Test Report", + "doctype": "Lab Test", + "label": _("Lab Test Report") } ] } diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index f9f66680b92..4c1509e441a 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -108,8 +108,8 @@ frappe.ui.form.on('Patient Appointment', { }, __('Create')); } - frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'automate_appointment_invoicing', (settings) => { - if (settings.automate_appointment_invoicing) { + frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, ['automate_appointment_invoicing'], (settings) => { + if (settings.automate_appointment_invoicing == 1) { frm.set_df_property('mode_of_payment', 'hidden', 0); frm.set_df_property('paid_amount', 'hidden', 0); frm.set_df_property('mode_of_payment', 'reqd', 1); diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py index 40db1b7d78c..639621cfd32 100644 --- a/erpnext/healthcare/utils.py +++ b/erpnext/healthcare/utils.py @@ -320,7 +320,7 @@ def set_invoiced(item, method, ref_invoice=None): else: manage_fee_validity(item.reference_dn, method, ref_invoice) dt_from_appointment = 'Patient Encounter' - manage_doc_for_appoitnment(dt_from_appointment, item.reference_dn, invoiced) + manage_doc_for_appointment(dt_from_appointment, item.reference_dn, invoiced) elif item.reference_dt == 'Lab Prescription': manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, 'Lab Test', 'lab_test_created') @@ -331,7 +331,7 @@ def set_invoiced(item, method, ref_invoice=None): def validate_invoiced_on_submit(item): if item.reference_dt == 'Clinical Procedure' and get_healthcare_service_item('clinical_procedure_consumable_item') == item.item_code: - is_invoiced = frappe.db.get_value(item.reference_dt, item.reference_dn, 'consumption_invoiced') + is_invoiced = frappe.db.get_value(item.reference_dt, item.reference_dn, 'consumption_invoiced') else: is_invoiced = frappe.db.get_value(item.reference_dt, item.reference_dn, 'invoiced') if is_invoiced: @@ -380,7 +380,7 @@ def manage_fee_validity(appointment_name, method, ref_invoice=None): fee_validity = create_fee_validity(appointment_doc.practitioner, appointment_doc.patient, appointment_doc.appointment_date, ref_invoice) visited = fee_validity.visited - mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc) + mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc, visited) if method == 'on_cancel': ref_invoice_in_fee_validity = frappe.db.get_value('Fee Validity', fee_validity.name, 'ref_invoice') @@ -388,7 +388,7 @@ def manage_fee_validity(appointment_name, method, ref_invoice=None): frappe.delete_doc('Fee Validity', fee_validity.name) -def mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc): +def mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment_doc, visited): if method == 'on_cancel': invoiced = True else: @@ -405,13 +405,13 @@ def mark_appointments_as_invoiced(fee_validity, ref_invoice, method, appointment visited = 0 frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited) frappe.db.set_value('Patient Appointment', appointment.name, 'invoiced', False) - manage_doc_for_appoitnment('Patient Encounter', appointment.name, False) + manage_doc_for_appointment('Patient Encounter', appointment.name, False) elif method == 'on_submit' and int(fee_validity.max_visits) > visit: if ref_invoice == fee_validity.ref_invoice: visited += 1 frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited) frappe.db.set_value('Patient Appointment', appointment.name, 'invoiced', True) - manage_doc_for_appoitnment('Patient Encounter', appointment.name, True) + manage_doc_for_appointment('Patient Encounter', appointment.name, True) if ref_invoice == fee_validity.ref_invoice: visit = visit + 1 @@ -432,7 +432,7 @@ def appointments_valid_in_fee_validity(appointment, invoiced): }, order_by='appointment_date', limit=int(max_visits)-1) -def manage_doc_for_appoitnment(dt_from_appointment, appointment, invoiced): +def manage_doc_for_appointment(dt_from_appointment, appointment, invoiced): dn_from_appointment = frappe.db.get_value( dt_from_appointment, filters={'appointment': appointment} @@ -525,7 +525,7 @@ def get_patient_vitals(patient, from_date=None, to_date=None): vitals = frappe.db.get_all('Vital Signs', { 'docstatus': 1, 'patient': patient - }, order_by='signs_date signs_time') + }, order_by='signs_date, signs_time') if len(vitals): return vitals