feat: multi company support

This commit is contained in:
anoop 2020-04-13 16:30:00 +05:30
parent 80ab98bf36
commit 2d2db60035
3 changed files with 25 additions and 20 deletions

View File

@ -137,7 +137,7 @@ var get_lab_test_prescribed = function(frm){
}); });
} }
else{ else{
frappe.msgprint(__("Please select Patient to get Lab Tests")); frappe.msgprint(__("Please select a Patient to get Lab Orders"));
} }
}; };
@ -180,9 +180,10 @@ var show_lab_tests = function(frm, result){
return false; return false;
}); });
}); });
if(!result){ if(!result.length){
var msg = "There are no Lab Test prescribed for "+frm.doc.patient; var msg = "No Lab Orders found for patient <b>" + frm.doc.patient_name + "</b>";
$(repl('<div class="col-xs-12" style="padding-top:20px;" >%(msg)s</div></div>', {msg: msg})).appendTo(html_field); html_field.empty();
$(repl('<div class="col-xs-12" style="padding-top:0px;" >%(msg)s</div>', {msg: msg})).appendTo(html_field);
} }
d.show(); d.show();
}; };

View File

@ -9,18 +9,18 @@
"document_type": "Document", "document_type": "Document",
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"inpatient_record",
"naming_series", "naming_series",
"invoiced",
"patient", "patient",
"patient_name", "patient_name",
"patient_age", "patient_age",
"patient_sex", "patient_sex",
"practitioner", "report_preference",
"email", "email",
"mobile", "mobile",
"company", "practitioner",
"c_b", "c_b",
"inpatient_record",
"company",
"department", "department",
"status", "status",
"submitted_date", "submitted_date",
@ -31,7 +31,7 @@
"employee_name", "employee_name",
"employee_designation", "employee_designation",
"user", "user",
"report_preference", "invoiced",
"sb_first", "sb_first",
"lab_test_name", "lab_test_name",
"column_break_26", "column_break_26",
@ -153,7 +153,7 @@
{ {
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "in_standard_filter": 1,
"label": "Company", "label": "Company",
"options": "Company", "options": "Company",
"print_hide": 1, "print_hide": 1,
@ -168,6 +168,7 @@
"fieldname": "department", "fieldname": "department",
"fieldtype": "Link", "fieldtype": "Link",
"ignore_user_permissions": 1, "ignore_user_permissions": 1,
"in_standard_filter": 1,
"label": "Department", "label": "Department",
"options": "Medical Department", "options": "Medical Department",
"search_index": 1 "search_index": 1
@ -427,7 +428,7 @@
], ],
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-03-23 19:37:06.617764", "modified": "2020-04-04 19:16:29.131168",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Healthcare", "module": "Healthcare",
"name": "Lab Test", "name": "Lab Test",

View File

