From 0a35b2207ee4b39697ef1fd5fe273faae81e4ba4 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Sun, 2 Feb 2020 23:21:18 +0530 Subject: [PATCH] refactor: Healthcare masters --- .../clinical_procedure/clinical_procedure.js | 2 +- .../healthcare_practitioner.js | 83 +- .../healthcare_practitioner.json | 982 +++--------------- .../healthcare_practitioner.py | 63 +- .../healthcare_service_unit.js | 30 +- .../healthcare_service_unit.json | 409 +------- .../healthcare_service_unit.py | 4 +- .../healthcare_service_unit_type.js | 132 +-- .../healthcare_service_unit_type.json | 702 +++---------- .../healthcare_service_unit_type.py | 154 ++- .../lab_test_sample/lab_test_sample.json | 191 +--- .../healthcare/doctype/patient/patient.json | 7 +- .../practitioner_schedule.js | 53 +- erpnext/hr/doctype/employee/employee.js | 4 +- 14 files changed, 622 insertions(+), 2194 deletions(-) diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js index 7ba13a69e9..75510839f9 100644 --- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js +++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js @@ -29,7 +29,7 @@ frappe.ui.form.on('Clinical Procedure', { refresh: function(frm) { frm.set_query("patient", function () { return { - filters: {"status": "Disabled"} + filters: {"status": ["!=", "Disabled"]} }; }); frm.set_query("appointment", function () { diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js index efca484d6a..4ab3b6e9c1 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js @@ -4,7 +4,7 @@ frappe.ui.form.on('Healthcare Practitioner', { setup: function(frm) { frm.set_query('account', 'accounts', function(doc, cdt, cdn) { - var d = locals[cdt][cdn]; + let d = locals[cdt][cdn]; return { filters: { 'root_type': 'Income', @@ -16,23 +16,28 @@ frappe.ui.form.on('Healthcare Practitioner', { }, refresh: function(frm) { frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Healthcare Practitioner'}; - if(!frm.is_new()) { + + if (!frm.is_new()) { frappe.contacts.render_address_and_contact(frm); + } else { + frappe.contacts.clear_address_and_contact(frm); } - frm.set_query("service_unit", "practitioner_schedules", function(){ + + frm.set_query('service_unit', 'practitioner_schedules', function(){ return { filters: { - "is_group": false, - "allow_appointments": true + 'is_group': false, + 'allow_appointments': true } }; }); + set_query_service_item(frm, 'inpatient_visit_charge_item'); set_query_service_item(frm, 'op_consulting_charge_item'); } }); -var set_query_service_item = function(frm, service_item_field) { +let set_query_service_item = function(frm, service_item_field) { frm.set_query(service_item_field, function() { return { filters: { @@ -43,62 +48,62 @@ var set_query_service_item = function(frm, service_item_field) { }); }; -frappe.ui.form.on("Healthcare Practitioner", "user_id",function(frm) { - if(frm.doc.user_id){ +frappe.ui.form.on('Healthcare Practitioner', 'user_id',function(frm) { + if (frm.doc.user_id) { frappe.call({ - "method": "frappe.client.get", + 'method': 'frappe.client.get', args: { - doctype: "User", + doctype: 'User', name: frm.doc.user_id }, callback: function (data) { frappe.model.get_value('Employee', {'user_id': frm.doc.user_id}, 'name', function(data) { - if(data){ - if(!frm.doc.employee || frm.doc.employee != data.name) - frappe.model.set_value(frm.doctype,frm.docname, "employee", data.name); - }else{ - frappe.model.set_value(frm.doctype,frm.docname, "employee", ""); + if (data) { + if (!frm.doc.employee || frm.doc.employee != data.name) + frappe.model.set_value(frm.doctype, frm.docname, 'employee', data.name); + } else { + frappe.model.set_value(frm.doctype, frm.docname, 'employee', ''); } } ); - if(!frm.doc.first_name || frm.doc.first_name != data.message.first_name) - frappe.model.set_value(frm.doctype,frm.docname, "first_name", data.message.first_name); - if(!frm.doc.middle_name || frm.doc.middle_name != data.message.middle_name) - frappe.model.set_value(frm.doctype,frm.docname, "middle_name", data.message.middle_name); - if(!frm.doc.last_name || frm.doc.last_name != data.message.last_name) - frappe.model.set_value(frm.doctype,frm.docname, "last_name", data.message.last_name); - if(!frm.doc.mobile_phone || frm.doc.mobile_phone != data.message.mobile_no) - frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.mobile_no); + if (!frm.doc.first_name || frm.doc.first_name != data.message.first_name) + frappe.model.set_value(frm.doctype,frm.docname, 'first_name', data.message.first_name); + if (!frm.doc.middle_name || frm.doc.middle_name != data.message.middle_name) + frappe.model.set_value(frm.doctype,frm.docname, 'middle_name', data.message.middle_name); + if (!frm.doc.last_name || frm.doc.last_name != data.message.last_name) + frappe.model.set_value(frm.doctype,frm.docname, 'last_name', data.message.last_name); + if (!frm.doc.mobile_phone || frm.doc.mobile_phone != data.message.mobile_no) + frappe.model.set_value(frm.doctype,frm.docname, 'mobile_phone', data.message.mobile_no); } }); } }); -frappe.ui.form.on("Healthcare Practitioner", "employee", function(frm) { - if(frm.doc.employee){ +frappe.ui.form.on('Healthcare Practitioner', 'employee', function(frm) { + if (frm.doc.employee){ frappe.call({ - "method": "frappe.client.get", + 'method': 'frappe.client.get', args: { - doctype: "Employee", + doctype: 'Employee', name: frm.doc.employee }, callback: function (data) { - if(!frm.doc.user_id || frm.doc.user_id != data.message.user_id) - frm.set_value("user_id", data.message.user_id); - if(!frm.doc.designation || frm.doc.designation != data.message.designation) - frappe.model.set_value(frm.doctype,frm.docname, "designation", data.message.designation); - if(!frm.doc.first_name || !frm.doc.user_id){ - frappe.model.set_value(frm.doctype,frm.docname, "first_name", data.message.employee_name); - frappe.model.set_value(frm.doctype,frm.docname, "middle_name", ""); - frappe.model.set_value(frm.doctype,frm.docname, "last_name", ""); + if (!frm.doc.user_id || frm.doc.user_id != data.message.user_id) + frm.set_value('user_id', data.message.user_id); + if (!frm.doc.designation || frm.doc.designation != data.message.designation) + frappe.model.set_value(frm.doctype,frm.docname, 'designation', data.message.designation); + if (!frm.doc.first_name || !frm.doc.user_id){ + frappe.model.set_value(frm.doctype,frm.docname, 'first_name', data.message.first_name); + frappe.model.set_value(frm.doctype,frm.docname, 'middle_name', ''); + frappe.model.set_value(frm.doctype,frm.docname, 'last_name', data.message.last_name); } - if(!frm.doc.mobile_phone || !frm.doc.user_id) - frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.cell_number); - if(!frm.doc.address || frm.doc.address != data.message.current_address) - frappe.model.set_value(frm.doctype,frm.docname, "address", data.message.current_address); + if (!frm.doc.mobile_phone || !frm.doc.user_id) + frappe.model.set_value(frm.doctype,frm.docname, 'mobile_phone', data.message.cell_number); + if (!frm.doc.address || frm.doc.address != data.message.current_address) + frappe.model.set_value(frm.doctype,frm.docname, 'address', data.message.current_address); } }); } diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json index 4a848a081d..51db233e96 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json @@ -1,1041 +1,329 @@ { + "actions": [], "allow_copy": 1, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, "allow_import": 1, "allow_rename": 1, - "autoname": "", + "autoname": "naming_series:", "beta": 1, "creation": "2016-02-23 11:20:53.565119", - "custom": 0, - "docstatus": 0, "doctype": "DocType", "document_type": "Setup", - "editable_grid": 0, + "engine": "InnoDB", + "field_order": [ + "basic_details_section", + "naming_series", + "first_name", + "middle_name", + "last_name", + "practitioner_name", + "gender", + "image", + "column_break_7", + "status", + "mobile_phone", + "residence_phone", + "office_phone", + "employee_and_user_details_section", + "employee", + "department", + "designation", + "column_break_17", + "user_id", + "hospital", + "appointments", + "practitioner_schedules", + "charges", + "op_consulting_charge_item", + "op_consulting_charge", + "column_break_18", + "inpatient_visit_charge_item", + "inpatient_visit_charge", + "address_and_contacts_section", + "address_html", + "column_break_19", + "contact_html", + "account_details", + "accounts", + "default_currency" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "first_name", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 1, "label": "First Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "middle_name", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Middle Name (Optional)", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Middle Name (Optional)" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "last_name", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, "label": "Last Name", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "reqd": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "image", "fieldtype": "Attach Image", "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Image", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "print_hide": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "employee", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Employee", - "length": 0, - "no_copy": 0, - "options": "Employee", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Employee" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "user_id", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "User", - "length": 0, - "no_copy": 0, "options": "User", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "fetch_from": "employee", "fieldname": "designation", "fieldtype": "Link", - "hidden": 0, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 1, "label": "Designation", - "length": 0, - "no_copy": 0, "options": "Designation", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "department", "fieldtype": "Link", - "hidden": 0, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, "in_standard_filter": 1, - "label": "Department", - "length": 0, - "no_copy": 0, - "options": "Medical Department", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Medical Department", + "options": "Medical Department" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_7", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "hospital", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Hospital", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Hospital" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "mobile_phone", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, - "label": "Mobile", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Mobile" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "residence_phone", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Phone (R)", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Phone (R)" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "office_phone", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, - "label": "Phone (Office)", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Phone (Office)" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "1", - "fieldname": "active", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Active", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "collapsible": 1, "fieldname": "appointments", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Appointments", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Appointments" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "practitioner_schedules", "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Practitioner Schedules", - "length": 0, - "no_copy": 0, - "options": "Practitioner Service Unit Schedule", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Practitioner Service Unit Schedule" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "collapsible": 1, "fieldname": "charges", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Charges", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Charges" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "op_consulting_charge_item", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Out Patient Consulting Charge Item", - "length": 0, - "no_copy": 0, - "options": "Item", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Item" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "op_consulting_charge", "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "OP Consulting Charge", - "length": 0, - "no_copy": 0, - "options": "Currency", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Out Patient Consulting Charge", + "options": "Currency" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_18", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "inpatient_visit_charge_item", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Inpatient Visit Charge Item", - "length": 0, - "no_copy": 0, - "options": "Item", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Item" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "inpatient_visit_charge", "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Inpatient Visit Charge", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Inpatient Visit Charge" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "contacts_and_address", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Contacts and Address", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "depends_on": "eval: !doc.__islocal", "fieldname": "address_html", "fieldtype": "HTML", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Address HTML", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 1, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "report_hide": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "column_break_19", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "fieldtype": "Column Break" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "depends_on": "eval: !doc.__islocal", "fieldname": "contact_html", "fieldtype": "HTML", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Contact HTML", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 1, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "report_hide": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, + "collapsible": 1, "fieldname": "account_details", "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Account Details", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Account Details" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "accounts", "fieldtype": "Table", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Income Account", - "length": 0, - "no_copy": 0, - "options": "Party Account", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Party Account" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "default_currency", "fieldtype": "Link", "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Default Currency", - "length": 0, "no_copy": 1, "options": "Currency", - "permlevel": 0, - "precision": "", "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, + "report_hide": 1 + }, + { + "bold": 1, + "fieldname": "practitioner_name", + "fieldtype": "Data", + "in_global_search": 1, + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Full Name", + "read_only": 1, + "search_index": 1 + }, + { + "fieldname": "naming_series", + "fieldtype": "Select", + "label": "Series", + "options": "HLC-PRAC-.YYYY.-", "report_hide": 1, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "set_only_once": 1 + }, + { + "fieldname": "gender", + "fieldtype": "Link", + "label": "Gender", + "options": "Gender", + "reqd": 1 + }, + { + "fieldname": "employee_and_user_details_section", + "fieldtype": "Section Break", + "label": "Employee and User Details" + }, + { + "fieldname": "column_break_17", + "fieldtype": "Column Break" + }, + { + "default": "Active", + "fieldname": "status", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Status", + "options": "\nActive\nDisabled", + "reqd": 1 + }, + { + "fieldname": "basic_details_section", + "fieldtype": "Section Break", + "label": "Basic Details" + }, + { + "collapsible": 1, + "depends_on": "eval: !doc.__islocal", + "fieldname": "address_and_contacts_section", + "fieldtype": "Section Break", + "label": "Address and Contacts" } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, "image_field": "image", - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-11-23 08:54:51.442105", + "links": [], + "modified": "2020-02-01 00:39:49.455988", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare Practitioner", - "name_case": "", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, "create": 1, - "delete": 0, "email": 1, - "export": 0, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Laboratory User", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 }, { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Physician", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 }, { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Nursing User", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 } ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, "restrict_to_domain": "Healthcare", - "search_fields": "first_name,mobile_phone,office_phone", + "search_fields": "practitioner_name, mobile_phone, office_phone", "show_name_in_global_search": 1, "sort_field": "modified", "sort_order": "DESC", - "title_field": "first_name", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + "title_field": "practitioner_name", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py index ad32e94631..a5a675f8ca 100644 --- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py +++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py @@ -9,6 +9,7 @@ from frappe import throw, _ from frappe.utils import cstr 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 from frappe.desk.reportview import build_match_conditions, get_filters_cond class HealthcarePractitioner(Document): @@ -16,63 +17,63 @@ class HealthcarePractitioner(Document): load_address_and_contact(self) def autoname(self): - # practitioner first_name and last_name - self.name = " ".join(filter(None, - [cstr(self.get(f)).strip() for f in ["first_name","middle_name","last_name"]])) + # concat first and last name + self.name = self.practitioner_name + + if frappe.db.exists('Healthcare Practitioner', self.name): + self.name = append_number_if_name_exists('Contact', self.name) def validate(self): + self.set_full_name() validate_party_accounts(self) if self.inpatient_visit_charge_item: - validate_service_item(self.inpatient_visit_charge_item, "Configure a service Item for Inpatient Visit Charge Item") + validate_service_item(self.inpatient_visit_charge_item, 'Configure a service Item for Inpatient Consulting Charge Item') if self.op_consulting_charge_item: - validate_service_item(self.op_consulting_charge_item, "Configure a service Item for Out Patient Consulting Charge Item") + validate_service_item(self.op_consulting_charge_item, 'Configure a service Item for Out Patient Consulting Charge Item') if self.user_id: - self.validate_for_enabled_user_id() - self.validate_duplicate_user_id() - existing_user_id = frappe.db.get_value("Healthcare Practitioner", self.name, "user_id") - if self.user_id != existing_user_id: - frappe.permissions.remove_user_permission( - "Healthcare Practitioner", self.name, existing_user_id) - + self.validate_user_id() else: - existing_user_id = frappe.db.get_value("Healthcare Practitioner", self.name, "user_id") + existing_user_id = frappe.db.get_value('Healthcare Practitioner', self.name, 'user_id') if existing_user_id: frappe.permissions.remove_user_permission( - "Healthcare Practitioner", self.name, existing_user_id) + 'Healthcare Practitioner', self.name, existing_user_id) def on_update(self): if self.user_id: - frappe.permissions.add_user_permission("Healthcare Practitioner", self.name, self.user_id) + frappe.permissions.add_user_permission('Healthcare Practitioner', self.name, self.user_id) + def set_full_name(self): + self.practitioner_name = ' '.join(filter(None, [self.first_name, self.last_name])) - def validate_for_enabled_user_id(self): - enabled = frappe.db.get_value("User", self.user_id, "enabled") - if enabled is None: - frappe.throw(_("User {0} does not exist").format(self.user_id)) - if enabled == 0: - frappe.throw(_("User {0} is disabled").format(self.user_id)) + def validate_user_id(self): + if not frappe.db.exists('User', self.user_id): + frappe.throw(_('User {0} does not exist').format(self.user_id)) + elif not frappe.db.exists('User', self.user_id, 'enabled'): + frappe.throw(_('User {0} is disabled').format(self.user_id)) - def validate_duplicate_user_id(self): - practitioner = frappe.db.sql_list("""select name from `tabHealthcare Practitioner` where - user_id=%s and name!=%s""", (self.user_id, self.name)) + # check duplicate + practitioner = frappe.db.exists('Healthcare Practitioner', { + 'user_id': self.user_id, + 'name': ('!=', self.name) + }) if practitioner: - throw(_("User {0} is already assigned to Healthcare Practitioner {1}").format( - self.user_id, practitioner[0]), frappe.DuplicateEntryError) + frappe.throw(_('User {0} is already assigned to Healthcare Practitioner {1}').format( + self.user_id, practitioner)) def on_trash(self): delete_contact_and_address('Healthcare Practitioner', self.name) def validate_service_item(item, msg): - if frappe.db.get_value("Item", item, "is_stock_item") == 1: + if frappe.db.get_value('Item', item, 'is_stock_item'): frappe.throw(_(msg)) def get_practitioner_list(doctype, txt, searchfield, start, page_len, filters=None): - fields = ["name", "first_name", "mobile_phone"] + fields = ['name', 'practitioner_name', 'mobile_phone'] filters = { - 'name': ("like", "%%%s%%" % txt) + 'name': ('like', '%%%s%%' % txt) } - return frappe.get_all("Healthcare Practitioner", fields = fields, - filters = filters, start=start, page_length=page_len, order_by="name, first_name", as_list=1) + return frappe.get_all('Healthcare Practitioner', fields = fields, + filters = filters, start=start, page_length=page_len, order_by='name, practitioner_name', as_list=1) diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js index 8480a526b4..2cdd550656 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js +++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js @@ -3,7 +3,7 @@ frappe.ui.form.on('Healthcare Service Unit', { onload: function(frm) { - frm.list_route = "Tree/Healthcare Service Unit"; + frm.list_route = 'Tree/Healthcare Service Unit'; // get query select healthcare service unit frm.fields_dict['parent_healthcare_service_unit'].get_query = function(doc) { @@ -16,32 +16,32 @@ frappe.ui.form.on('Healthcare Service Unit', { }; }, refresh: function(frm) { - frm.trigger("set_root_readonly"); - frm.set_df_property("service_unit_type", "reqd", 1); - frm.add_custom_button(__("Healthcare Service Unit Tree"), function() { - frappe.set_route("Tree", "Healthcare Service Unit"); + frm.trigger('set_root_readonly'); + frm.set_df_property('service_unit_type', 'reqd', 1); + frm.add_custom_button(__('Healthcare Service Unit Tree'), function() { + frappe.set_route('Tree', 'Healthcare Service Unit'); }); }, set_root_readonly: function(frm) { // read-only for root healthcare service unit - frm.set_intro(""); - if(!frm.doc.parent_healthcare_service_unit) { + frm.set_intro(''); + if (!frm.doc.parent_healthcare_service_unit) { frm.set_read_only(); - frm.set_intro(__("This is a root healthcare service unit and cannot be edited."), true); + frm.set_intro(__('This is a root healthcare service unit and cannot be edited.'), true); } }, allow_appointments: function(frm) { - if(!frm.doc.allow_appointments){ - frm.set_value("overlap_appointments", false); + if (!frm.doc.allow_appointments) { + frm.set_value('overlap_appointments', false); } }, is_group: function(frm) { - if(frm.doc.is_group == 1){ - frm.set_value("allow_appointments", false); - frm.set_df_property("service_unit_type", "reqd", 0); + if (frm.doc.is_group == 1) { + frm.set_value('allow_appointments', false); + frm.set_df_property('service_unit_type', 'reqd', 0); } - else{ - frm.set_df_property("service_unit_type", "reqd", 1); + else { + frm.set_df_property('service_unit_type', 'reqd', 1); } } }); 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 6e92455404..56f05c60ff 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json +++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json @@ -1,542 +1,209 @@ { - "allow_copy": 0, - "allow_events_in_timeline": 0, - "allow_guest_to_view": 0, + "actions": [], "allow_import": 1, "allow_rename": 1, "autoname": "field:healthcare_service_unit_name", "beta": 1, "creation": "2016-09-21 13:48:14.731437", - "custom": 0, "description": "Healthcare Service Unit", - "docstatus": 0, "doctype": "DocType", "document_type": "Setup", "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "healthcare_service_unit_name", + "parent_healthcare_service_unit", + "is_group", + "service_unit_type", + "allow_appointments", + "overlap_appointments", + "inpatient_occupancy", + "occupancy_status", + "column_break_9", + "warehouse", + "company", + "lft", + "rgt", + "old_parent" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "healthcare_service_unit_name", "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, "in_global_search": 1, "in_list_view": 1, - "in_standard_filter": 0, "label": "Service Unit", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, "unique": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, "fieldname": "parent_healthcare_service_unit", "fieldtype": "Link", - "hidden": 0, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, "label": "Parent Service Unit", - "length": 0, - "no_copy": 0, - "options": "Healthcare Service Unit", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Healthcare Service Unit" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, "default": "0", "depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1", "fieldname": "is_group", "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, - "in_standard_filter": 0, - "label": "Is Group", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "label": "Is Group" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.is_group != 1", "fieldname": "service_unit_type", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Service Unit Type", - "length": 0, - "no_copy": 0, - "options": "Healthcare Service Unit Type", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Healthcare Service Unit Type" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, "default": "0", "depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1", "fetch_from": "service_unit_type.allow_appointments", "fieldname": "allow_appointments", "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Allow Appointments", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "default": "0", "depends_on": "eval:doc.is_group != 1 && doc.allow_appointments == 1 && doc.inpatient_occupany != 1", "fetch_from": "service_unit_type.overlap_appointments", "fieldname": "overlap_appointments", "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Allow Overlap", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, "default": "0", "depends_on": "eval:doc.allow_appointments != 1 && doc.is_group != 1", "fetch_from": "service_unit_type.inpatient_occupancy", "fieldname": "inpatient_occupancy", "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Inpatient Occupancy", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "", "depends_on": "eval:doc.inpatient_occupancy == 1", "fieldname": "occupancy_status", "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Occupancy Status", - "length": 0, "no_copy": 1, "options": "Vacant\nOccupied", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "read_only": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, "bold": 1, - "collapsible": 0, - "columns": 0, "depends_on": "eval:doc.is_group != 1", "fieldname": "warehouse", "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Warehouse", - "length": 0, "no_copy": 1, - "options": "Warehouse", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "options": "Warehouse" }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "company", "fieldtype": "Link", - "hidden": 0, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 1, "label": "Company", - "length": 0, - "no_copy": 0, "options": "Company", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, "remember_last_selected_value": 1, - "report_hide": 0, "reqd": 1, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "lft", "fieldtype": "Int", "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "lft", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "rgt", "fieldtype": "Int", "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "rgt", - "length": 0, "no_copy": 1, - "permlevel": 0, - "precision": "", "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 1, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "search_index": 1 }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, "fieldname": "old_parent", "fieldtype": "Link", "hidden": 1, "ignore_user_permissions": 1, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, "label": "Old Parent", - "length": 0, "no_copy": 1, "options": "Healthcare Service Unit", - "permlevel": 0, - "precision": "", "print_hide": 1, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 1, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "report_hide": 1 + }, + { + "fieldname": "column_break_9", + "fieldtype": "Column Break" } ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-10-04 21:09:52.261882", + "links": [], + "modified": "2020-01-30 18:03:29.031351", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare Service Unit", - "name_case": "", "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 0, - "delete": 0, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Nursing User", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 0 + "share": 1 }, { - "amend": 0, - "cancel": 0, "create": 1, "delete": 1, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Healthcare Administrator", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 }, { - "amend": 0, - "cancel": 0, "create": 1, - "delete": 0, "email": 1, "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, "print": 1, "read": 1, "report": 1, "role": "Physician", - "set_user_permissions": 0, "share": 1, - "submit": 0, "write": 1 } ], "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, "restrict_to_domain": "Healthcare", "search_fields": "healthcare_service_unit_name", - "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", "title_field": "healthcare_service_unit_name", - "track_changes": 1, - "track_seen": 0, - "track_views": 0 + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py index b40869348d..13cc43d2be 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py +++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py @@ -23,9 +23,9 @@ class HealthcareServiceUnit(NestedSet): self.validate_one_root() def validate(self): - if self.is_group == 1: + if self.is_group: self.allow_appointments = 0 self.overlap_appointments = 0 self.inpatient_occupancy = 0 - elif self.allow_appointments != 1: + elif not self.allow_appointments: self.overlap_appointments = 0 diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js index 288ebc40b4..f5e8a6f2de 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js @@ -2,118 +2,84 @@ // For license information, please see license.txt frappe.ui.form.on('Healthcare Service Unit Type', { + refresh: function(frm) { + frm.set_df_property('item_code', 'read_only', frm.doc.__islocal ? 0 : 1); + if (!frm.doc.__islocal) { + frm.add_custom_button(__('Change Item Code'), function() { + change_item_code(cur_frm, frm.doc); + }); + } + }, + service_unit_type: function(frm) { set_item_details(frm); - if(!frm.doc.__islocal){ + + if (!frm.doc.__islocal) { frm.doc.change_in_item = 1; } }, + is_billable: function(frm) { set_item_details(frm); }, - refresh: function(frm) { - frm.set_df_property("item_code", "read_only", frm.doc.__islocal ? 0 : 1); - if(!frm.doc.__islocal) { - frm.add_custom_button(__('Change Item Code'), function() { - change_item_code(cur_frm,frm.doc); - } ); - if(frm.doc.disabled == 1){ - frm.add_custom_button(__('Enable'), function() { - enable(cur_frm); - } ); - } - else{ - frm.add_custom_button(__('Disable'), function() { - disable(cur_frm); - } ); - } - } - }, + rate: function(frm) { - if(!frm.doc.__islocal){ + if (!frm.doc.__islocal) { frm.doc.change_in_item = 1; } }, item_group: function(frm) { - if(!frm.doc.__islocal){ + if (!frm.doc.__islocal) { frm.doc.change_in_item = 1; } }, description: function(frm) { - if(!frm.doc.__islocal){ + if (!frm.doc.__islocal) { frm.doc.change_in_item = 1; } } }); -var disable = function(frm){ - var doc = frm.doc; - frappe.call({ - method: "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.disable_enable", - args: {status: 1, doc_name: doc.name, item: doc.item, is_billable: doc.is_billable}, - callback: function(){ - cur_frm.reload_doc(); - } - }); +let set_item_details = function(frm) { + if (frm.doc.service_unit_type && frm.doc.is_billable) { + if (!frm.doc.item_code) + frm.set_value('item_code', frm.doc.service_unit_type); + if (!frm.doc.description) + frm.set_value('description', frm.doc.service_unit_type); + if (!frm.doc.item_group) + frm.set_value('item_group', 'Services'); + } }; -var enable = function(frm){ - var doc = frm.doc; - frappe.call({ - method: "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.disable_enable", - args: {status: 0, doc_name: doc.name, item: doc.item, is_billable: doc.is_billable}, - callback: function(){ - cur_frm.reload_doc(); - } - }); -}; - -var change_item_code = function(frm, doc){ - var d = new frappe.ui.Dialog({ - title:__("Change Item Code"), - fields:[ +let change_item_code = function(frm, doc) { + let d = new frappe.ui.Dialog({ + title: __('Change Item Code'), + fields: [ { - "fieldtype": "Data", - "label": "Item Code", - "fieldname": "Item Code", - reqd:1 - }, - { - "fieldtype": "Button", - "label": __("Change Code"), - click: function() { - var values = d.get_values(); - if(!values) - return; - change_item_code_from_unit_type(values["Item Code"], doc); - d.hide(); - } + 'fieldtype': 'Data', + 'label': 'Item Code', + 'fieldname': 'item_code', + reqd: 1 } - ] + ], + primary_action: function() { + let values = d.get_values(); + if (values) { + frappe.call({ + "method": "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.change_item_code", + "args": {item: doc.item, item_code: values['item_code'], doc_name: doc.name}, + callback: function () { + frm.reload_doc(); + } + }); + } + d.hide(); + }, + primary_action_label: __("Change Template Code") }); + d.show(); d.set_values({ 'Item Code': frm.doc.item_code }); - - var change_item_code_from_unit_type = function(item_code, doc){ - frappe.call({ - "method": "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.change_item_code", - "args": {item: doc.item, item_code: item_code, doc_name: doc.name}, - callback: function () { - frm.reload_doc(); - } - }); - }; -}; - -var set_item_details = function(frm) { - if(frm.doc.service_unit_type && frm.doc.is_billable == 1){ - if(!frm.doc.item_code) - frm.set_value("item_code", frm.doc.service_unit_type); - if(!frm.doc.description) - frm.set_value("description", frm.doc.service_unit_type); - if(!frm.doc.item_group) - frm.set_value("item_group", 'Services'); - } }; diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json index 40681e9f77..5fa47d91bc 100644 --- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json +++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json @@ -1,588 +1,164 @@ { - "allow_copy": 0, - "allow_guest_to_view": 0, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:service_unit_type", - "beta": 0, - "creation": "2018-07-11 16:47:51.414675", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "", - "editable_grid": 1, - "engine": "InnoDB", + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:service_unit_type", + "creation": "2018-07-11 16:47:51.414675", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "disabled", + "service_unit_type", + "allow_appointments", + "overlap_appointments", + "inpatient_occupancy", + "is_billable", + "item_details", + "item", + "item_code", + "item_group", + "uom", + "no_of_hours", + "column_break_11", + "rate", + "description", + "change_in_item" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "service_unit_type", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Service Unit Type", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, + "fieldname": "service_unit_type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Service Unit Type", + "reqd": 1, "unique": 1 - }, + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 1, - "collapsible": 0, - "columns": 0, - "default": "0", - "depends_on": "eval:doc.inpatient_occupancy != 1", - "fieldname": "allow_appointments", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Allow Appointments", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "bold": 1, + "default": "0", + "depends_on": "eval:doc.inpatient_occupancy != 1", + "fieldname": "allow_appointments", + "fieldtype": "Check", + "label": "Allow Appointments", + "no_copy": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 1, - "collapsible": 0, - "columns": 0, - "default": "0", - "depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1", - "fieldname": "overlap_appointments", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Allow Overlap", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "bold": 1, + "default": "0", + "depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1", + "fieldname": "overlap_appointments", + "fieldtype": "Check", + "label": "Allow Overlap", + "no_copy": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 1, - "collapsible": 0, - "columns": 0, - "default": "0", - "depends_on": "eval:doc.allow_appointments != 1", - "fieldname": "inpatient_occupancy", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Inpatient Occupancy", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "bold": 1, + "default": "0", + "depends_on": "eval:doc.allow_appointments != 1", + "fieldname": "inpatient_occupancy", + "fieldtype": "Check", + "label": "Inpatient Occupancy", + "no_copy": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 1, - "collapsible": 0, - "columns": 0, - "depends_on": "eval:doc.inpatient_occupancy == 1 && doc.allow_appointments != 1", - "fieldname": "is_billable", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Is Billable", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "bold": 1, + "default": "0", + "depends_on": "eval:doc.inpatient_occupancy == 1 && doc.allow_appointments != 1", + "fieldname": "is_billable", + "fieldtype": "Check", + "label": "Is Billable" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "is_billable", - "fieldname": "item_details", - "fieldtype": "Section Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item Details", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "depends_on": "is_billable", + "fieldname": "item_details", + "fieldtype": "Section Break", + "label": "Item Details" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "item", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item", - "length": 0, - "no_copy": 0, - "options": "Item", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "item", + "fieldtype": "Link", + "label": "Item", + "options": "Item", + "read_only": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "item_code", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item Code", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "item_code", + "fieldtype": "Data", + "label": "Item Code", + "mandatory_depends_on": "eval: doc.is_billable == 1" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "item_group", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Item Group", - "length": 0, - "no_copy": 0, - "options": "Item Group", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "item_group", + "fieldtype": "Link", + "label": "Item Group", + "mandatory_depends_on": "eval: doc.is_billable == 1", + "options": "Item Group" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "uom", - "fieldtype": "Link", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "UOM", - "length": 0, - "no_copy": 0, - "options": "UOM", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "uom", + "fieldtype": "Link", + "label": "UOM", + "mandatory_depends_on": "eval: doc.is_billable == 1", + "options": "UOM" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "no_of_hours", - "fieldtype": "Int", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "UOM Conversion in Hours", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "no_of_hours", + "fieldtype": "Int", + "label": "UOM Conversion in Hours", + "mandatory_depends_on": "eval: doc.is_billable == 1" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "column_break_11", - "fieldtype": "Column Break", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "column_break_11", + "fieldtype": "Column Break" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "rate", - "fieldtype": "Currency", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Rate / UOM", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "rate", + "fieldtype": "Currency", + "label": "Rate / UOM" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "default": "0", - "fieldname": "disabled", - "fieldtype": "Check", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Disabled", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 1, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "default": "0", + "fieldname": "disabled", + "fieldtype": "Check", + "label": "Disabled", + "no_copy": 1 + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "description", - "fieldtype": "Small Text", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Description", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description" + }, { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "change_in_item", - "fieldtype": "Check", - "hidden": 1, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Change in Item", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 + "default": "0", + "fieldname": "change_in_item", + "fieldtype": "Check", + "hidden": 1, + "label": "Change in Item" } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2018-08-08 13:00:23.751635", - "modified_by": "Administrator", - "module": "Healthcare", - "name": "Healthcare Service Unit Type", - "name_case": "", - "owner": "Administrator", + ], + "links": [], + "modified": "2020-01-30 16:06:00.624496", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Healthcare Service Unit Type", + "owner": "Administrator", "permissions": [ { - "amend": 0, - "cancel": 0, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Healthcare Administrator", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Healthcare Administrator", + "share": 1, "write": 1 } - ], - "quick_entry": 0, - "read_only": 0, - "read_only_onload": 0, - "restrict_to_domain": "Healthcare", - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "title_field": "service_unit_type", - "track_changes": 0, - "track_seen": 0, - "track_views": 0 + ], + "restrict_to_domain": "Healthcare", + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "service_unit_type" } \ No newline at end of file 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 43f01c86b9..49d06d5963 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 @@ -10,109 +10,107 @@ from frappe.model.rename_doc import rename_doc class HealthcareServiceUnitType(Document): def validate(self): - if self.is_billable == 1: - if not self.uom or not self.item_group or not self.description or not self.no_of_hours > 0: - frappe.throw(_("Configure Item Fields like UOM, Item Group, Description and No of Hours.")) + if self.is_billable: + if self.disabled: + frappe.db.set_value('Item', self.item, 'disabled', 1) + else: + frappe.db.set_value('Item', self.item, 'disabled', 0) def after_insert(self): if self.inpatient_occupancy and self.is_billable: create_item(self) def on_trash(self): - if(self.item): + if self.item: try: - frappe.delete_doc("Item",self.item) + frappe.delete_doc('Item', self.item) except Exception: - frappe.throw(_("""Not permitted. Please disable the Service Unit Type""")) + frappe.throw(_('Not permitted. Please disable the Service Unit Type')) def on_update(self): - if(self.change_in_item and self.is_billable == 1 and self.item): - updating_item(self) - item_price = item_price_exist(self) - if not item_price: - if(self.rate != 0.0): - price_list_name = frappe.db.get_value("Price List", {"selling": 1}) - if(self.rate): - make_item_price(self.item_code, price_list_name, self.rate) - else: - make_item_price(self.item_code, price_list_name, 0.0) - else: - frappe.db.set_value("Item Price", item_price, "price_list_rate", self.rate) + if self.change_in_item and self.is_billable and self.item: + update_item(self) - frappe.db.set_value(self.doctype,self.name,"change_in_item",0) - elif(self.is_billable == 0 and self.item): - frappe.db.set_value("Item",self.item,"disabled",1) + item_price = item_price_exists(self) + + if not item_price: + price_list_name = frappe.db.get_value('Price List', {'selling': 1}) + if self.rate: + make_item_price(self.item_code, price_list_name, self.rate) + else: + make_item_price(self.item_code, price_list_name, 0.0) + else: + frappe.db.set_value('Item Price', item_price, 'price_list_rate', self.rate) + + frappe.db.set_value(self.doctype, self.name, 'change_in_item',0) + elif not self.is_billable and self.item: + frappe.db.set_value('Item', self.item, 'disabled', 1) self.reload() -def item_price_exist(doc): - item_price = frappe.db.exists({ - "doctype": "Item Price", - "item_code": doc.item_code}) - if(item_price): - return item_price[0][0] - else: - return False -def updating_item(doc): - frappe.db.sql("""update `tabItem` set item_name=%s, item_group=%s, disabled=0, standard_rate=%s, - description=%s, modified=NOW() where item_code=%s""", - (doc.service_unit_type, doc.item_group , doc.rate, doc.description, doc.item)) +def item_price_exists(doc): + if frappe.db.exists({'doctype': 'Item Price', 'item_code': doc.item_code}): + return item_price[0][0] + return False def create_item(doc): - #insert item + # insert item item = frappe.get_doc({ - "doctype": "Item", - "item_code": doc.item_code, - "item_name":doc.service_unit_type, - "item_group": doc.item_group, - "description":doc.description, - "is_sales_item": 1, - "is_service_item": 1, - "is_purchase_item": 0, - "is_stock_item": 0, - "show_in_website": 0, - "is_pro_applicable": 0, - "disabled": 0, - "stock_uom": doc.uom + 'doctype': 'Item', + 'item_code': doc.item_code, + 'item_name': doc.service_unit_type, + 'item_group': doc.item_group, + 'description': doc.description or doc.item_code, + 'is_sales_item': 1, + 'is_service_item': 1, + 'is_purchase_item': 0, + 'is_stock_item': 0, + 'show_in_website': 0, + 'is_pro_applicable': 0, + 'disabled': 0, + 'stock_uom': doc.uom }).insert(ignore_permissions=True) - #insert item price - #get item price list to insert item price - if(doc.rate != 0.0): - price_list_name = frappe.db.get_value("Price List", {"selling": 1}) - if(doc.rate): - make_item_price(item.name, price_list_name, doc.rate) - item.standard_rate = doc.rate - else: - make_item_price(item.name, price_list_name, 0.0) - item.standard_rate = 0.0 - item.save(ignore_permissions = True) - #Set item to the Doc - frappe.db.set_value("Healthcare Service Unit Type", doc.name, "item", item.name) + # insert item price + # get item price list to insert item price + price_list_name = frappe.db.get_value('Price List', {'selling': 1}) + if doc.rate: + make_item_price(item.name, price_list_name, doc.rate) + item.standard_rate = doc.rate + else: + make_item_price(item.name, price_list_name, 0.0) + item.standard_rate = 0.0 - doc.reload() #refresh the doc after insert. + item.save(ignore_permissions=True) + # Set item in the doc + frappe.db.set_value('Healthcare Service Unit Type', doc.name, 'item', item.name) + + doc.reload() def make_item_price(item, price_list_name, item_price): frappe.get_doc({ - "doctype": "Item Price", - "price_list": price_list_name, - "item_code": item, - "price_list_rate": item_price + 'doctype': 'Item Price', + 'price_list': price_list_name, + 'item_code': item, + 'price_list_rate': item_price }).insert(ignore_permissions=True) +def update_item(doc): + item = frappe.get_doc("Item", doc.item) + if item: + item.update({ + "item_name": doc.service_unit_type, + "item_group": doc.item_group, + "disabled": 0, + "standard_rate": doc.rate, + "description": doc.description + }) + item.save() + @frappe.whitelist() def change_item_code(item, item_code, doc_name): - item_exist = frappe.db.exists({ - "doctype": "Item", - "item_code": item_code}) - if(item_exist): - frappe.throw(_("Code {0} already exist").format(item_code)) + if frappe.db.exists({'doctype': 'Item', 'item_code': item_code}): + frappe.throw(_('Item with Item Code {0} already exists').format(item_code)) else: - rename_doc("Item", item, item_code, ignore_permissions=True) - frappe.db.set_value("Healthcare Service Unit Type", doc_name, "item_code", item_code) - -@frappe.whitelist() -def disable_enable(status, doc_name, item=None, is_billable=None): - frappe.db.set_value("Healthcare Service Unit Type", doc_name, "disabled", status) - if(is_billable == 1): - frappe.db.set_value("Item", item, "disabled", status) + rename_doc('Item', item, item_code, ignore_permissions=True) + frappe.db.set_value('Healthcare Service Unit Type', doc_name, 'item_code', item_code) diff --git a/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json b/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json index 46c04c696e..2830038eaf 100644 --- a/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json +++ b/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json @@ -1,145 +1,68 @@ { - "allow_copy": 1, - "allow_guest_to_view": 0, - "allow_import": 1, - "allow_rename": 1, - "autoname": "field:sample", - "beta": 1, - "creation": "2016-04-04 17:35:44.823951", - "custom": 0, - "docstatus": 0, - "doctype": "DocType", - "document_type": "Setup", - "editable_grid": 0, + "actions": [], + "allow_copy": 1, + "allow_import": 1, + "allow_rename": 1, + "autoname": "field:sample", + "beta": 1, + "creation": "2016-04-04 17:35:44.823951", + "doctype": "DocType", + "document_type": "Setup", + "engine": "InnoDB", + "field_order": [ + "sample", + "sample_uom" + ], "fields": [ { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "sample", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 1, - "in_standard_filter": 0, - "label": "Sample", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 1, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, + "fieldname": "sample", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Sample", + "reqd": 1, + "unique": 1 + }, { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 1, - "collapsible": 0, - "columns": 0, - "fieldname": "sample_uom", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "UOM", - "length": 0, - "no_copy": 0, - "options": "", - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 + "bold": 1, + "fieldname": "sample_uom", + "fieldtype": "Link", + "in_list_view": 1, + "label": "UOM", + "options": "Lab Test UOM" } - ], - "has_web_view": 0, - "hide_heading": 0, - "hide_toolbar": 0, - "idx": 0, - "image_view": 0, - "in_create": 0, - "is_submittable": 0, - "issingle": 0, - "istable": 0, - "max_attachments": 0, - "modified": "2017-08-31 13:46:22.508908", - "modified_by": "Administrator", - "module": "Healthcare", - "name": "Lab Test Sample", - "name_case": "", - "owner": "Administrator", + ], + "links": [], + "modified": "2020-01-29 23:02:02.249839", + "modified_by": "Administrator", + "module": "Healthcare", + "name": "Lab Test Sample", + "owner": "Administrator", "permissions": [ { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 1, - "delete": 0, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Healthcare Administrator", - "set_user_permissions": 0, - "share": 1, - "submit": 0, + "create": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Healthcare Administrator", + "share": 1, "write": 1 - }, + }, { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Laboratory User", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 0 + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Laboratory User", + "share": 1 } - ], - "quick_entry": 1, - "read_only": 0, - "read_only_onload": 0, - "restrict_to_domain": "Healthcare", - "show_name_in_global_search": 0, - "sort_field": "modified", - "sort_order": "DESC", - "title_field": "sample", - "track_changes": 1, - "track_seen": 0 + ], + "quick_entry": 1, + "restrict_to_domain": "Healthcare", + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "sample", + "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json index e866f0950b..cf092921f6 100644 --- a/erpnext/healthcare/doctype/patient/patient.json +++ b/erpnext/healthcare/doctype/patient/patient.json @@ -81,10 +81,11 @@ { "fieldname": "naming_series", "fieldtype": "Select", - "label": "Patient ID", + "label": "Series", "options": "HLC-PAT-.YYYY.-", "print_hide": 1, - "report_hide": 1 + "report_hide": 1, + "set_only_once": 1 }, { "bold": 1, @@ -362,7 +363,7 @@ "image_field": "image", "links": [], "max_attachments": 50, - "modified": "2020-01-29 13:56:10.174897", + "modified": "2020-01-31 17:50:59.797789", "modified_by": "Administrator", "module": "Healthcare", "name": "Patient", diff --git a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js index f247856b92..7cb7c4b65e 100644 --- a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js +++ b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js @@ -5,9 +5,9 @@ frappe.ui.form.on('Practitioner Schedule', { refresh: function(frm) { cur_frm.fields_dict["time_slots"].grid.wrapper.find('.grid-add-row').hide(); cur_frm.fields_dict["time_slots"].grid.add_custom_button(__('Add Time Slots'), () => { - var d = new frappe.ui.Dialog({ + let d = new frappe.ui.Dialog({ fields: [ - {fieldname: 'days', label: __('Select Days'), fieldtype:'MultiSelect', + {fieldname: 'days', label: __('Select Days'), fieldtype: 'MultiSelect', options:[ {value:'Sunday', label:__('Sunday')}, {value:'Monday', label:__('Monday')}, @@ -17,40 +17,41 @@ frappe.ui.form.on('Practitioner Schedule', { {value:'Friday', label:__('Friday')}, {value:'Saturday', label:__('Saturday')}, ], reqd: 1}, - {fieldname: 'from_time', label:__('From'), fieldtype:'Time', + {fieldname: 'from_time', label: __('From'), fieldtype: 'Time', 'default': '09:00:00', reqd: 1}, - {fieldname: 'to_time', label:__('To'), fieldtype:'Time', + {fieldname: 'to_time', label: __('To'), fieldtype: 'Time', 'default': '12:00:00', reqd: 1}, - {fieldname: 'duration', label:__('Appointment Duration (mins)'), + {fieldname: 'duration', label: __('Appointment Duration (mins)'), fieldtype:'Int', 'default': 15, reqd: 1}, ], primary_action_label: __('Add Timeslots'), primary_action: () => { - var values = d.get_values(); - if(values) { + let values = d.get_values(); + if (values) { let slot_added = false; values.days.split(',').forEach(function(day){ day = $.trim(day); - if(['Sunday', 'Monday', 'Tuesday', 'Wednesday', + if (['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'].includes(day)){ add_slots(day); } }); + function check_overlap_or_add_slot(week_day, cur_time, end_time, add_slots_to_child){ let overlap = false; - while(cur_time < end_time) { + while (cur_time < end_time) { let add_to_child = true; let to_time = cur_time.clone().add(values.duration, 'minutes'); - if(to_time <= end_time) { - if(frm.doc.time_slots){ + if (to_time <= end_time) { + if (frm.doc.time_slots){ frm.doc.time_slots.forEach(function(slot) { - if(slot.day == week_day){ + if (slot.day == week_day){ let slot_from_moment = moment(slot.from_time, 'HH:mm:ss'); let slot_to_moment = moment(slot.to_time, 'HH:mm:ss'); - if(cur_time.isSame(slot_from_moment) || cur_time.isBetween(slot_from_moment, slot_to_moment) || - to_time.isSame(slot_to_moment) || to_time.isBetween(slot_from_moment, slot_to_moment)){ + if (cur_time.isSame(slot_from_moment) || cur_time.isBetween(slot_from_moment, slot_to_moment) || + to_time.isSame(slot_to_moment) || to_time.isBetween(slot_from_moment, slot_to_moment)) { overlap = true; - if(add_slots_to_child){ + if (add_slots_to_child) { frappe.show_alert({ message:__('Time slot skiped, the slot {0} to {1} overlap exisiting slot {2} to {3}', [cur_time.format('HH:mm:ss'), to_time.format('HH:mm:ss'), slot.from_time, slot.to_time]), @@ -63,7 +64,7 @@ frappe.ui.form.on('Practitioner Schedule', { }); } // add a new timeslot - if(add_to_child && add_slots_to_child){ + if (add_to_child && add_slots_to_child) { frm.add_child('time_slots', { from_time: cur_time.format('HH:mm:ss'), to_time: to_time.format('HH:mm:ss'), @@ -76,10 +77,11 @@ frappe.ui.form.on('Practitioner Schedule', { } return overlap; } - function add_slots(week_day){ + + function add_slots(week_day) { let cur_time = moment(values.from_time, 'HH:mm:ss'); let end_time = moment(values.to_time, 'HH:mm:ss'); - if(check_overlap_or_add_slot(week_day, cur_time, end_time, false)){ + if (check_overlap_or_add_slot(week_day, cur_time, end_time, false)) { frappe.confirm(__('Schedules for {0} overlaps, do you want to proceed after skiping overlaped slots ?', [week_day]), function() { // if Yes @@ -88,21 +90,22 @@ frappe.ui.form.on('Practitioner Schedule', { function() { // if No frappe.show_alert({ - message:__('Slots for {0} are not added to the schedule', [week_day]), - indicator:'red' + message: __('Slots for {0} are not added to the schedule', [week_day]), + indicator: 'red' }); } ); - } - else{ + } else { check_overlap_or_add_slot(week_day, cur_time, end_time, true); } } + frm.refresh_field('time_slots'); - if(slot_added){ + + if (slot_added) { frappe.show_alert({ - message:__('Time slots added'), - indicator:'green' + message: __('Time slots added'), + indicator: 'green' }); } } diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js index 7d153d432c..c21d4b893c 100755 --- a/erpnext/hr/doctype/employee/employee.js +++ b/erpnext/hr/doctype/employee/employee.js @@ -55,8 +55,8 @@ frappe.ui.form.on('Employee',{ }; }); }, - prefered_contact_email:function(frm){ - frm.events.update_contact(frm) + prefered_contact_email:function(frm){ + frm.events.update_contact(frm) }, personal_email:function(frm){ frm.events.update_contact(frm)