[Fix] Healthcare minor fixes and field rename (#15413)

* Healthcare practitoiner in Clinical Procedure

* Insert and Update Patient Medical Record from Healthcare DocTypes

* vital signs remove extra columns

* Rename Healthcare Field test_name

* Healthcare Util - get_drugs_to_invoice - fix

* Rename Healthcare Field test_code

* Rename Healthcare Field test_comment

* Rename Healthcare Field test_created

* Rename Healthcare Field test_template

* Rename Healthcare Field test_rate

* Rename Healthcare Field test_description

* Rename Healthcare Field test_groups

* Rename Healthcare Field test_group

* Rename Healthcare Field test_template_type

* Rename Healthcare Field test_uom

* Rename Healthcare Field test_normal_range

* Rename Healthcare Field test_event

* Rename Healthcare Field test_prescription

* Rename Healthcare Field test_particulars

* Patch - Rename healthcare fields

* Sales Invoice - Filter updated for get drugs to invoice

* Patient Appointment - fix - get_event
This commit is contained in:
Jamsheer 2018-09-18 10:54:03 +05:30 committed by Nabin Hait
parent 267e806d7f
commit c07e8e5b0d
32 changed files with 526 additions and 318 deletions

View File

@ -1034,7 +1034,7 @@ var get_drugs_to_invoice = function(frm) {
description:'Quantity will be calculated only for items which has "Nos" as UoM. You may change as required for each invoice item.',
get_query: function(doc) {
return {
filters: { patient :dialog.get_value("patient") }
filters: { patient: dialog.get_value("patient"), docstatus: 1 }
};
}
},

View File

@ -48,6 +48,13 @@ frappe.ui.form.on('Clinical Procedure', {
}
};
});
frm.set_query("practitioner", function() {
return {
filters: {
'department': frm.doc.medical_department
}
};
});
if(frm.doc.consume_stock){
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.actual_qty) ? "green" : "orange" ; });
@ -217,6 +224,20 @@ frappe.ui.form.on('Clinical Procedure', {
}
});
}
},
practitioner: function(frm) {
if(frm.doc.practitioner){
frappe.call({
"method": "frappe.client.get",
args: {
doctype: "Healthcare Practitioner",
name: frm.doc.practitioner
},
callback: function (data) {
frappe.model.set_value(frm.doctype,frm.docname, "medical_department",data.message.department);
}
});
}
}
});

View File

@ -212,39 +212,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "procedure_template",
"fieldtype": "Link",
"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": "Procedure Template",
"length": 0,
"no_copy": 0,
"options": "Clinical Procedure 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": 1,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -311,6 +278,39 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "practitioner",
"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": "Healthcare Practitioner",
"length": 0,
"no_copy": 0,
"options": "Healthcare Practitioner",
"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": 1,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -342,6 +342,39 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "procedure_template",
"fieldtype": "Link",
"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": "Procedure Template",
"length": 0,
"no_copy": 0,
"options": "Clinical Procedure 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": 1,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,

View File

@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import cint, flt, nowdate, nowtime
from frappe.utils import cint, flt, nowdate, nowtime, cstr
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_account
from erpnext.healthcare.doctype.lab_test.lab_test import create_sample_doc
from erpnext.stock.stock_ledger import get_previous_sle
@ -81,9 +81,9 @@ class ClinicalProcedure(Document):
allow_start = self.set_actual_qty()
if allow_start:
self.status = 'In Progress'
insert_clinical_procedure_to_medical_record(self)
else:
self.status = 'Draft'
self.save()
def set_actual_qty(self):
@ -201,3 +201,18 @@ def create_procedure(appointment):
if warehouse:
procedure.warehouse = warehouse
return procedure.as_dict()
def insert_clinical_procedure_to_medical_record(doc):
subject = cstr(doc.procedure_template) +" "+ doc.practitioner
if subject and doc.notes:
subject += "<br/>"+doc.notes
medical_record = frappe.new_doc("Patient Medical Record")
medical_record.patient = doc.patient
medical_record.subject = subject
medical_record.status = "Open"
medical_record.communication_date = doc.start_date
medical_record.reference_doctype = "Clinical Procedure"
medical_record.reference_name = doc.name
medical_record.reference_owner = doc.owner
medical_record.save(ignore_permissions=True)

View File

@ -1226,7 +1226,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Hello {{doc.patient}}, Your {{doc.test_name}} result is ready with {{doc.company }}. \nThank You, Good day!",
"default": "Hello {{doc.patient}}, Your {{doc.lab_test_name}} result is ready with {{doc.company }}. \nThank You, Good day!",
"fieldname": "sms_printed",
"fieldtype": "Small Text",
"hidden": 0,
@ -1290,7 +1290,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Hello {{doc.patient}}, Your {{doc.test_name}} result has been emailed to {{doc.email}}. \n{{doc.company }}. \nThank You, Good day!",
"default": "Hello {{doc.patient}}, Your {{doc.lab_test_name}} result has been emailed to {{doc.email}}. \n{{doc.company }}. \nThank You, Good day!",
"fieldname": "sms_emailed",
"fieldtype": "Small Text",
"hidden": 0,
@ -1327,7 +1327,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-03 15:18:36.631441",
"modified": "2018-09-03 11:46:25.317482",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Settings",

View File

@ -18,7 +18,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_code",
"fieldname": "lab_test_code",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -51,8 +51,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "test_code.test_name",
"fieldname": "test_name",
"fetch_from": "lab_test_code.lab_test_name",
"fieldname": "lab_test_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -150,7 +150,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_comment",
"fieldname": "lab_test_comment",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
@ -182,7 +182,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_created",
"fieldname": "lab_test_created",
"fieldtype": "Check",
"hidden": 1,
"ignore_user_permissions": 0,
@ -218,7 +218,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-08-06 16:53:02.033406",
"modified": "2018-09-04 09:02:18.592637",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Prescription",

View File

