Physician - Set Details by User or Employee (#12558)
diff --git a/erpnext/healthcare/doctype/physician/physician.js b/erpnext/healthcare/doctype/physician/physician.js
index c607f23..c224b5d 100755
--- a/erpnext/healthcare/doctype/physician/physician.js
+++ b/erpnext/healthcare/doctype/physician/physician.js
@@ -31,21 +31,26 @@
name: frm.doc.user_id
},
callback: function (data) {
- if(!frm.doc.employee){
- frappe.model.get_value('Employee', {'user_id': frm.doc.user_id}, 'name',
- function(data) {
- if(data)
+
+ frappe.model.get_value('Employee', {'user_id': frm.doc.user_id}, 'name',
+ function(data) {
+ if(data){
+ if(!frm.doc.employee || frm.doc.employee != data.name)
frappe.model.set_value(frm.doctype,frm.docname, "employee", data.name);
- });
- }
- if(!frm.doc.first_name)
+ }else{
+ frappe.model.set_value(frm.doctype,frm.docname, "employee", "");
+ }
+ }
+ );
+
+ if(!frm.doc.first_name || frm.doc.first_name != data.message.first_name)
frappe.model.set_value(frm.doctype,frm.docname, "first_name", data.message.first_name);
- if(!frm.doc.middle_name)
+ if(!frm.doc.middle_name || frm.doc.middle_name != data.message.middle_name)
frappe.model.set_value(frm.doctype,frm.docname, "middle_name", data.message.middle_name);
- if(!frm.doc.last_name)
+ if(!frm.doc.last_name || frm.doc.last_name != data.message.last_name)
frappe.model.set_value(frm.doctype,frm.docname, "last_name", data.message.last_name);
- if(!frm.doc.mobile_phone)
- frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.phone);
+ if(!frm.doc.mobile_phone || frm.doc.mobile_phone != data.message.mobile_no)
+ frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.mobile_no);
}
});
}
@@ -60,13 +65,18 @@
name: frm.doc.employee
},
callback: function (data) {
- if(!frm.doc.designation)
+ if(!frm.doc.user_id || frm.doc.user_id != data.message.user_id)
+ frm.set_value("user_id", data.message.user_id);
+ if(!frm.doc.designation || frm.doc.designation != data.message.designation)
frappe.model.set_value(frm.doctype,frm.docname, "designation", data.message.designation);
- if(!frm.doc.first_name)
+ if(!frm.doc.first_name || !frm.doc.user_id){
frappe.model.set_value(frm.doctype,frm.docname, "first_name", data.message.employee_name);
- if(!frm.doc.mobile_phone)
+ frappe.model.set_value(frm.doctype,frm.docname, "middle_name", "");
+ frappe.model.set_value(frm.doctype,frm.docname, "last_name", "");
+ }
+ if(!frm.doc.mobile_phone || !frm.doc.user_id)
frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.cell_number);
- if(!frm.doc.address)
+ if(!frm.doc.address || frm.doc.address != data.message.current_address)
frappe.model.set_value(frm.doctype,frm.docname, "address", data.message.current_address);
}
});
diff --git a/erpnext/healthcare/doctype/physician/physician.json b/erpnext/healthcare/doctype/physician/physician.json
index 3edad0b..1d9794e 100644
--- a/erpnext/healthcare/doctype/physician/physician.json
+++ b/erpnext/healthcare/doctype/physician/physician.json
@@ -155,7 +155,7 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@@ -810,8 +810,8 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2017-10-05 16:08:24.624644",
- "modified_by": "Administrator",
+ "modified": "2018-01-19 15:25:43.166877",
+ "modified_by": "jams@hcf.com",
"module": "Healthcare",
"name": "Physician",
"name_case": "",