fix: code clean-up
This commit is contained in:
parent
73edb12ab3
commit
afa001a1d1
@ -34,10 +34,10 @@ frappe.ui.form.on('Lab Test', {
|
|||||||
if (frm.doc.docstatus === 1 && frm.doc.status !== 'Approved' && frm.doc.status !== 'Rejected') {
|
if (frm.doc.docstatus === 1 && frm.doc.status !== 'Approved' && frm.doc.status !== 'Rejected') {
|
||||||
frm.add_custom_button(__('Approve'), function () {
|
frm.add_custom_button(__('Approve'), function () {
|
||||||
status_update(1, frm);
|
status_update(1, frm);
|
||||||
});
|
}, __('Actions'));
|
||||||
frm.add_custom_button(__('Reject'), function () {
|
frm.add_custom_button(__('Reject'), function () {
|
||||||
status_update(0, frm);
|
status_update(0, frm);
|
||||||
});
|
}, __('Actions'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ var make_dialog = function (frm, emailed, printed) {
|
|||||||
title: 'Send SMS',
|
title: 'Send SMS',
|
||||||
width: 400,
|
width: 400,
|
||||||
fields: [
|
fields: [
|
||||||
{ fieldname: 'sms_type', fieldtype: 'Select', label: 'Type', options: ['Emailed', 'Printed'] },
|
{ fieldname: 'result_format', fieldtype: 'Select', label: 'Result Format', options: ['Emailed', 'Printed'] },
|
||||||
{ fieldname: 'number', fieldtype: 'Data', label: 'Mobile Number', reqd: 1 },
|
{ fieldname: 'number', fieldtype: 'Data', label: 'Mobile Number', reqd: 1 },
|
||||||
{ fieldname: 'message', fieldtype: 'Small Text', label: 'Message', reqd: 1 }
|
{ fieldname: 'message', fieldtype: 'Small Text', label: 'Message', reqd: 1 }
|
||||||
],
|
],
|
||||||
@ -200,22 +200,22 @@ var make_dialog = function (frm, emailed, printed) {
|
|||||||
dialog.hide();
|
dialog.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (frm.doc.report_preference == 'Print') {
|
if (frm.doc.report_preference === 'Print') {
|
||||||
dialog.set_values({
|
dialog.set_values({
|
||||||
'sms_type': 'Printed',
|
'result_format': 'Printed',
|
||||||
'number': number,
|
'number': number,
|
||||||
'message': printed
|
'message': printed
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dialog.set_values({
|
dialog.set_values({
|
||||||
'sms_type': 'Emailed',
|
'result_format': 'Emailed',
|
||||||
'number': number,
|
'number': number,
|
||||||
'message': emailed
|
'message': emailed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var fd = dialog.fields_dict;
|
var fd = dialog.fields_dict;
|
||||||
$(fd.sms_type.input).change(function () {
|
$(fd.result_format.input).change(function () {
|
||||||
if (dialog.get_value('sms_type') == 'Emailed') {
|
if (dialog.get_value('result_format') === 'Emailed') {
|
||||||
dialog.set_values({
|
dialog.set_values({
|
||||||
'number': number,
|
'number': number,
|
||||||
'message': emailed
|
'message': emailed
|
||||||
|
|||||||
@ -103,7 +103,7 @@ def create_multiple(doctype, docname):
|
|||||||
lab_test_created = create_lab_test_from_encounter(docname)
|
lab_test_created = create_lab_test_from_encounter(docname)
|
||||||
|
|
||||||
if lab_test_created:
|
if lab_test_created:
|
||||||
frappe.msgprint(_('Lab Test(s) {0} created'.format(lab_test_created)))
|
frappe.msgprint(_('Lab Test(s) {0} created'.format(lab_test_created)), indicator='green')
|
||||||
else:
|
else:
|
||||||
frappe.msgprint(_('No Lab Tests created'))
|
frappe.msgprint(_('No Lab Tests created'))
|
||||||
|
|
||||||
@ -225,8 +225,9 @@ def create_sample_doc(template, patient, invoice, company = None):
|
|||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'sample': template.sample
|
'sample': template.sample
|
||||||
})
|
})
|
||||||
|
|
||||||
if sample_exists:
|
if sample_exists:
|
||||||
# Update Sample Collection by adding quantity
|
# update sample collection by adding quantity
|
||||||
sample_collection = frappe.get_doc('Sample Collection', sample_exists[0][0])
|
sample_collection = frappe.get_doc('Sample Collection', sample_exists[0][0])
|
||||||
quantity = int(sample_collection.sample_qty) + int(template.sample_qty)
|
quantity = int(sample_collection.sample_qty) + int(template.sample_qty)
|
||||||
if template.sample_details:
|
if template.sample_details:
|
||||||
@ -252,7 +253,7 @@ def create_sample_doc(template, patient, invoice, company = None):
|
|||||||
sample_collection.company = company
|
sample_collection.company = company
|
||||||
|
|
||||||
if template.sample_details:
|
if template.sample_details:
|
||||||
sample_collection.sample_details = 'Test :' + (template.get('lab_test_name') or template.get('template')) + '\n' + 'Collection Detials:\n\t' + template.sample_details
|
sample_collection.sample_details = _('Test :') + (template.get('lab_test_name') or template.get('template')) + '\n' + 'Collection Detials:\n\t' + template.sample_details
|
||||||
sample_collection.save(ignore_permissions=True)
|
sample_collection.save(ignore_permissions=True)
|
||||||
|
|
||||||
return sample_collection
|
return sample_collection
|
||||||
@ -270,10 +271,13 @@ def create_sample_collection(lab_test, template, patient, invoice):
|
|||||||
def load_result_format(lab_test, template, prescription, invoice):
|
def load_result_format(lab_test, template, prescription, invoice):
|
||||||
if template.lab_test_template_type == 'Single':
|
if template.lab_test_template_type == 'Single':
|
||||||
create_normals(template, lab_test)
|
create_normals(template, lab_test)
|
||||||
|
|
||||||
elif template.lab_test_template_type == 'Compound':
|
elif template.lab_test_template_type == 'Compound':
|
||||||
create_compounds(template, lab_test, False)
|
create_compounds(template, lab_test, False)
|
||||||
|
|
||||||
elif template.lab_test_template_type == 'Descriptive':
|
elif template.lab_test_template_type == 'Descriptive':
|
||||||
create_descriptives(template, lab_test)
|
create_descriptives(template, lab_test)
|
||||||
|
|
||||||
elif template.lab_test_template_type == 'Grouped':
|
elif template.lab_test_template_type == 'Grouped':
|
||||||
# Iterate for each template in the group and create one result for all.
|
# Iterate for each template in the group and create one result for all.
|
||||||
for lab_test_group in template.lab_test_groups:
|
for lab_test_group in template.lab_test_groups:
|
||||||
@ -283,6 +287,7 @@ def load_result_format(lab_test, template, prescription, invoice):
|
|||||||
if template_in_group:
|
if template_in_group:
|
||||||
if template_in_group.lab_test_template_type == 'Single':
|
if template_in_group.lab_test_template_type == 'Single':
|
||||||
create_normals(template_in_group, lab_test)
|
create_normals(template_in_group, lab_test)
|
||||||
|
|
||||||
elif template_in_group.lab_test_template_type == 'Compound':
|
elif template_in_group.lab_test_template_type == 'Compound':
|
||||||
normal_heading = lab_test.append('normal_test_items')
|
normal_heading = lab_test.append('normal_test_items')
|
||||||
normal_heading.lab_test_name = template_in_group.lab_test_name
|
normal_heading.lab_test_name = template_in_group.lab_test_name
|
||||||
@ -290,6 +295,7 @@ def load_result_format(lab_test, template, prescription, invoice):
|
|||||||
normal_heading.allow_blank = 1
|
normal_heading.allow_blank = 1
|
||||||
normal_heading.template = template_in_group.name
|
normal_heading.template = template_in_group.name
|
||||||
create_compounds(template_in_group, lab_test, True)
|
create_compounds(template_in_group, lab_test, True)
|
||||||
|
|
||||||
elif template_in_group.lab_test_template_type == 'Descriptive':
|
elif template_in_group.lab_test_template_type == 'Descriptive':
|
||||||
descriptive_heading = lab_test.append('descriptive_test_items')
|
descriptive_heading = lab_test.append('descriptive_test_items')
|
||||||
descriptive_heading.lab_test_name = template_in_group.lab_test_name
|
descriptive_heading.lab_test_name = template_in_group.lab_test_name
|
||||||
@ -297,6 +303,7 @@ def load_result_format(lab_test, template, prescription, invoice):
|
|||||||
descriptive_heading.allow_blank = 1
|
descriptive_heading.allow_blank = 1
|
||||||
descriptive_heading.template = template_in_group.name
|
descriptive_heading.template = template_in_group.name
|
||||||
create_descriptives(template_in_group, lab_test)
|
create_descriptives(template_in_group, lab_test)
|
||||||
|
|
||||||
else: # Lab Test Group - Add New Line
|
else: # Lab Test Group - Add New Line
|
||||||
normal = lab_test.append('normal_test_items')
|
normal = lab_test.append('normal_test_items')
|
||||||
normal.lab_test_name = lab_test_group.group_event
|
normal.lab_test_name = lab_test_group.group_event
|
||||||
@ -307,6 +314,7 @@ def load_result_format(lab_test, template, prescription, invoice):
|
|||||||
normal.allow_blank = lab_test_group.allow_blank
|
normal.allow_blank = lab_test_group.allow_blank
|
||||||
normal.require_result_value = 1
|
normal.require_result_value = 1
|
||||||
normal.template = template.name
|
normal.template = template.name
|
||||||
|
|
||||||
if template.lab_test_template_type != 'No Result':
|
if template.lab_test_template_type != 'No Result':
|
||||||
if prescription:
|
if prescription:
|
||||||
lab_test.prescription = prescription
|
lab_test.prescription = prescription
|
||||||
|
|||||||
@ -24,7 +24,7 @@ frappe.listview_settings['Lab Test'] = {
|
|||||||
|
|
||||||
var create_multiple_dialog = function (listview) {
|
var create_multiple_dialog = function (listview) {
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
title: 'Create Multiple Lab Test',
|
title: 'Create Multiple Lab Tests',
|
||||||
width: 100,
|
width: 100,
|
||||||
fields: [
|
fields: [
|
||||||
{ fieldtype: 'Link', label: 'Patient', fieldname: 'patient', options: 'Patient', reqd: 1 },
|
{ fieldtype: 'Link', label: 'Patient', fieldname: 'patient', options: 'Patient', reqd: 1 },
|
||||||
@ -44,7 +44,7 @@ var create_multiple_dialog = function (listview) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
primary_action_label: __('Create Lab Test'),
|
primary_action_label: __('Create'),
|
||||||
primary_action: function () {
|
primary_action: function () {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.healthcare.doctype.lab_test.lab_test.create_multiple',
|
method: 'erpnext.healthcare.doctype.lab_test.lab_test.create_multiple',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user