@ -10,14 +10,14 @@ cur_frm.cscript.custom_refresh = function(doc) {
frappe.ui.form.on('Lab Test', {
setup: function(frm) {
frm.get_field('normal_test_items').grid.editable_fields = [
{fieldname: 'test_name', columns: 3},
{fieldname: 'test_event', columns: 2},
{fieldname: 'lab_test_name', columns: 3},
{fieldname: 'lab_test_event', columns: 2},
{fieldname: 'result_value', columns: 2},
{fieldname: 'test_uom', columns: 1},
{fieldname: 'lab_test_uom', columns: 1},
{fieldname: 'normal_range', columns: 2}
];
frm.get_field('special_test_items').grid.editable_fields = [
{fieldname: 'test_particulars', columns: 3},
{fieldname: 'lab_test_particulars', columns: 3},
{fieldname: 'result_value', columns: 7}
];
},

View File

@ -54,7 +54,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "",
"fieldname": "naming_series",
"fieldtype": "Select",
"hidden": 0,
@ -67,7 +66,7 @@
"label": "Series",
"length": 0,
"no_copy": 0,
"options": "HLC-LT-.YYYY.-",
"options": "LP-",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -810,7 +809,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_name",
"fieldname": "lab_test_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -906,7 +905,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_group",
"fieldname": "lab_test_group",
"fieldtype": "Link",
"hidden": 1,
"ignore_user_permissions": 0,
@ -1159,7 +1158,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_comment",
"fieldname": "lab_test_comment",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
@ -1518,7 +1517,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-21 14:44:21.605374",
"modified": "2018-09-04 10:19:33.422304",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test",
@ -1587,7 +1586,7 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "patient,practitioner,test_name,sample",
"search_fields": "patient,practitioner,lab_test_name,sample",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
@ -1595,4 +1594,4 @@
"track_changes": 1,
"track_seen": 1,
"track_views": 0
}
}

View File

@ -28,10 +28,10 @@ class LabTest(Document):
def after_insert(self):
if(self.prescription):
frappe.db.set_value("Lab Prescription", self.prescription, "test_created", 1)
frappe.db.set_value("Lab Prescription", self.prescription, "lab_test_created", 1)
if frappe.db.get_value("Lab Prescription", self.prescription, 'invoiced') == 1:
self.invoiced = True
if not self.test_name and self.template:
if not self.lab_test_name and self.template:
self.load_test_from_template()
self.reload()
@ -44,10 +44,10 @@ def create_test_from_template(lab_test):
template = frappe.get_doc("Lab Test Template", lab_test.template)
patient = frappe.get_doc("Patient", lab_test.patient)
lab_test.test_name = template.test_name
lab_test.lab_test_name = template.lab_test_name
lab_test.result_date = getdate()
lab_test.department = template.department
lab_test.test_group = template.test_group
lab_test.lab_test_group = template.lab_test_group
lab_test = create_sample_collection(lab_test, template, patient, None)
lab_test = load_result_format(lab_test, template, None, None)
@ -77,10 +77,10 @@ def create_lab_test_from_encounter(encounter_id):
lab_test_created = False
encounter = frappe.get_doc("Patient Encounter", encounter_id)
lab_test_ids = frappe.db.sql("""select lp.name, lp.test_code, lp.invoiced
lab_test_ids = frappe.db.sql("""select lp.name, lp.lab_test_code, lp.invoiced
from `tabPatient Encounter` et, `tabLab Prescription` lp
where et.patient=%s and lp.parent=%s and
lp.parent=et.name and lp.test_created=0 and et.docstatus=1""", (encounter.patient, encounter_id))
lp.parent=et.name and lp.lab_test_created=0 and et.docstatus=1""", (encounter.patient, encounter_id))
if lab_test_ids:
patient = frappe.get_doc("Patient", encounter.patient)
@ -89,7 +89,7 @@ def create_lab_test_from_encounter(encounter_id):
if template:
lab_test = create_lab_test_doc(lab_test_id[2], encounter.practitioner, patient, template)
lab_test.save(ignore_permissions = True)
frappe.db.set_value("Lab Prescription", lab_test_id[0], "test_created", 1)
frappe.db.set_value("Lab Prescription", lab_test_id[0], "lab_test_created", 1)
if not lab_test_created:
lab_test_created = lab_test.name
else:
@ -98,17 +98,17 @@ def create_lab_test_from_encounter(encounter_id):
def create_lab_test_from_invoice(invoice_name):
lab_test_created = False
lab_tests_created = False
invoice = frappe.get_doc("Sales Invoice", invoice_name)
if invoice.patient:
patient = frappe.get_doc("Patient", invoice.patient)
for item in invoice.items:
test_created = 0
lab_test_created = 0
if item.reference_dt == "Lab Prescription":
test_created = frappe.db.get_value("Lab Prescription", item.reference_dn, "test_created")
lab_test_created = frappe.db.get_value("Lab Prescription", item.reference_dn, "lab_test_created")
elif item.reference_dt == "Lab Test":
test_created = 1
if test_created != 1:
lab_test_created = 1
if lab_test_created != 1:
template = get_lab_test_template(item.item_code)
if template:
lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template)
@ -118,11 +118,11 @@ def create_lab_test_from_invoice(invoice_name):
if item.reference_dt != "Lab Prescription":
frappe.db.set_value("Sales Invoice Item", item.name, "reference_dt", "Lab Test")
frappe.db.set_value("Sales Invoice Item", item.name, "reference_dn", lab_test.name)
if not lab_test_created:
lab_test_created = lab_test.name
if not lab_tests_created:
lab_tests_created = lab_test.name
else:
lab_test_created += ", "+lab_test.name
return lab_test_created
lab_tests_created += ", "+lab_test.name
return lab_tests_created
def get_lab_test_template(item):
template_id = check_template_exists(item)
@ -152,7 +152,7 @@ def create_lab_test_doc(invoiced, practitioner, patient, template):
lab_test.mobile = patient.mobile
lab_test.department = template.department
lab_test.template = template.name
lab_test.test_group = template.test_group
lab_test.lab_test_group = template.lab_test_group
lab_test.result_date = getdate()
lab_test.report_preference = patient.report_preference
return lab_test
@ -160,9 +160,9 @@ def create_lab_test_doc(invoiced, practitioner, patient, template):
def create_normals(template, lab_test):
lab_test.normal_toggle = "1"
normal = lab_test.append("normal_test_items")
normal.test_name = template.test_name
normal.test_uom = template.test_uom
normal.normal_range = template.test_normal_range
normal.lab_test_name = template.lab_test_name
normal.lab_test_uom = template.lab_test_uom
normal.normal_range = template.lab_test_normal_range
normal.require_result_value = 1
normal.template = template.name
@ -171,11 +171,11 @@ def create_compounds(template, lab_test, is_group):
for normal_test_template in template.normal_test_templates:
normal = lab_test.append("normal_test_items")
if is_group:
normal.test_event = normal_test_template.test_event
normal.lab_test_event = normal_test_template.lab_test_event
else:
normal.test_name = normal_test_template.test_event
normal.lab_test_name = normal_test_template.lab_test_event
normal.test_uom = normal_test_template.test_uom
normal.lab_test_uom = normal_test_template.lab_test_uom
normal.normal_range = normal_test_template.normal_range
normal.require_result_value = 1
normal.template = template.name
@ -186,7 +186,7 @@ def create_specials(template, lab_test):
lab_test.sensitivity_toggle = "1"
for special_test_template in template.special_test_template:
special = lab_test.append("special_test_items")
special.test_particulars = special_test_template.particulars
special.lab_test_particulars = special_test_template.particulars
special.require_result_value = 1
special.template = template.name
@ -202,7 +202,7 @@ def create_sample_doc(template, patient, invoice):
sample_collection = frappe.get_doc("Sample Collection",sample_exist[0][0])
quantity = int(sample_collection.sample_quantity)+int(template.sample_quantity)
if(template.sample_collection_details):
sample_collection_details = sample_collection.sample_collection_details+"\n==============\n"+"Test :"+template.test_name+"\n"+"Collection Detials:\n\t"+template.sample_collection_details
sample_collection_details = sample_collection.sample_collection_details+"\n==============\n"+"Test :"+template.lab_test_name+"\n"+"Collection Detials:\n\t"+template.sample_collection_details
frappe.db.set_value("Sample Collection", sample_collection.name, "sample_collection_details",sample_collection_details)
frappe.db.set_value("Sample Collection", sample_collection.name, "sample_quantity",quantity)
@ -218,7 +218,7 @@ def create_sample_doc(template, patient, invoice):
sample_collection.sample_uom = template.sample_uom
sample_collection.sample_quantity = template.sample_quantity
if(template.sample_collection_details):
sample_collection.sample_collection_details = "Test :"+template.test_name+"\n"+"Collection Detials:\n\t"+template.sample_collection_details
sample_collection.sample_collection_details = "Test :"+template.lab_test_name+"\n"+"Collection Detials:\n\t"+template.sample_collection_details
sample_collection.save(ignore_permissions=True)
return sample_collection
@ -231,42 +231,42 @@ def create_sample_collection(lab_test, template, patient, invoice):
return lab_test
def load_result_format(lab_test, template, prescription, invoice):
if(template.test_template_type == 'Single'):
if(template.lab_test_template_type == 'Single'):
create_normals(template, lab_test)
elif(template.test_template_type == 'Compound'):
elif(template.lab_test_template_type == 'Compound'):
create_compounds(template, lab_test, False)
elif(template.test_template_type == 'Descriptive'):
elif(template.lab_test_template_type == 'Descriptive'):
create_specials(template, lab_test)
elif(template.test_template_type == 'Grouped'):
elif(template.lab_test_template_type == 'Grouped'):
#iterate for each template in the group and create one result for all.
for test_group in template.test_groups:
for lab_test_group in template.lab_test_groups:
#template_in_group = None
if(test_group.test_template):
if(lab_test_group.lab_test_template):
template_in_group = frappe.get_doc("Lab Test Template",
test_group.test_template)
lab_test_group.lab_test_template)
if(template_in_group):
if(template_in_group.test_template_type == 'Single'):
if(template_in_group.lab_test_template_type == 'Single'):
create_normals(template_in_group, lab_test)
elif(template_in_group.test_template_type == 'Compound'):
elif(template_in_group.lab_test_template_type == 'Compound'):
normal_heading = lab_test.append("normal_test_items")
normal_heading.test_name = template_in_group.test_name
normal_heading.lab_test_name = template_in_group.lab_test_name
normal_heading.require_result_value = 0
normal_heading.template = template_in_group.name
create_compounds(template_in_group, lab_test, True)
elif(template_in_group.test_template_type == 'Descriptive'):
elif(template_in_group.lab_test_template_type == 'Descriptive'):
special_heading = lab_test.append("special_test_items")
special_heading.test_name = template_in_group.test_name
special_heading.lab_test_name = template_in_group.lab_test_name
special_heading.require_result_value = 0
special_heading.template = template_in_group.name
create_specials(template_in_group, lab_test)
else:
normal = lab_test.append("normal_test_items")
normal.test_name = test_group.group_event
normal.test_uom = test_group.group_test_uom
normal.normal_range = test_group.group_test_normal_range
normal.lab_test_name = lab_test_group.group_event
normal.lab_test_uom = lab_test_group.group_test_uom
normal.normal_range = lab_test_group.group_test_normal_range
normal.require_result_value = 1
normal.template = template.name
if(template.test_template_type != 'No Result'):
if(template.lab_test_template_type != 'No Result'):
if(prescription):
lab_test.prescription = prescription
if(invoice):
@ -281,9 +281,35 @@ def get_employee_by_user_id(user_id):
return employee
def insert_lab_test_to_medical_record(doc):
subject = cstr(doc.test_name)
if(doc.test_comment):
subject += ", \n"+ cstr(doc.test_comment)
table_row = False
subject = cstr(doc.lab_test_name)
if doc.practitioner:
subject += " "+ doc.practitioner
if doc.normal_test_items:
item = doc.normal_test_items[0]
comment = ""
if item.lab_test_comment:
comment = str(item.lab_test_comment)
event = ""
if item.lab_test_event:
event = item.lab_test_event
table_row = item.lab_test_name +" "+ event +" "+ item.result_value
if item.normal_range:
table_row += " normal_range("+item.normal_range+")"
table_row += " "+comment
elif doc.special_test_items:
item = doc.special_test_items[0]
table_row = item.lab_test_particulars +" "+ item.result_value
elif doc.sensitivity_test_items:
item = doc.sensitivity_test_items[0]
table_row = item.antibiotic +" "+ item.antibiotic_sensitivity
if table_row:
subject += "<br/>"+table_row
if doc.lab_test_comment:
subject += "<br/>"+ cstr(doc.lab_test_comment)
medical_record = frappe.new_doc("Patient Medical Record")
medical_record.patient = doc.patient
@ -303,5 +329,5 @@ def delete_lab_test_from_medical_record(self):
@frappe.whitelist()
def get_lab_test_prescribed(patient):
return frappe.db.sql("""select cp.name, cp.test_code, cp.parent, cp.invoiced, ct.practitioner, ct.encounter_date from `tabPatient Encounter` ct,
`tabLab Prescription` cp where ct.patient=%s and cp.parent=ct.name and cp.test_created=0""", (patient))
return frappe.db.sql("""select cp.name, cp.lab_test_code, cp.parent, cp.invoiced, ct.practitioner, ct.encounter_date from `tabPatient Encounter` ct,
`tabLab Prescription` cp where ct.patient=%s and cp.parent=ct.name and cp.lab_test_created=0""", (patient))

