diff --git a/hms_tz/jubilee/api/api.py b/hms_tz/jubilee/api/api.py index cb750544..cd833b11 100644 --- a/hms_tz/jubilee/api/api.py +++ b/hms_tz/jubilee/api/api.py @@ -4,8 +4,12 @@ from frappe import _ from time import sleep from erpnext import get_default_company +from frappe.utils.background_jobs import enqueue from hms_tz.jubilee.api.token import get_jubilee_service_token -from hms_tz.jubilee.doctype.jubilee_response_log.jubilee_response_log import add_jubilee_log +from hms_tz.jubilee.api.price_package import sync_jubilee_price_package +from hms_tz.jubilee.doctype.jubilee_response_log.jubilee_response_log import ( + add_jubilee_log, +) @frappe.whitelist() @@ -19,7 +23,9 @@ def get_member_card_detials(card_no, insurance_provider): if not company: company = frappe.get_list( - "Company Insurance Setting", fields=["company"], filters={"enable": 1, "api_provider": insurance_provider} + "Company Insurance Setting", + fields=["company"], + filters={"enable": 1, "api_provider": insurance_provider}, )[0].company if not company: frappe.throw(_("No companies found to connect to Jubilee")) @@ -32,9 +38,7 @@ def get_member_card_detials(card_no, insurance_provider): "service_url", ) headers = {"Authorization": "Bearer " + token} - url = ( - str(service_url) + f"/jubileeapi/Getcarddetails?MemberNo={str(card_no)}" - ) + url = str(service_url) + f"/jubileeapi/Getcarddetails?MemberNo={str(card_no)}" for i in range(3): try: r = requests.get(url, headers=headers, timeout=5) @@ -77,3 +81,57 @@ def get_member_card_detials(card_no, insurance_provider): continue else: raise e + + +@frappe.whitelist() +def enqueue_get_jubilee_price_packages(company): + enqueue( + method=get_jubilee_price_packages, + job_name="get_jubilee_price_packages", + queue="default", + timeout=None, + is_async=True, + company=company, + ) + + +@frappe.whitelist() +def get_jubilee_price_packages(company, insurance_provider="Jubilee"): + if not company: + frappe.throw(_("No companies found to connect to Jubilee")) + + token = get_jubilee_service_token(company, insurance_provider) + + service_url = frappe.get_cached_value( + "Company Insurance Setting", + {"company": company, "api_provider": insurance_provider}, + "service_url", + ) + headers = {"Authorization": "Bearer " + token} + url = str(service_url) + "/jubileeapi/GetPriceList" + r = requests.get(url, headers=headers, timeout=300) + if r.status_code != 200: + add_jubilee_log( + request_type="GetPricePackage", + request_url=url, + request_header=headers, + response_data=r.text, + status_code=r.status_code, + ref_doctype="Jubilee Price Package", + company=company, + ) + frappe.throw(json.loads(r.text)) + else: + if json.loads(r.text): + log_name = add_jubilee_log( + request_type="GetPricePackage", + request_url=url, + request_header=headers, + response_data=r.text, + status_code=r.status_code, + ref_doctype="Jubilee Price Package", + company=company, + ) + + packages = json.loads(r.text)["Description"] + sync_jubilee_price_package(packages, company, log_name) diff --git a/hms_tz/jubilee/api/price_package.py b/hms_tz/jubilee/api/price_package.py new file mode 100644 index 00000000..841f4630 --- /dev/null +++ b/hms_tz/jubilee/api/price_package.py @@ -0,0 +1,153 @@ +import json +import frappe +from time import sleep +from frappe.utils import now_datetime +from frappe.query_builder import DocType + + +def sync_jubilee_price_package( + packages, company, log_name, insurance_provider="Jubilee" +): + if len(packages) == 0: + return + + delete_price_package(company) + + sleep(30) + create_price_package(packages, company, log_name) + + sleep(30) + set_package_diff(company) + + +def delete_price_package(company): + jpp = DocType("Jubilee Price Package") + frappe.qb.from_(jpp).delete().where(jpp.company == company).run() + + +def create_price_package(packages, company, log_name): + fields = [ + "name", + "company", + "itemcode", + "itemname", + "cleanname", + "itemprice", + "providerid", + "log_name", + "time_stamp", + ] + + data = [] + time_stamp = now_datetime() + for row in packages: + jpp_name = frappe.generate_hash(length=10) + + data.append( + ( + jpp_name, + company, + row.get("ItemCode"), + row.get("ItemName"), + row.get("CleanName"), + row.get("ItemPrice"), + row.get("ProviderID"), + log_name, + time_stamp, + ) + ) + frappe.db.bulk_insert( + "Jubilee Price Package", fields=fields, values=data, chunk_size=1000 + ) + + +def set_package_diff(company): + logs = frappe.get_all( + "Jubilee Response Log", + filters={ + "request_type": "GetPricePackage", + "response_data": ["not in", ["", None]], + "company": company, + }, + fields=["name", "response_data"], + order_by="creation desc", + page_length=2, + ) + if len(logs) < 2: + return + + current_rec = json.loads(logs[0]["response_data"]) + previous_rec = json.loads(logs[1]["response_data"]) + current_price_packages = current_rec.get("Description") + previousـprice_packages = previous_rec.get("Description") + + diff_price_packages_from_current = [ + i for i in current_price_packages if i not in previousـprice_packages + ] + diff_price_packages_from_previous = [ + i for i in previousـprice_packages if i not in current_price_packages + ] + + changed_price_packages = [] + new_price_packages = [] + + for e in diff_price_packages_from_current: + exist_rec = next( + ( + item + for item in diff_price_packages_from_previous + if item.get("ItemCode") == e.get("ItemCode") + ), + None, + ) + if exist_rec: + changed_price_packages.append(exist_rec) + else: + new_price_packages.append(e) + + deleted_price_packages = [] + + for z in diff_price_packages_from_previous: + exist_rec = next( + ( + item + for item in diff_price_packages_from_current + if item.get("ItemCode") == z.get("ItemCode") + ), + None, + ) + if not exist_rec: + deleted_price_packages.append(z) + + if ( + len(changed_price_packages) > 0 + or len(new_price_packages) > 0 + or len(deleted_price_packages) > 0 + ): + doc = frappe.new_doc("Jubilee Update") + + add_price_packages_records(doc, changed_price_packages, "Changed") + add_price_packages_records(doc, new_price_packages, "New") + add_price_packages_records(doc, deleted_price_packages, "Deleted") + + if (doc.get("price_package") and len(doc.price_package)) or (): + doc.company = company + doc.current_log = logs[0].name + doc.previous_log = logs[1].name + doc.save(ignore_permissions=True) + + +def add_price_packages_records(doc, rec, type): + if not len(rec) > 0: + return + + for e in rec: + price_row = doc.append("price_package", {}) + price_row.itemcode = e.get("ItemCode") + price_row.type = type + price_row.olditemcode = e.get("OldItemCode") + price_row.itemname = e.get("ItemName") + price_row.strength = e.get("Strength") + price_row.dosage = e.get("Dosage") + price_row.unitprice = e.get("UnitPrice") + price_row.record = json.dumps(e) diff --git a/hms_tz/jubilee/api/token.py b/hms_tz/jubilee/api/token.py index cd2f77a4..252d01fc 100644 --- a/hms_tz/jubilee/api/token.py +++ b/hms_tz/jubilee/api/token.py @@ -24,6 +24,7 @@ def make_jubilee_token_request(doc, url, headers, payload, fields): request_body=payload, response_data=data, status_code=r.status_code, + company=doc.company, ) if ( @@ -46,6 +47,7 @@ def make_jubilee_token_request(doc, url, headers, payload, fields): request_body=payload, response_data=data, status_code=r.status_code, + company=doc.company, ) frappe.throw(data) diff --git a/hms_tz/jubilee/doctype/jubilee_price_package/__init__.py b/hms_tz/jubilee/doctype/jubilee_price_package/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.js b/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.js new file mode 100644 index 00000000..e66aa74b --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, Aakvatech and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Jubilee Price Package', { + // refresh: function(frm) { + + // } +}); diff --git a/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.json b/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.json new file mode 100644 index 00000000..8b6a8751 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.json @@ -0,0 +1,135 @@ +{ + "actions": [], + "autoname": "JPP-.YY.-.MM.-.DD.-.#####", + "creation": "2024-06-14 16:02:14.924451", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "providerid", + "log_name", + "column_break_4", + "company", + "time_stamp", + "section_break_3", + "itemcode", + "itemprice", + "strength", + "dosage", + "column_break_12", + "itemname", + "cleanname" + ], + "fields": [ + { + "fieldname": "log_name", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Log Name", + "read_only": 1 + }, + { + "fieldname": "time_stamp", + "fieldtype": "Datetime", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Time Stamp", + "read_only": 1 + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "company", + "fieldtype": "Data", + "in_standard_filter": 1, + "label": "Company", + "read_only": 1 + }, + { + "fieldname": "section_break_3", + "fieldtype": "Section Break" + }, + { + "fieldname": "itemcode", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "ItemCode", + "read_only": 1 + }, + { + "fieldname": "itemname", + "fieldtype": "Small Text", + "in_standard_filter": 1, + "label": "ItemName", + "read_only": 1 + }, + { + "fieldname": "strength", + "fieldtype": "Data", + "label": "Strength", + "read_only": 1 + }, + { + "fieldname": "dosage", + "fieldtype": "Data", + "label": "Dosage", + "read_only": 1 + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break" + }, + { + "fieldname": "providerid", + "fieldtype": "Data", + "label": "ProviderID", + "read_only": 1 + }, + { + "fieldname": "itemprice", + "fieldtype": "Float", + "in_list_view": 1, + "label": "ItemPrice", + "read_only": 1 + }, + { + "fieldname": "cleanname", + "fieldtype": "Small Text", + "in_standard_filter": 1, + "label": "CleanName", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-06-18 18:11:06.535715", + "modified_by": "Administrator", + "module": "Jubilee", + "name": "Jubilee Price Package", + "naming_rule": "Expression (old style)", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "itemname", + "track_changes": 1 +} \ No newline at end of file diff --git a/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.py b/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.py new file mode 100644 index 00000000..3477fb26 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_price_package/jubilee_price_package.py @@ -0,0 +1,8 @@ +# Copyright (c) 2024, Aakvatech and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class JubileePricePackage(Document): + pass diff --git a/hms_tz/jubilee/doctype/jubilee_price_package/test_jubilee_price_package.py b/hms_tz/jubilee/doctype/jubilee_price_package/test_jubilee_price_package.py new file mode 100644 index 00000000..c33e5b68 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_price_package/test_jubilee_price_package.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Aakvatech and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestJubileePricePackage(FrappeTestCase): + pass diff --git a/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.json b/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.json index b0fcba3b..e2ee7cb2 100644 --- a/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.json +++ b/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.json @@ -16,6 +16,7 @@ "status_code", "ref_doctype", "ref_docname", + "company", "request_section", "request_body", "section_break_8", @@ -115,11 +116,18 @@ "label": "Ref Docname", "read_only": 1, "search_index": 1 + }, + { + "fieldname": "company", + "fieldtype": "Data", + "hidden": 1, + "label": "Company", + "read_only": 1 } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-04-17 19:55:34.807520", + "modified": "2024-06-18 09:28:58.023706", "modified_by": "Administrator", "module": "Jubilee", "name": "Jubilee Response Log", diff --git a/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.py b/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.py index cf8f83ac..2322af6e 100644 --- a/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.py +++ b/hms_tz/jubilee/doctype/jubilee_response_log/jubilee_response_log.py @@ -4,6 +4,7 @@ import frappe from frappe.model.document import Document + class JubileeResponseLog(Document): pass @@ -17,6 +18,7 @@ def add_jubilee_log( status_code=None, ref_doctype=None, ref_docname=None, + company=None, ): doc = frappe.new_doc("Jubilee Response Log") doc.request_type = str(request_type) @@ -28,6 +30,7 @@ def add_jubilee_log( doc.status_code = status_code or "" doc.ref_doctype = ref_doctype or "" doc.ref_docname = ref_docname or "" + doc.company = company doc.save(ignore_permissions=True) frappe.db.commit() return doc.name diff --git a/hms_tz/jubilee/doctype/jubilee_update/__init__.py b/hms_tz/jubilee/doctype/jubilee_update/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.js b/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.js new file mode 100644 index 00000000..42ca9555 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, Aakvatech and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Jubilee Update', { + // refresh: function(frm) { + + // } +}); diff --git a/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.json b/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.json new file mode 100644 index 00000000..cc96ddd9 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.json @@ -0,0 +1,92 @@ +{ + "actions": [], + "autoname": "JU-.YY.-.#########", + "creation": "2024-06-18 09:47:39.160869", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "company", + "datetime", + "column_break_lln7e", + "current_log", + "previous_log", + "jubilee_price_packages_section", + "price_package" + ], + "fields": [ + { + "fieldname": "company", + "fieldtype": "Data", + "label": "company", + "read_only": 1 + }, + { + "default": "Now", + "fieldname": "datetime", + "fieldtype": "Datetime", + "label": "DateTime", + "read_only": 1 + }, + { + "fieldname": "column_break_lln7e", + "fieldtype": "Column Break" + }, + { + "fieldname": "current_log", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Current Log", + "options": "Jubilee Response Log", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "previous_log", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Previous Log", + "options": "Jubilee Response Log", + "read_only": 1, + "reqd": 1 + }, + { + "fieldname": "jubilee_price_packages_section", + "fieldtype": "Section Break", + "label": "Jubilee Price Packages" + }, + { + "fieldname": "price_package", + "fieldtype": "Table", + "label": "Price Packages", + "options": "Jubilee Update Item", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2024-06-18 09:47:39.160869", + "modified_by": "Administrator", + "module": "Jubilee", + "name": "Jubilee Update", + "naming_rule": "Expression (old style)", + "owner": "Administrator", + "permissions": [ + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "track_changes": 1 +} \ No newline at end of file diff --git a/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.py b/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.py new file mode 100644 index 00000000..57f89c88 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_update/jubilee_update.py @@ -0,0 +1,8 @@ +# Copyright (c) 2024, Aakvatech and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class JubileeUpdate(Document): + pass diff --git a/hms_tz/jubilee/doctype/jubilee_update/test_jubilee_update.py b/hms_tz/jubilee/doctype/jubilee_update/test_jubilee_update.py new file mode 100644 index 00000000..08fa8b15 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_update/test_jubilee_update.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Aakvatech and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestJubileeUpdate(FrappeTestCase): + pass diff --git a/hms_tz/jubilee/doctype/jubilee_update_item/__init__.py b/hms_tz/jubilee/doctype/jubilee_update_item/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hms_tz/jubilee/doctype/jubilee_update_item/jubilee_update_item.json b/hms_tz/jubilee/doctype/jubilee_update_item/jubilee_update_item.json new file mode 100644 index 00000000..cb535334 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_update_item/jubilee_update_item.json @@ -0,0 +1,91 @@ +{ + "actions": [], + "creation": "2024-06-18 09:41:52.551063", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "type", + "section_break_3", + "itemcode", + "itemprice", + "strength", + "dosage", + "column_break_12", + "itemname", + "cleanname", + "record" + ], + "fields": [ + { + "fieldname": "type", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Change Type" + }, + { + "fieldname": "section_break_3", + "fieldtype": "Section Break" + }, + { + "fieldname": "itemcode", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "ItemCode" + }, + { + "fieldname": "itemname", + "fieldtype": "Small Text", + "in_standard_filter": 1, + "label": "ItemName" + }, + { + "fieldname": "strength", + "fieldtype": "Data", + "label": "Strength" + }, + { + "fieldname": "dosage", + "fieldtype": "Data", + "label": "Dosage" + }, + { + "fieldname": "column_break_12", + "fieldtype": "Column Break" + }, + { + "fieldname": "record", + "fieldtype": "Small Text", + "label": "Record" + }, + { + "fieldname": "itemprice", + "fieldtype": "Float", + "in_list_view": 1, + "label": "ItemPrice", + "read_only": 1 + }, + { + "fieldname": "cleanname", + "fieldtype": "Small Text", + "in_list_view": 1, + "label": "CleanName", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2024-06-18 18:56:42.770935", + "modified_by": "Administrator", + "module": "Jubilee", + "name": "Jubilee Update Item", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "itemname" +} \ No newline at end of file diff --git a/hms_tz/jubilee/doctype/jubilee_update_item/jubilee_update_item.py b/hms_tz/jubilee/doctype/jubilee_update_item/jubilee_update_item.py new file mode 100644 index 00000000..76b75f40 --- /dev/null +++ b/hms_tz/jubilee/doctype/jubilee_update_item/jubilee_update_item.py @@ -0,0 +1,8 @@ +# Copyright (c) 2024, Aakvatech and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class JubileeUpdateItem(Document): + pass diff --git a/hms_tz/nhif/api/insurance_company.js b/hms_tz/nhif/api/insurance_company.js index fb05c3bf..3347cfbc 100644 --- a/hms_tz/nhif/api/insurance_company.js +++ b/hms_tz/nhif/api/insurance_company.js @@ -1,15 +1,29 @@ frappe.ui.form.on('Healthcare Insurance Company', { onload: function (frm) { - add_get_price_btn(frm) + // For NHIF + add_nhif_get_price_btn(frm); + + // For Jubilee + add_jubilee_get_price_btn(frm); + }, refresh: function (frm) { - add_get_price_btn(frm) + // For NHIF + add_nhif_get_price_btn(frm); + + // For Jubilee + add_jubilee_get_price_btn(frm); }, }); -var add_get_price_btn = function (frm) { +var add_nhif_get_price_btn = function (frm) { if (!frm.doc.insurance_company_name.includes("NHIF")) { return } frm.add_custom_button(__('Get NHIF Price Package'), function () { + frappe.show_alert({ + message: __("Fetching NHIF Price packages."), + indicator: 'green' + }, 10); + frappe.call({ method: 'hms_tz.nhif.api.insurance_company.enqueue_get_nhif_price_package', args: { company: frm.doc.company }, @@ -20,8 +34,12 @@ var add_get_price_btn = function (frm) { } }); }); - if (!frm.doc.insurance_company_name.includes("NHIF")) { return } frm.add_custom_button(__('Only Process NHIF Records'), function () { + frappe.show_alert({ + message: __("Processing NHIF Price packages."), + indicator: 'green' + }, 10); + frappe.call({ method: 'hms_tz.nhif.api.insurance_company.process_nhif_records', args: { company: frm.doc.company }, @@ -33,4 +51,42 @@ var add_get_price_btn = function (frm) { }); }); +} + +var add_jubilee_get_price_btn = function (frm) { + if (!frm.doc.insurance_company_name.includes("Jubilee")) { return } + + frm.add_custom_button(__('Get Jubilee Price Package'), function () { + frappe.show_alert({ + message: __("Fetching Jubilee Price packages."), + indicator: 'green' + }, 10); + + frappe.call({ + method: 'hms_tz.jubilee.api.api.enqueue_get_jubilee_price_packages', + args: { company: frm.doc.company }, + callback: function (data) { + if (data.message) { + console.log(data.message) + } + } + }); + }); + frm.add_custom_button(__('Only Process Jubilee Records'), function () { + frappe.show_alert({ + message: __("Processing Jubilee Price packages."), + indicator: 'green' + }, 10); + + frappe.call({ + method: 'hms_tz.jubilee.api.api.enqueue_get_jubilee_price_packages', + args: { company: frm.doc.company }, + callback: function (data) { + if (data.message) { + console.log(data.message) + } + } + }); + }); + } \ No newline at end of file