feat: additional customer fileds
add customer_group, price list, currency etc.
rearrange and group fields
disable cusotmer edit after save (temp fix)
diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js
index d5df956..a11faf5 100644
--- a/erpnext/healthcare/doctype/patient/patient.js
+++ b/erpnext/healthcare/doctype/patient/patient.js
@@ -40,6 +40,7 @@
frm.add_custom_button(__('Patient Encounter'), function () {
create_encounter(frm);
}, 'Create');
+ frm.toggle_enable(['customer'], 0); // ToDo, allow change only if no transactions booked or better, add merge option
}
},
onload: function (frm) {
diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json
index 4258e40..2c701fb 100644
--- a/erpnext/healthcare/doctype/patient/patient.json
+++ b/erpnext/healthcare/doctype/patient/patient.json
@@ -24,13 +24,20 @@
"image",
"column_break_14",
"status",
- "inpatient_status",
"inpatient_record",
- "customer",
+ "inpatient_status",
+ "report_preference",
"mobile",
"email",
"phone",
- "report_preference",
+ "customer_details_section",
+ "customer",
+ "customer_group",
+ "territory",
+ "column_break_24",
+ "default_currency",
+ "default_price_list",
+ "language",
"personal_and_social_history",
"occupation",
"column_break_25",
@@ -52,9 +59,7 @@
"surrounding_factors",
"other_risk_factors",
"more_info",
- "patient_details",
- "ac_sb",
- "default_currency"
+ "patient_details"
],
"fields": [
{
@@ -156,6 +161,7 @@
"fieldname": "customer",
"fieldtype": "Link",
"ignore_user_permissions": 1,
+ "in_preview": 1,
"label": "Customer",
"options": "Customer"
},
@@ -171,7 +177,8 @@
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
- "label": "Mobile"
+ "label": "Mobile",
+ "options": "Phone"
},
{
"bold": 1,
@@ -186,7 +193,8 @@
"fieldname": "phone",
"fieldtype": "Data",
"in_filter": 1,
- "label": "Phone"
+ "label": "Phone",
+ "options": "Phone"
},
{
"collapsible": 1,
@@ -268,25 +276,25 @@
"fieldname": "tobacco_past_use",
"fieldtype": "Data",
"ignore_xss_filter": 1,
- "label": "Tobacco Consumption Habbits (Past)"
+ "label": "Tobacco Consumption (Past)"
},
{
"fieldname": "tobacco_current_use",
"fieldtype": "Data",
"ignore_xss_filter": 1,
- "label": "Tobacco Consumption Habbits (Present)"
+ "label": "Tobacco Consumption (Present)"
},
{
"fieldname": "alcohol_past_use",
"fieldtype": "Data",
"ignore_xss_filter": 1,
- "label": "Alcohol Consumption Habbits (Past)"
+ "label": "Alcohol Consumption (Past)"
},
{
"fieldname": "alcohol_current_use",
"fieldtype": "Data",
"ignore_user_permissions": 1,
- "label": "Alcohol Consumption Habbits (Present)"
+ "label": "Alcohol Consumption (Present)"
},
{
"fieldname": "column_break_32",
@@ -321,19 +329,10 @@
"label": "Patient Details"
},
{
- "collapsible": 1,
- "fieldname": "ac_sb",
- "fieldtype": "Section Break",
- "label": "Account Details"
- },
- {
"fieldname": "default_currency",
"fieldtype": "Link",
- "hidden": 1,
- "ignore_xss_filter": 1,
- "label": "Default Currency",
- "options": "Currency",
- "print_hide": 1
+ "label": "Billing Currency",
+ "options": "Currency"
},
{
"fieldname": "last_name",
@@ -351,13 +350,47 @@
"fieldname": "middle_name",
"fieldtype": "Data",
"label": "Middle Name (optional)"
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "customer_details_section",
+ "fieldtype": "Section Break",
+ "label": "Customer Details"
+ },
+ {
+ "fieldname": "customer_group",
+ "fieldtype": "Link",
+ "label": "Customer Group",
+ "options": "Customer Group"
+ },
+ {
+ "fieldname": "territory",
+ "fieldtype": "Link",
+ "label": "Territory",
+ "options": "Territory"
+ },
+ {
+ "fieldname": "column_break_24",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "default_price_list",
+ "fieldtype": "Link",
+ "label": "Default Price List",
+ "options": "Price List"
+ },
+ {
+ "fieldname": "language",
+ "fieldtype": "Link",
+ "label": "Print Language",
+ "options": "Language"
}
],
"icon": "fa fa-user",
"image_field": "image",
"links": [],
"max_attachments": 50,
- "modified": "2020-04-06 12:55:30.807744",
+ "modified": "2020-04-11 14:53:48.767245",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient",
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index e304a0b..f83fac0 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -26,6 +26,7 @@
frappe.db.set_value('Patient', self.name, 'status', 'Disabled')
else:
send_registration_sms(self)
+ self.reload() # self.notify_update()
def set_full_name(self):
if self.last_name:
@@ -86,8 +87,8 @@
return {'invoice': sales_invoice.name}
def create_customer(doc):
- customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group')
- territory = frappe.db.get_single_value('Selling Settings', 'territory')
+ customer_group = doc.customer_group or frappe.db.get_single_value('Selling Settings', 'customer_group')
+ territory = doc.territory or frappe.db.get_single_value('Selling Settings', 'territory')
if not (customer_group and territory):
customer_group = get_root_of('Customer Group')
territory = get_root_of('Territory')
@@ -98,7 +99,10 @@
'customer_name': doc.patient_name,
'customer_group': customer_group,
'territory' : territory,
- 'customer_type': 'Individual'
+ 'customer_type': 'Individual',
+ 'default_currency': doc.default_currency,
+ 'default_price_ist': doc.default_price_list,
+ 'language': doc.language
}).insert(ignore_permissions=True, ignore_mandatory=True)
frappe.db.set_value('Patient', doc.name, 'customer', customer.name)