View File

@ -13,6 +13,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -42,17 +43,18 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 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.template_or_new_line == 'Add Test'",
"fieldname": "test_template",
"fieldname": "lab_test_template",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -75,17 +77,18 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "test_template.test_rate",
"fieldname": "test_rate",
"fetch_from": "lab_test_template.lab_test_rate",
"fieldname": "lab_test_rate",
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
@ -108,17 +111,18 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "test_template.test_description",
"fieldname": "test_description",
"fetch_from": "lab_test_template.lab_test_description",
"fieldname": "lab_test_description",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -141,11 +145,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -173,11 +178,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -206,11 +212,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -238,11 +245,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -268,7 +276,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
}
],
@ -282,7 +290,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-05-25 22:43:38.667043",
"modified": "2018-09-04 09:49:24.817787",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test Groups",
@ -297,5 +305,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

View File

@ -2,18 +2,18 @@
// License: ESS license.txt
frappe.ui.form.on("Lab Test Template",{
test_name: function(frm) {
if(!frm.doc.test_code)
frm.set_value("test_code", frm.doc.test_name);
if(!frm.doc.test_description)
frm.set_value("test_description", frm.doc.test_name);
lab_test_name: function(frm) {
if(!frm.doc.lab_test_code)
frm.set_value("lab_test_code", frm.doc.lab_test_name);
if(!frm.doc.lab_test_description)
frm.set_value("lab_test_description", frm.doc.lab_test_name);
},
refresh : function(frm){
// Restrict Special, Grouped type templates in Child TestGroups
frm.set_query("test_template", "test_groups", function() {
frm.set_query("lab_test_template", "lab_test_groups", function() {
return {
filters: {
test_template_type:['in',['Single','Compound']]
lab_test_template_type:['in',['Single','Compound']]
}
};
});
@ -21,7 +21,7 @@ frappe.ui.form.on("Lab Test Template",{
});
cur_frm.cscript.custom_refresh = function(doc) {
cur_frm.set_df_property("test_code", "read_only", doc.__islocal ? 0 : 1);
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() {
@ -88,13 +88,13 @@ var change_template_code = function(frm,doc){
});
d.show();
d.set_values({
'Test Code': doc.test_code
'Test Code': doc.lab_test_code
});
var change_test_code_from_template = function(test_code,doc){
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": {test_code: test_code, doc: doc},
"args": {lab_test_code: lab_test_code, doc: doc},
callback: function (data) {
frappe.set_route("Form", "Lab Test Template", data.message);
}
@ -102,22 +102,22 @@ var change_template_code = function(frm,doc){
};
};
frappe.ui.form.on("Lab Test Template", "test_name", function(frm){
frappe.ui.form.on("Lab Test Template", "lab_test_name", function(frm){
frm.doc.change_in_item = 1;
});
frappe.ui.form.on("Lab Test Template", "test_rate", function(frm){
frappe.ui.form.on("Lab Test Template", "lab_test_rate", function(frm){
frm.doc.change_in_item = 1;
});
frappe.ui.form.on("Lab Test Template", "test_group", function(frm){
frappe.ui.form.on("Lab Test Template", "lab_test_group", function(frm){
frm.doc.change_in_item = 1;
});
frappe.ui.form.on("Lab Test Template", "test_description", function(frm){
frappe.ui.form.on("Lab Test Template", "lab_test_description", function(frm){
frm.doc.change_in_item = 1;
@ -126,7 +126,7 @@ frappe.ui.form.on("Lab Test Template", "test_description", function(frm){
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"){
frappe.model.set_value(cdt, cdn, 'test_template', "");
frappe.model.set_value(cdt, cdn, 'test_description', "");
frappe.model.set_value(cdt, cdn, 'lab_test_template', "");
frappe.model.set_value(cdt, cdn, 'lab_test_description', "");
}
});

View File

@ -3,7 +3,7 @@
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:test_code",
"autoname": "field:lab_test_code",
"beta": 1,
"creation": "2016-03-29 17:35:36.761223",
"custom": 0,
@ -19,7 +19,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_name",
"fieldname": "lab_test_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -84,7 +84,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_code",
"fieldname": "lab_test_code",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -104,10 +104,10 @@
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"unique": 1
},
{
"allow_bulk_edit": 0,
@ -117,7 +117,7 @@
"collapsible": 0,
"columns": 0,
"description": "",
"fieldname": "test_group",
"fieldname": "lab_test_group",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -216,7 +216,7 @@
"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": "test_template_type",
"fieldname": "lab_test_template_type",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
@ -250,7 +250,7 @@
"collapsible": 0,
"columns": 0,
"default": "1",
"depends_on": "eval:doc.test_template_type != 'Grouped'",
"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",
@ -286,7 +286,7 @@
"columns": 0,
"depends_on": "eval:doc.is_billable == 1",
"description": "This value is updated in the Default Sales Price List.",
"fieldname": "test_rate",
"fieldname": "lab_test_rate",
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
@ -319,7 +319,7 @@
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:doc.test_template_type == 'Single'",
"depends_on": "eval:doc.lab_test_template_type == 'Single'",
"fieldname": "section_break_normal",
"fieldtype": "Section Break",
"hidden": 0,
@ -352,7 +352,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_uom",
"fieldname": "lab_test_uom",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -385,7 +385,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_normal_range",
"fieldname": "lab_test_normal_range",
"fieldtype": "Long Text",
"hidden": 0,
"ignore_user_permissions": 0,
@ -449,7 +449,7 @@
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:doc.test_template_type == 'Compound'",
"depends_on": "eval:doc.lab_test_template_type == 'Compound'",
"fieldname": "section_break_compound",
"fieldtype": "Section Break",
"hidden": 0,
@ -514,7 +514,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.test_template_type == 'Descriptive'",
"depends_on": "eval:doc.lab_test_template_type == 'Descriptive'",
"fieldname": "section_break_special",
"fieldtype": "Section Break",
"hidden": 0,
@ -612,7 +612,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.test_template_type == 'Grouped'",
"depends_on": "eval:doc.lab_test_template_type == 'Grouped'",
"fieldname": "section_break_group",
"fieldtype": "Section Break",
"hidden": 0,
@ -645,7 +645,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_groups",
"fieldname": "lab_test_groups",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
@ -709,7 +709,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_description",
"fieldname": "lab_test_description",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
@ -975,7 +975,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-07-02 11:58:00.266070",
"modified": "2018-09-04 11:16:02.349707",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test Template",
@ -1025,11 +1025,12 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "test_code,test_name,test_template_type",
"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": "test_name",
"title_field": "lab_test_name",
"track_changes": 1,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

View File

@ -14,14 +14,14 @@ class LabTestTemplate(Document):
updating_item(self)
item_price = item_price_exist(self)
if not item_price:
if(self.test_rate != 0.0):
if(self.lab_test_rate != 0.0):
price_list_name = frappe.db.get_value("Price List", {"selling": 1})
if(self.test_rate):
make_item_price(self.test_code, price_list_name, self.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.test_code, price_list_name, 0.0)
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.test_rate)
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):
@ -44,7 +44,7 @@ class LabTestTemplate(Document):
def item_price_exist(doc):
item_price = frappe.db.exists({
"doctype": "Item Price",
"item_code": doc.test_code})
"item_code": doc.lab_test_code})
if(item_price):
return item_price[0][0]
else:
@ -53,7 +53,7 @@ def item_price_exist(doc):
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.test_name, self.test_group , self.test_rate, self.test_description, self.item))
(self.lab_test_name, self.lab_test_group , self.lab_test_rate, self.lab_test_description, self.item))
def create_item_from_template(doc):
if(doc.is_billable == 1):
@ -63,10 +63,10 @@ def create_item_from_template(doc):
#insert item
item = frappe.get_doc({
"doctype": "Item",
"item_code": doc.test_code,
"item_name":doc.test_name,
"item_group": doc.test_group,
"description":doc.test_description,
"item_code": doc.lab_test_code,
"item_name":doc.lab_test_name,
"item_group": doc.lab_test_group,
"description":doc.lab_test_description,
"is_sales_item": 1,
"is_service_item": 1,
"is_purchase_item": 0,
@ -79,11 +79,11 @@ def create_item_from_template(doc):
#insert item price
#get item price list to insert item price
if(doc.test_rate != 0.0):
if(doc.lab_test_rate != 0.0):
price_list_name = frappe.db.get_value("Price List", {"selling": 1})
if(doc.test_rate):
make_item_price(item.name, price_list_name, doc.test_rate)
item.standard_rate = doc.test_rate
if(doc.lab_test_rate):
make_item_price(item.name, price_list_name, doc.lab_test_rate)
item.standard_rate = doc.lab_test_rate
else:
make_item_price(item.name, price_list_name, 0.0)
item.standard_rate = 0.0
@ -102,20 +102,20 @@ def make_item_price(item, price_list_name, item_price):
}).insert(ignore_permissions=True)
@frappe.whitelist()
def change_test_code_from_template(test_code, doc):
def change_test_code_from_template(lab_test_code, doc):
args = json.loads(doc)
doc = frappe._dict(args)
item_exist = frappe.db.exists({
"doctype": "Item",
"item_code": test_code})
"item_code": lab_test_code})
if(item_exist):
frappe.throw(_("Code {0} already exist").format(test_code))
frappe.throw(_("Code {0} already exist").format(lab_test_code))
else:
frappe.rename_doc("Item", doc.name, test_code, ignore_permissions = True)
frappe.db.set_value("Lab Test Template",doc.name,"test_code",test_code)
frappe.rename_doc("Lab Test Template", doc.name, test_code, ignore_permissions = True)
return test_code
frappe.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.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):

View File

@ -2,7 +2,7 @@
(c) ESS 2015-16
*/
frappe.listview_settings['Lab Test Template'] = {
add_fields: ["test_name", "test_code", "test_rate"],
add_fields: ["lab_test_name", "lab_test_code", "lab_test_rate"],
filters:[["disabled","=",0]],
/* get_indicator: function(doc) {
if(doc.disabled==1){

View File

@ -3,7 +3,7 @@
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:test_uom",
"autoname": "field:lab_test_uom",
"beta": 1,
"creation": "2016-03-29 17:28:08.630148",
"custom": 0,
@ -14,11 +14,12 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_uom",
"fieldname": "lab_test_uom",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -27,7 +28,7 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Test UOM",
"label": "Lab Test UOM",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -40,10 +41,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
"translatable": 0,
"unique": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -70,6 +73,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -83,7 +87,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-05 11:24:15.687464",
"modified": "2018-09-04 11:02:53.202718",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test UOM",
@ -92,7 +96,6 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@ -112,7 +115,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
@ -135,11 +137,12 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "test_uom",
"search_fields": "lab_test_uom",
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "test_uom",
"title_field": "lab_test_uom",
"track_changes": 1,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

View File

@ -13,11 +13,12 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_name",
"fieldname": "lab_test_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -39,15 +40,17 @@
"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,
"fieldname": "test_event",
"fieldname": "lab_test_event",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -69,10 +72,12 @@
"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,
@ -100,15 +105,17 @@
"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,
"fieldname": "test_uom",
"fieldname": "lab_test_uom",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -130,10 +137,12 @@
"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,
@ -160,15 +169,17 @@
"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,
"fieldname": "test_comment",
"fieldname": "lab_test_comment",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
@ -190,10 +201,12 @@
"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,
@ -221,10 +234,12 @@
"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,
@ -252,6 +267,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -265,7 +281,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-10-04 17:13:06.376928",
"modified": "2018-09-04 11:42:43.095726",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Normal Test Items",
@ -280,5 +296,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

View File

@ -13,6 +13,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -39,15 +40,17 @@
"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,
"fieldname": "test_event",
"fieldname": "lab_test_event",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -69,15 +72,17 @@
"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,
"fieldname": "test_uom",
"fieldname": "lab_test_uom",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -100,10 +105,12 @@
"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,
@ -130,10 +137,12 @@
"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,
@ -159,6 +168,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -172,7 +182,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-10-04 16:58:43.990804",
"modified": "2018-09-04 11:42:30.766950",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Normal Test Template",
@ -187,5 +197,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

View File

@ -337,7 +337,7 @@ def get_events(start, end, filters=None):
from frappe.desk.calendar import get_event_conditions
conditions = get_event_conditions("Patient Appointment", filters)
data = frappe.db.sql("""select name, patient, physician, status,
data = frappe.db.sql("""select name, patient, practitioner, status,
duration, timestamp(appointment_date, appointment_time) as
'appointment_date' from `tabPatient Appointment` where
(appointment_date between %(start)s and %(end)s)

View File

@ -9,16 +9,16 @@ frappe.ui.form.on('Patient Encounter', {
{fieldname: 'dosage', columns: 2},
{fieldname: 'period', columns: 2}
];
frm.get_field('test_prescription').grid.editable_fields = [
{fieldname: 'test_code', columns: 2},
{fieldname: 'test_name', columns: 4},
{fieldname: 'test_comment', columns: 4}
frm.get_field('lab_test_prescription').grid.editable_fields = [
{fieldname: 'lab_test_code', columns: 2},
{fieldname: 'lab_test_name', columns: 4},
{fieldname: 'lab_test_comment', columns: 4}
];
},
refresh: function(frm) {
refresh_field('drug_prescription');
refresh_field('test_prescription');
refresh_field('lab_test_prescription');
if (!frm.doc.__islocal){
frappe.call({
method: 'frappe.client.get_value',
@ -72,7 +72,7 @@ frappe.ui.form.on('Patient Encounter', {
}
};
});
frm.set_query("test_code", "test_prescription", function() {
frm.set_query("lab_test_code", "lab_test_prescription", function() {
return {
filters: {
is_billable:'1'

View File

@ -975,7 +975,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_prescription",
"fieldname": "lab_test_prescription",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
@ -1141,7 +1141,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-21 14:44:40.378365",
"modified": "2018-09-04 11:50:52.217175",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Encounter",
@ -1180,4 +1180,4 @@
"track_changes": 1,
"track_seen": 1,
"track_views": 0
}
}

View File

@ -45,12 +45,18 @@ def delete_medical_record(encounter):
frappe.db.sql("""delete from `tabPatient Medical Record` where reference_name = %s""", (encounter.name))
def set_subject_field(encounter):
subject = "No Diagnosis "
subject = encounter.practitioner+"<br/>"
if(encounter.symptoms):
subject += "Symptoms: "+ cstr(encounter.symptoms)+".<br/>"
else:
subject += "No Symptoms <br/>"
if(encounter.diagnosis):
subject = "Diagnosis: \n"+ cstr(encounter.diagnosis)+". "
subject += "Diagnosis: "+ cstr(encounter.diagnosis)+".<br/>"
else:
subject += "No Diagnosis <br/>"
if(encounter.drug_prescription):
subject +="\nDrug(s) Prescribed. "
if(encounter.test_prescription):
if(encounter.lab_test_prescription):
subject += "\nTest(s) Prescribed."
if(encounter.procedure_prescription):
subject += "\nProcedure(s) Prescribed."

View File

@ -14,11 +14,12 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "test_particulars",
"fieldname": "lab_test_particulars",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
@ -40,10 +41,12 @@
"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,
@ -72,11 +75,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": ""
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -103,10 +108,12 @@
"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,
@ -134,6 +141,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -147,7 +155,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-10-04 16:15:12.642699",
"modified": "2018-09-04 12:01:18.801216",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Special Test Items",
@ -162,5 +170,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
"track_seen": 0,
"track_views": 0
}

View File

@ -244,37 +244,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_4",
"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
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -967,7 +936,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-07-17 14:04:09.604470",
"modified": "2018-08-26 10:26:20.896305",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Vital Signs",
@ -1023,5 +992,6 @@
"sort_order": "DESC",
"title_field": "patient",
"track_changes": 1,
"track_seen": 1
}
"track_seen": 1,
"track_views": 0
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,7 @@ def execute(filters=None):
data = []
for lab_test in lab_test_list:
row = [ lab_test.test_name, lab_test.patient, lab_test.practitioner, lab_test.invoiced, lab_test.status, lab_test.result_date, lab_test.department]
row = [ lab_test.lab_test_name, lab_test.patient, lab_test.practitioner, lab_test.invoiced, lab_test.status, lab_test.result_date, lab_test.department]
data.append(row)
return columns, data
@ -52,7 +52,7 @@ def get_conditions(filters):
def get_lab_test(filters):
conditions = get_conditions(filters)
return frappe.db.sql("""select name, patient, test_name, patient_name, status, result_date, practitioner, invoiced, department
return frappe.db.sql("""select name, patient, lab_test_name, patient_name, status, result_date, practitioner, invoiced, department
from `tabLab Test`
where docstatus<2 %s order by submitted_date desc, name desc""" %
conditions, filters, as_dict=1)

View File

@ -10,7 +10,7 @@ def setup_healthcare():
return
create_medical_departments()
create_antibiotics()
create_test_uom()
create_lab_test_uom()
create_duration()
create_dosage()
create_healthcare_item_groups()
@ -73,30 +73,30 @@ def create_antibiotics():
except frappe.DuplicateEntryError:
pass
def create_test_uom():
def create_lab_test_uom():
records = [
{"doctype": "Lab Test UOM", "name": "umol/L", "test_uom": "umol/L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mg/L", "test_uom": "mg/L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mg / dl", "test_uom": "mg / dl", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "pg / ml", "test_uom": "pg / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "U/ml", "test_uom": "U/ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "/HPF", "test_uom": "/HPF", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Million Cells / cumm", "test_uom": "Million Cells / cumm", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Lakhs Cells / cumm", "test_uom": "Lakhs Cells / cumm", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "U / L", "test_uom": "U / L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "g / L", "test_uom": "g / L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "IU / ml", "test_uom": "IU / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "gm %", "test_uom": "gm %", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Microgram", "test_uom": "Microgram", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Micron", "test_uom": "Micron", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Cells / cumm", "test_uom": "Cells / cumm", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "%", "test_uom": "%", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mm / dl", "test_uom": "mm / dl", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mm / hr", "test_uom": "mm / hr", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ulU / ml", "test_uom": "ulU / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ng / ml", "test_uom": "ng / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ng / dl", "test_uom": "ng / dl", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ug / dl", "test_uom": "ug / dl", "uom_description": None }
{"doctype": "Lab Test UOM", "name": "umol/L", "lab_test_uom": "umol/L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mg/L", "lab_test_uom": "mg/L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mg / dl", "lab_test_uom": "mg / dl", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "pg / ml", "lab_test_uom": "pg / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "U/ml", "lab_test_uom": "U/ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "/HPF", "lab_test_uom": "/HPF", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Million Cells / cumm", "lab_test_uom": "Million Cells / cumm", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Lakhs Cells / cumm", "lab_test_uom": "Lakhs Cells / cumm", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "U / L", "lab_test_uom": "U / L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "g / L", "lab_test_uom": "g / L", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "IU / ml", "lab_test_uom": "IU / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "gm %", "lab_test_uom": "gm %", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Microgram", "lab_test_uom": "Microgram", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Micron", "lab_test_uom": "Micron", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "Cells / cumm", "lab_test_uom": "Cells / cumm", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "%", "lab_test_uom": "%", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mm / dl", "lab_test_uom": "mm / dl", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "mm / hr", "lab_test_uom": "mm / hr", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ulU / ml", "lab_test_uom": "ulU / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ng / ml", "lab_test_uom": "ng / ml", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ng / dl", "lab_test_uom": "ng / dl", "uom_description": None },
{"doctype": "Lab Test UOM", "name": "ug / dl", "lab_test_uom": "ug / dl", "uom_description": None }
]
insert_record(records)

View File

@ -91,13 +91,13 @@ def get_healthcare_services_to_invoice(patient):
'service': frappe.db.get_value("Lab Test Template", lab_test_obj.template, "item")})
lab_rxs = frappe.db.sql("""select lp.name from `tabPatient Encounter` et, `tabLab Prescription` lp
where et.patient=%s and lp.parent=et.name and lp.test_created=0 and lp.invoiced=0""", (patient.name))
where et.patient=%s and lp.parent=et.name and lp.lab_test_created=0 and lp.invoiced=0""", (patient.name))
if lab_rxs:
for lab_rx in lab_rxs:
rx_obj = frappe.get_doc("Lab Prescription", lab_rx[0])
if rx_obj.test_code and (frappe.db.get_value("Lab Test Template", rx_obj.test_code, "is_billable") == 1):
if rx_obj.lab_test_code and (frappe.db.get_value("Lab Test Template", rx_obj.lab_test_code, "is_billable") == 1):
item_to_invoice.append({'reference_type': 'Lab Prescription', 'reference_name': rx_obj.name,
'service': frappe.db.get_value("Lab Test Template", rx_obj.test_code, "item")})
'service': frappe.db.get_value("Lab Test Template", rx_obj.lab_test_code, "item")})
procedures = frappe.get_list("Clinical Procedure", {'patient': patient.name, 'invoiced': False})
if procedures:
@ -250,7 +250,7 @@ def set_invoiced(item, method, ref_invoice=None):
manage_doc_for_appoitnment(dt_from_appointment, item.reference_dn, invoiced)
elif item.reference_dt == 'Lab Prescription':
manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, "Lab Test", "test_created")
manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, "Lab Test", "lab_test_created")
elif item.reference_dt == 'Procedure Prescription':
manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, "Clinical Procedure", "procedure_created")
@ -369,8 +369,15 @@ def get_drugs_to_invoice(encounter):
qty = 1
if frappe.db.get_value("Item", drug_line.drug_code, "stock_uom") == "Nos":
qty = drug_line.get_quantity()
description = False
if drug_line.dosage:
description = drug_line.dosage
if description and drug_line.period:
description += " for "+drug_line.period
if not description:
description = ""
item_to_invoice.append({'drug_code': drug_line.drug_code, 'quantity': qty,
'description': drug_line.dosage+" for "+drug_line.period})
'description': description})
return item_to_invoice
@frappe.whitelist()

View File

@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2018-07-17 13:10:47.940128",
"modified": "2018-09-04 08:50:41.314546",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "lab-test",
@ -27,6 +27,7 @@
"print_format": "Lab Test Print",
"published": 1,
"route": "lab-test",
"show_in_grid": 0,
"show_sidebar": 1,
"sidebar_items": [],
"success_url": "/lab-test",
@ -41,7 +42,8 @@
"max_value": 0,
"options": "LP-",
"read_only": 0,
"reqd": 1
"reqd": 1,
"show_in_filter": 0
},
{
"default": "0",
@ -53,7 +55,8 @@
"max_value": 0,
"options": "",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "patient",
@ -64,7 +67,8 @@
"max_value": 0,
"options": "Patient",
"read_only": 0,
"reqd": 1
"reqd": 1,
"show_in_filter": 0
},
{
"fieldname": "patient_name",
@ -75,7 +79,8 @@
"max_value": 0,
"options": "patient.patient_name",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "practitioner",
@ -86,7 +91,8 @@
"max_value": 0,
"options": "Healthcare Practitioner",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "status",
@ -97,7 +103,8 @@
"max_value": 0,
"options": "Draft\nCompleted\nApproved\nRejected\nCancelled",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "department",
@ -108,7 +115,8 @@
"max_value": 0,
"options": "Medical Department",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "sample",
@ -119,7 +127,8 @@
"max_value": 0,
"options": "Sample Collection",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"default": "",
@ -130,7 +139,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "report_preference",
@ -140,17 +150,19 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "test_name",
"fieldname": "lab_test_name",
"fieldtype": "Data",
"hidden": 0,
"label": "Test Name",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "normal_test_items",
@ -160,7 +172,8 @@
"max_value": 0,
"options": "Normal Test Items",
"read_only": 1,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "special_test_items",
@ -170,7 +183,8 @@
"max_value": 0,
"options": "Special Test Items",
"read_only": 1,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "sensitivity_test_items",
@ -180,17 +194,19 @@
"max_value": 0,
"options": "Sensitivity Test Items",
"read_only": 1,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "test_comment",
"fieldname": "lab_test_comment",
"fieldtype": "Text",
"hidden": 0,
"label": "Comments",
"max_length": 0,
"max_value": 0,
"read_only": 1,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "custom_result",
@ -200,7 +216,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 1,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"default": "0",
@ -210,7 +227,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"default": "0",
@ -220,7 +238,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"default": "0",
@ -230,7 +249,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
}
]
}
}

View File

@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2018-07-16 13:11:28.057697",
"modified": "2018-09-04 11:53:40.954517",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "prescription",
@ -27,6 +27,7 @@
"print_format": "Encounter Print",
"published": 1,
"route": "prescription",
"show_in_grid": 0,
"show_sidebar": 1,
"sidebar_items": [],
"success_url": "/prescription",
@ -41,7 +42,8 @@
"max_value": 0,
"options": "Healthcare Practitioner",
"read_only": 0,
"reqd": 1
"reqd": 1,
"show_in_filter": 0
},
{
"fieldname": "visit_department",
@ -52,7 +54,8 @@
"max_value": 0,
"options": "Medical Department",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"default": "Today",
@ -63,7 +66,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1
"reqd": 1,
"show_in_filter": 0
},
{
"default": "",
@ -74,7 +78,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1
"reqd": 1,
"show_in_filter": 0
},
{
"fieldname": "drug_prescription",
@ -85,10 +90,11 @@
"max_value": 0,
"options": "Drug Prescription",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "test_prescription",
"fieldname": "lab_test_prescription",
"fieldtype": "Table",
"hidden": 0,
"label": "Investigations",
@ -96,7 +102,8 @@
"max_value": 0,
"options": "Lab Prescription",
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
},
{
"fieldname": "encounter_comment",
@ -106,7 +113,8 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
"reqd": 0,
"show_in_filter": 0
}
]
}

View File

@ -564,3 +564,4 @@ erpnext.patches.v10_0.recalculate_gross_margin_for_project
erpnext.patches.v11_0.make_job_card
erpnext.patches.v11_0.redesign_healthcare_billing_work_flow
erpnext.patches.v10_0.delete_hub_documents # 12-08-2018
erpnext.patches.v11_0.rename_healthcare_fields

View File

@ -0,0 +1,52 @@
import frappe
from frappe.model.utils.rename_field import rename_field
from frappe.modules import scrub, get_doctype_module
lab_test_name = ["test_name", "lab_test_name"]
lab_test_code = ["test_code", "lab_test_code"]
lab_test_comment = ["test_comment", "lab_test_comment"]
lab_test_created = ["test_created", "lab_test_created"]
lab_test_template = ["test_template", "lab_test_template"]
lab_test_rate = ["test_rate", "lab_test_rate"]
lab_test_description = ["test_description", "lab_test_description"]
lab_test_group = ["test_group", "lab_test_group"]
lab_test_template_type = ["test_template_type", "lab_test_template_type"]
lab_test_uom = ["test_uom", "lab_test_uom"]
lab_test_normal_range = ["test_normal_range", "lab_test_normal_range"]
lab_test_event = ["test_event", "lab_test_event"]
lab_test_particulars = ["test_particulars", "lab_test_particulars"]
field_rename_map = {
"Lab Test Template": [lab_test_name, lab_test_code, lab_test_rate, lab_test_description,
lab_test_group, lab_test_template_type, lab_test_uom, lab_test_normal_range],
"Normal Test Items": [lab_test_name, lab_test_comment, lab_test_uom, lab_test_event],
"Lab Test": [lab_test_name, lab_test_comment, lab_test_group],
"Lab Prescription": [lab_test_name, lab_test_code, lab_test_comment, lab_test_created],
"Lab Test Groups": [lab_test_template, lab_test_rate, lab_test_description],
"Lab Test UOM": [lab_test_uom],
"Normal Test Template": [lab_test_uom, lab_test_event],
"Special Test Items": [lab_test_particulars]
}
def execute():
for dt, field_list in field_rename_map.items():
if frappe.db.exists('DocType', dt):
frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
for field in field_list:
if frappe.db.has_column(dt, field[0]):
rename_field(dt, field[0], field[1])
if frappe.db.exists('DocType', 'Lab Prescription'):
if frappe.db.has_column('Lab Prescription', 'parentfield'):
frappe.db.sql("""
update `tabLab Prescription` set parentfield = 'lab_test_prescription'
where parentfield = 'test_prescription'
""")
if frappe.db.exists('DocType', 'Lab Test Groups'):
if frappe.db.has_column('Lab Test Groups', 'parentfield'):
frappe.db.sql("""
update `tabLab Test Groups` set parentfield = 'lab_test_groups'
where parentfield = 'test_groups'
""")