fix(Healthcare): disabled Lab Test Template shown as Enabled in List View (#20378)
* fix (Healthcare): disabled Lab Test Template shown as enabled in List View
* fix: remove custom disabled button and unhide disabled field
diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.js b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.js
index 3eb4f6a..5c9bf49 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.js
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.js
@@ -3,17 +3,17 @@
frappe.ui.form.on("Lab Test Template",{
lab_test_name: function(frm) {
- if(!frm.doc.lab_test_code)
+ if (!frm.doc.lab_test_code)
frm.set_value("lab_test_code", frm.doc.lab_test_name);
- if(!frm.doc.lab_test_description)
+ if (!frm.doc.lab_test_description)
frm.set_value("lab_test_description", frm.doc.lab_test_name);
},
- refresh : function(frm){
+ refresh : function(frm) {
// Restrict Special, Grouped type templates in Child TestGroups
frm.set_query("lab_test_template", "lab_test_groups", function() {
return {
filters: {
- lab_test_template_type:['in',['Single','Compound']]
+ lab_test_template_type: ['in',['Single','Compound']]
}
};
});
@@ -23,83 +23,44 @@
cur_frm.cscript.custom_refresh = function(doc) {
cur_frm.set_df_property("lab_test_code", "read_only", doc.__islocal ? 0 : 1);
- if(!doc.__islocal) {
- cur_frm.add_custom_button(__('Change Template Code'), function() {
- change_template_code(cur_frm,doc);
- } );
- if(doc.disabled == 1){
- cur_frm.add_custom_button(__('Enable Template'), function() {
- enable_template(cur_frm);
- } );
- }
- else{
- cur_frm.add_custom_button(__('Disable Template'), function() {
- disable_template(cur_frm);
- } );
- }
+ if (!doc.__islocal) {
+ cur_frm.add_custom_button(__("Change Template Code"), function() {
+ change_template_code(doc);
+ });
}
};
-var disable_template = function(frm){
- var doc = frm.doc;
- frappe.call({
- method: "erpnext.healthcare.doctype.lab_test_template.lab_test_template.disable_enable_test_template",
- args: {status: 1, name: doc.name, is_billable: doc.is_billable},
- callback: function(){
- cur_frm.reload_doc();
- }
- });
-};
-
-var enable_template = function(frm){
- var doc = frm.doc;
- frappe.call({
- method: "erpnext.healthcare.doctype.lab_test_template.lab_test_template.disable_enable_test_template",
- args: {status: 0, name: doc.name, is_billable: doc.is_billable},
- callback: function(){
- cur_frm.reload_doc();
- }
- });
-};
-
-
-var change_template_code = function(frm,doc){
- var d = new frappe.ui.Dialog({
+let change_template_code = function(doc) {
+ let d = new frappe.ui.Dialog({
title:__("Change Template Code"),
fields:[
{
"fieldtype": "Data",
- "label": "Test Template Code",
- "fieldname": "Test Code",
- reqd:1
- },
- {
- "fieldtype": "Button",
- "label": __("Change Code"),
- click: function() {
- var values = d.get_values();
- if(!values)
- return;
- change_test_code_from_template(values["Test Code"],doc);
- d.hide();
- }
+ "label": "Lab Test Template Code",
+ "fieldname": "lab_test_code",
+ reqd: 1
}
- ]
+ ],
+ primary_action: function() {
+ let values = d.get_values();
+ if (values) {
+ frappe.call({
+ "method": "erpnext.healthcare.doctype.lab_test_template.lab_test_template.change_test_code_from_template",
+ "args": {lab_test_code: values.lab_test_code, doc: doc},
+ callback: function (data) {
+ frappe.set_route("Form", "Lab Test Template", data.message);
+ }
+ });
+ }
+ d.hide();
+ },
+ primary_action_label: __("Change Template Code")
});
d.show();
- d.set_values({
- 'Test Code': doc.lab_test_code
- });
- var change_test_code_from_template = function(lab_test_code,doc){
- frappe.call({
- "method": "erpnext.healthcare.doctype.lab_test_template.lab_test_template.change_test_code_from_template",
- "args": {lab_test_code: lab_test_code, doc: doc},
- callback: function (data) {
- frappe.set_route("Form", "Lab Test Template", data.message);
- }
- });
- };
+ d.set_values({
+ "lab_test_code": doc.lab_test_code
+ });
};
frappe.ui.form.on("Lab Test Template", "lab_test_name", function(frm){
@@ -124,8 +85,8 @@
});
frappe.ui.form.on("Lab Test Groups", "template_or_new_line", function (frm, cdt, cdn) {
- var child = locals[cdt][cdn];
- if(child.template_or_new_line =="Add new line"){
+ let child = locals[cdt][cdn];
+ if (child.template_or_new_line == "Add new line") {
frappe.model.set_value(cdt, cdn, 'lab_test_template', "");
frappe.model.set_value(cdt, cdn, 'lab_test_description', "");
}
diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json
index a707560..fcfecba 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.json
@@ -1,1036 +1,276 @@
{
- "allow_copy": 1,
- "allow_guest_to_view": 0,
- "allow_import": 1,
- "allow_rename": 1,
- "autoname": "field:lab_test_code",
- "beta": 1,
- "creation": "2016-03-29 17:35:36.761223",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 0,
+ "actions": [],
+ "allow_copy": 1,
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "field:lab_test_code",
+ "beta": 1,
+ "creation": "2016-03-29 17:35:36.761223",
+ "doctype": "DocType",
+ "engine": "InnoDB",
+ "field_order": [
+ "lab_test_name",
+ "item",
+ "lab_test_code",
+ "lab_test_group",
+ "department",
+ "column_break_3",
+ "lab_test_template_type",
+ "disabled",
+ "is_billable",
+ "lab_test_rate",
+ "section_break_normal",
+ "lab_test_uom",
+ "lab_test_normal_range",
+ "column_break_10",
+ "section_break_compound",
+ "normal_test_templates",
+ "section_break_special",
+ "sensitivity",
+ "special_test_template",
+ "section_break_group",
+ "lab_test_groups",
+ "section_break_description",
+ "lab_test_description",
+ "sb_sample_collection",
+ "sample",
+ "sample_uom",
+ "sample_quantity",
+ "sample_collection_details",
+ "change_in_item"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lab_test_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": "Test Name",
- "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": 1,
- "search_index": 1,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "lab_test_name",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "in_standard_filter": 1,
+ "label": "Test Name",
+ "no_copy": 1,
+ "reqd": 1,
+ "search_index": 1
+ },
{
- "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": 1,
- "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": 1,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "item",
+ "fieldtype": "Link",
+ "label": "Item",
+ "no_copy": 1,
+ "options": "Item",
+ "read_only": 1,
+ "search_index": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lab_test_code",
- "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": "Item Code",
- "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": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
+ "fieldname": "lab_test_code",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Item Code",
+ "no_copy": 1,
+ "reqd": 1,
"unique": 1
- },
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "description": "",
- "fieldname": "lab_test_group",
- "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": "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": 1,
- "search_index": 1,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "lab_test_group",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "in_standard_filter": 1,
+ "label": "Item Group",
+ "options": "Item Group",
+ "reqd": 1,
+ "search_index": 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": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "department",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "in_standard_filter": 1,
+ "label": "Department",
+ "options": "Medical Department",
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_3",
- "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_3",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "",
- "description": "Single for results which require only a single input, result UOM and normal value \n<br>\nCompound for results which require multiple input fields with corresponding event names, result UOMs and normal values\n<br>\nDescriptive for tests which have multiple result components and corresponding result entry fields. \n<br>\nGrouped for test templates which are a group of other test templates.\n<br>\nNo Result for tests with no results. Also, no Lab Test is created. e.g.. Sub Tests for Grouped results.",
- "fieldname": "lab_test_template_type",
- "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": 1,
- "label": "Result Format",
- "length": 0,
- "no_copy": 0,
- "options": "\nSingle\nCompound\nDescriptive\nGrouped\nNo Result",
- "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
- },
+ "description": "Single for results which require only a single input, result UOM and normal value \n<br>\nCompound for results which require multiple input fields with corresponding event names, result UOMs and normal values\n<br>\nDescriptive for tests which have multiple result components and corresponding result entry fields. \n<br>\nGrouped for test templates which are a group of other test templates.\n<br>\nNo Result for tests with no results. Also, no Lab Test is created. e.g.. Sub Tests for Grouped results.",
+ "fieldname": "lab_test_template_type",
+ "fieldtype": "Select",
+ "in_standard_filter": 1,
+ "label": "Result Format",
+ "options": "\nSingle\nCompound\nDescriptive\nGrouped\nNo Result"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "1",
- "depends_on": "eval:doc.lab_test_template_type != 'Grouped'",
- "description": "If unchecked, the item wont be appear in Sales Invoice, but can be used in group test creation. ",
- "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": 1,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "default": "1",
+ "depends_on": "eval:doc.lab_test_template_type != 'Grouped'",
+ "description": "If unchecked, the item wont be appear in Sales Invoice, but can be used in group test creation. ",
+ "fieldname": "is_billable",
+ "fieldtype": "Check",
+ "label": "Is billable",
+ "search_index": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:doc.is_billable == 1",
- "description": "This value is updated in the Default Sales Price List.",
- "fieldname": "lab_test_rate",
- "fieldtype": "Currency",
- "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": "Standard Selling Rate",
- "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": "eval:doc.is_billable == 1",
+ "description": "This value is updated in the Default Sales Price List.",
+ "fieldname": "lab_test_rate",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Standard Selling Rate"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": "",
- "columns": 0,
- "depends_on": "eval:doc.lab_test_template_type == 'Single'",
- "fieldname": "section_break_normal",
- "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": "Lab Routine",
- "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": "eval:doc.lab_test_template_type == 'Single'",
+ "fieldname": "section_break_normal",
+ "fieldtype": "Section Break",
+ "label": "Lab Routine"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lab_test_uom",
- "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": "UOM",
- "length": 0,
- "no_copy": 0,
- "options": "Lab Test 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": "lab_test_uom",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "in_list_view": 1,
+ "label": "UOM",
+ "options": "Lab Test UOM"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lab_test_normal_range",
- "fieldtype": "Long Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 1,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Normal Range",
- "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": "lab_test_normal_range",
+ "fieldtype": "Long Text",
+ "ignore_xss_filter": 1,
+ "label": "Normal Range"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_10",
- "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_10",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": "",
- "columns": 0,
- "depends_on": "eval:doc.lab_test_template_type == 'Compound'",
- "fieldname": "section_break_compound",
- "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": "Compound",
- "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": "eval:doc.lab_test_template_type == 'Compound'",
+ "fieldname": "section_break_compound",
+ "fieldtype": "Section Break",
+ "label": "Compound"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "normal_test_templates",
- "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,
- "length": 0,
- "no_copy": 0,
- "options": "Normal Test Template",
- "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": "normal_test_templates",
+ "fieldtype": "Table",
+ "options": "Normal Test Template"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:doc.lab_test_template_type == 'Descriptive'",
- "fieldname": "section_break_special",
- "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": "Special",
- "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": "eval:doc.lab_test_template_type == 'Descriptive'",
+ "fieldname": "section_break_special",
+ "fieldtype": "Section Break",
+ "label": "Special"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "0",
- "fieldname": "sensitivity",
- "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": "Sensitivity",
- "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": "sensitivity",
+ "fieldtype": "Check",
+ "label": "Sensitivity"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "special_test_template",
- "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,
- "length": 0,
- "no_copy": 0,
- "options": "Special Test Template",
- "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": "special_test_template",
+ "fieldtype": "Table",
+ "options": "Special Test Template"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:doc.lab_test_template_type == 'Grouped'",
- "fieldname": "section_break_group",
- "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": "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
- },
+ "depends_on": "eval:doc.lab_test_template_type == 'Grouped'",
+ "fieldname": "section_break_group",
+ "fieldtype": "Section Break",
+ "label": "Group"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lab_test_groups",
- "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": "",
- "length": 0,
- "no_copy": 0,
- "options": "Lab Test Groups",
- "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": "lab_test_groups",
+ "fieldtype": "Table",
+ "options": "Lab Test Groups"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_description",
- "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,
- "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": "section_break_description",
+ "fieldtype": "Section Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lab_test_description",
- "fieldtype": "Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 1,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Description",
- "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
- },
+ "fieldname": "lab_test_description",
+ "fieldtype": "Text",
+ "ignore_xss_filter": 1,
+ "label": "Description",
+ "no_copy": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "sb_sample_collection",
- "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": "Sample Collection",
- "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": "sb_sample_collection",
+ "fieldtype": "Section Break",
+ "label": "Sample Collection"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "sample",
- "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": 0,
- "label": "Sample",
- "length": 0,
- "no_copy": 0,
- "options": "Lab Test Sample",
- "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": "sample",
+ "fieldtype": "Link",
+ "ignore_user_permissions": 1,
+ "label": "Sample",
+ "options": "Lab Test Sample"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fetch_from": "sample.sample_uom",
- "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": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fetch_from": "sample.sample_uom",
+ "fieldname": "sample_uom",
+ "fieldtype": "Data",
+ "label": "UOM",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "0",
- "fieldname": "sample_quantity",
- "fieldtype": "Float",
- "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": "Quantity",
- "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": "sample_quantity",
+ "fieldtype": "Float",
+ "label": "Quantity"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "sample_collection_details",
- "fieldtype": "Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 1,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Collection 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
- },
+ "fieldname": "sample_collection_details",
+ "fieldtype": "Text",
+ "ignore_xss_filter": 1,
+ "label": "Collection Details"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "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": 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
- },
+ "default": "0",
+ "fieldname": "change_in_item",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "label": "Change In Item",
+ "no_copy": 1,
+ "print_hide": 1,
+ "report_hide": 1
+ },
{
- "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": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 1,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 1,
- "label": "disabled",
- "length": 0,
- "no_copy": 0,
- "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
+ "default": "0",
+ "fieldname": "disabled",
+ "fieldtype": "Check",
+ "label": "Disabled"
}
- ],
- "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-09-04 11:16:02.349707",
- "modified_by": "Administrator",
- "module": "Healthcare",
- "name": "Lab Test Template",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "links": [],
+ "modified": "2020-01-21 21:02:16.108347",
+ "modified_by": "ruchamahabal2@gmail.com",
+ "module": "Healthcare",
+ "name": "Lab Test Template",
+ "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
- },
+ },
{
- "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": "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": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "restrict_to_domain": "Healthcare",
- "search_fields": "lab_test_code,lab_test_name,lab_test_template_type",
- "show_name_in_global_search": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
- "title_field": "lab_test_name",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
+ ],
+ "restrict_to_domain": "Healthcare",
+ "search_fields": "lab_test_code,lab_test_name,lab_test_template_type",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "lab_test_name",
+ "track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
index 91488e3..fd7ae80 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py
@@ -9,59 +9,76 @@
from frappe import _
class LabTestTemplate(Document):
+ def after_insert(self):
+ if not self.item:
+ create_item_from_template(self)
+
+ def validate(self):
+ self.enable_disable_item()
+
def on_update(self):
- #Item and Price List update --> if (change_in_item)
- if(self.change_in_item and self.is_billable == 1 and self.item):
- updating_item(self)
- item_price = item_price_exist(self)
+ # if change_in_item update Item and Price List
+ if self.change_in_item and self.is_billable and self.item:
+ self.update_item()
+ item_price = self.item_price_exists()
if not item_price:
- if(self.lab_test_rate != 0.0):
+ if self.lab_test_rate != 0.0:
price_list_name = frappe.db.get_value("Price List", {"selling": 1})
- if(self.lab_test_rate):
+ if self.lab_test_rate:
make_item_price(self.lab_test_code, price_list_name, self.lab_test_rate)
else:
make_item_price(self.lab_test_code, price_list_name, 0.0)
else:
frappe.db.set_value("Item Price", item_price, "price_list_rate", self.lab_test_rate)
- 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)
+ 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 after_insert(self):
- if not self.item:
- create_item_from_template(self)
-
- #Call before delete the template
def on_trash(self):
- # remove template refernce from item and disable item
- if(self.item):
+ # remove template reference from item and disable item
+ if self.item:
try:
- frappe.delete_doc("Item",self.item, force=True)
+ frappe.delete_doc("Item", self.item)
except Exception:
- frappe.throw(_("""Not permitted. Please disable the Test Template"""))
+ frappe.throw(_("Not permitted. Please disable the Lab Test Template"))
-def item_price_exist(doc):
- item_price = frappe.db.exists({
- "doctype": "Item Price",
- "item_code": doc.lab_test_code})
- if(item_price):
- return item_price[0][0]
- else:
- return False
+ def enable_disable_item(self):
+ 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 updating_item(self):
- 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""",
- (self.lab_test_name, self.lab_test_group , self.lab_test_rate, self.lab_test_description, self.item))
+ def update_item(self):
+ item = frappe.get_doc("Item", self.item)
+ if item:
+ item.update({
+ "item_name": self.lab_test_name,
+ "item_group": self.lab_test_group,
+ "disabled": 0,
+ "standard_rate": self.lab_test_rate,
+ "description": self.lab_test_description
+ })
+ item.save()
+
+ def item_price_exists(self):
+ item_price = frappe.db.exists({"doctype": "Item Price", "item_code": self.lab_test_code})
+ if item_price:
+ return item_price[0][0]
+ else:
+ return False
+
def create_item_from_template(doc):
- if(doc.is_billable == 1):
+ if doc.is_billable:
disabled = 0
else:
disabled = 1
- #insert item
+ # insert item
item = frappe.get_doc({
"doctype": "Item",
"item_code": doc.lab_test_code,
@@ -78,9 +95,9 @@
"stock_uom": "Unit"
}).insert(ignore_permissions=True)
- #insert item price
- #get item price list to insert item price
- if(doc.lab_test_rate != 0.0):
+ # insert item price
+ # get item price list to insert item price
+ if doc.lab_test_rate != 0.0:
price_list_name = frappe.db.get_value("Price List", {"selling": 1})
if(doc.lab_test_rate):
make_item_price(item.name, price_list_name, doc.lab_test_rate)
@@ -89,10 +106,10 @@
make_item_price(item.name, price_list_name, 0.0)
item.standard_rate = 0.0
item.save(ignore_permissions = True)
- #Set item to the template
+ # Set item in the template
frappe.db.set_value("Lab Test Template", doc.name, "item", item.name)
- doc.reload() #refresh the doc after insert.
+ doc.reload()
def make_item_price(item, price_list_name, item_price):
frappe.get_doc({
@@ -104,22 +121,13 @@
@frappe.whitelist()
def change_test_code_from_template(lab_test_code, doc):
- args = json.loads(doc)
- doc = frappe._dict(args)
+ doc = frappe._dict(json.loads(doc))
- item_exist = frappe.db.exists({
- "doctype": "Item",
- "item_code": lab_test_code})
- if(item_exist):
- frappe.throw(_("Code {0} already exist").format(lab_test_code))
+ if frappe.db.exists({ "doctype": "Item", "item_code": lab_test_code}):
+ frappe.throw(_("Lab Test Item {0} already exist").format(lab_test_code))
else:
rename_doc("Item", doc.name, lab_test_code, ignore_permissions=True)
- frappe.db.set_value("Lab Test Template",doc.name,"lab_test_code",lab_test_code)
+ frappe.db.set_value("Lab Test Template", doc.name, "lab_test_code", lab_test_code)
+ frappe.db.set_value("Lab Test Template", doc.name, "lab_test_name", lab_test_code)
rename_doc("Lab Test Template", doc.name, lab_test_code, ignore_permissions=True)
- return lab_test_code
-
-@frappe.whitelist()
-def disable_enable_test_template(status, name, is_billable):
- frappe.db.set_value("Lab Test Template",name,"disabled",status)
- if(is_billable == 1):
- frappe.db.set_value("Item",name,"disabled",status)
+ return lab_test_code
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js b/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js
index a16a72f..a86075f 100644
--- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js
+++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template_list.js
@@ -3,13 +3,5 @@
*/
frappe.listview_settings['Lab Test Template'] = {
add_fields: ["lab_test_name", "lab_test_code", "lab_test_rate"],
- filters:[["disabled","=",0]],
- /* get_indicator: function(doc) {
- if(doc.disabled==1){
- return [__("Disabled"), "red", "disabled,=,Disabled"];
- }
- if(doc.disabled==0){
- return [__("Enabled"), "green", "disabled,=,0"];
- }
- } */
+ filters: [["disabled", "=", 0]]
};