@ -69,9 +69,9 @@ 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) "+lab_test_created+" created.")) frappe.msgprint(_("Lab Test(s) " + lab_test_created + " created."))
else: else:
frappe.msgprint(_("No Lab Test created")) frappe.msgprint(_("No Lab Tests created"))
def create_lab_test_from_encounter(encounter_id): def create_lab_test_from_encounter(encounter_id):
lab_test_created = False lab_test_created = False
@ -87,7 +87,7 @@ def create_lab_test_from_encounter(encounter_id):
for lab_test_id in lab_test_ids: for lab_test_id in lab_test_ids:
template = get_lab_test_template(lab_test_id[1]) template = get_lab_test_template(lab_test_id[1])
if template: if template:
lab_test = create_lab_test_doc(lab_test_id[2], encounter.practitioner, patient, template) lab_test = create_lab_test_doc(lab_test_id[2], encounter.practitioner, patient, template, encounter.company)
lab_test.save(ignore_permissions = True) lab_test.save(ignore_permissions = True)
frappe.db.set_value("Lab Prescription", lab_test_id[0], "lab_test_created", 1) frappe.db.set_value("Lab Prescription", lab_test_id[0], "lab_test_created", 1)
if not lab_test_created: if not lab_test_created:
@ -111,7 +111,7 @@ def create_lab_test_from_invoice(invoice_name):
if lab_test_created != 1: if lab_test_created != 1:
template = get_lab_test_template(item.item_code) template = get_lab_test_template(item.item_code)
if template: if template:
lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template) lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template, company, invoice.company)
if item.reference_dt == "Lab Prescription": if item.reference_dt == "Lab Prescription":
lab_test.prescription = item.reference_dn lab_test.prescription = item.reference_dn
lab_test.save(ignore_permissions = True) lab_test.save(ignore_permissions = True)
@ -121,7 +121,7 @@ def create_lab_test_from_invoice(invoice_name):
if not lab_tests_created: if not lab_tests_created:
lab_tests_created = lab_test.name lab_tests_created = lab_test.name
else: else:
lab_tests_created += ", "+lab_test.name lab_tests_created += ", " + lab_test.name
return lab_tests_created return lab_tests_created
def get_lab_test_template(item): def get_lab_test_template(item):
@ -141,7 +141,7 @@ def check_template_exists(item):
return template_exists return template_exists
return False return False
def create_lab_test_doc(invoiced, practitioner, patient, template): def create_lab_test_doc(invoiced, practitioner, patient, template, company):
lab_test = frappe.new_doc("Lab Test") lab_test = frappe.new_doc("Lab Test")
lab_test.invoiced = invoiced lab_test.invoiced = invoiced
lab_test.practitioner = practitioner lab_test.practitioner = practitioner
@ -150,11 +150,12 @@ def create_lab_test_doc(invoiced, practitioner, patient, template):
lab_test.patient_sex = patient.sex lab_test.patient_sex = patient.sex
lab_test.email = patient.email lab_test.email = patient.email
lab_test.mobile = patient.mobile lab_test.mobile = patient.mobile
lab_test.report_preference = patient.report_preference
lab_test.department = template.department lab_test.department = template.department
lab_test.template = template.name lab_test.template = template.name
lab_test.lab_test_group = template.lab_test_group lab_test.lab_test_group = template.lab_test_group
lab_test.result_date = getdate() lab_test.result_date = getdate()
lab_test.report_preference = patient.report_preference lab_test.company = company
return lab_test return lab_test
def create_normals(template, lab_test): def create_normals(template, lab_test):
@ -190,7 +191,7 @@ def create_specials(template, lab_test):
special.require_result_value = 1 special.require_result_value = 1
special.template = template.name special.template = template.name
def create_sample_doc(template, patient, invoice): def create_sample_doc(template, patient, invoice, company = None):
if template.sample: if template.sample:
sample_exists = frappe.db.exists({ sample_exists = frappe.db.exists({
"doctype": "Sample Collection", "doctype": "Sample Collection",
@ -221,6 +222,8 @@ def create_sample_doc(template, patient, invoice):
sample_collection.sample = template.sample sample_collection.sample = template.sample
sample_collection.sample_uom = template.sample_uom sample_collection.sample_uom = template.sample_uom
sample_collection.sample_qty = template.sample_qty sample_collection.sample_qty = template.sample_qty
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)
@ -229,7 +232,7 @@ def create_sample_doc(template, patient, invoice):
def create_sample_collection(lab_test, template, patient, invoice): def create_sample_collection(lab_test, template, patient, invoice):
if(frappe.db.get_value("Healthcare Settings", None, "create_sample_collection_for_lab_test") == "1"): if(frappe.db.get_value("Healthcare Settings", None, "create_sample_collection_for_lab_test") == "1"):
sample_collection = create_sample_doc(template, patient, invoice) sample_collection = create_sample_doc(template, patient, invoice, lab_test.company)
if(sample_collection): if(sample_collection):
lab_test.sample = sample_collection.name lab_test.sample = sample_collection.name
return lab_test return lab_test