From 61808ae8840de6fff7d9baeaf9390d937fa19998 Mon Sep 17 00:00:00 2001 From: sajin Date: Tue, 24 Jan 2023 18:11:29 +0530 Subject: [PATCH] fix: Primary Address and Contact in Healthcare Practitioner --- .../healthcare_practitioner.js | 39 ++++++++++++- .../healthcare_practitioner.json | 56 ++++++++++++++++++- 2 files changed, 91 insertions(+), 4 deletions(-) diff --git a/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js b/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js index 5f08eef8e6..17d203cd17 100644 --- a/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js +++ b/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js @@ -22,7 +22,26 @@ frappe.ui.form.on('Healthcare Practitioner', { } }; }); + + frm.set_query('practitioner_primary_contact', function(doc) { + return { + filters: { + 'link_doctype': 'Healthcare Practitioner', + 'link_name': doc.name + } + } + }) + + frm.set_query('practitioner_primary_address', function(doc) { + return { + filters: { + 'link_doctype': 'Healthcare Practitioner', + 'link_name': doc.name + } + } + }) }, + refresh: function(frm) { frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Healthcare Practitioner'}; @@ -43,7 +62,25 @@ frappe.ui.form.on('Healthcare Practitioner', { set_query_service_item(frm, 'inpatient_visit_charge_item'); set_query_service_item(frm, 'op_consulting_charge_item'); - } + }, + + practitioner_primary_address: function(frm) { + if (frm.doc.practitioner_primary_address) { + frappe.call({ + method: 'frappe.contacts.doctype.address.address.get_address_display', + args: { + 'address_dict': frm.doc.practitioner_primary_address + }, + callback: function(r) { + frm.set_value('primary_address', r.message); + } + }); + } + + if (!frm.doc.practitioner_primary_address) { + frm.set_value('primary_address', ''); + } + }, }); let set_query_service_item = function(frm, service_item_field) { diff --git a/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json b/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json index 3c3a24d7a9..b3c1aa4a63 100644 --- a/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json +++ b/healthcare/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json @@ -3,7 +3,6 @@ "allow_import": 1, "allow_rename": 1, "autoname": "naming_series:", - "beta": 0, "creation": "2016-02-23 11:20:53.565119", "doctype": "DocType", "document_type": "Setup", @@ -44,7 +43,14 @@ "address_and_contacts_section", "address_html", "column_break_19", - "contact_html" + "contact_html", + "primary_address_and_contact_detail", + "practitioner_primary_contact", + "mobile_no", + "email_id", + "column_break_26", + "practitioner_primary_address", + "primary_address" ], "fields": [ { @@ -286,11 +292,55 @@ "fieldtype": "Link", "label": "Google Calendar", "options": "Google Calendar" + }, + { + "collapsible": 1, + "depends_on": "eval: !doc.__islocal", + "description": "Select, to make the practitioner searchable with these fields", + "fieldname": "primary_address_and_contact_detail", + "fieldtype": "Section Break", + "label": "Primary Address and Contact" + }, + { + "description": "Reselect, if the chosen contact is edited after save", + "fieldname": "practitioner_primary_contact", + "fieldtype": "Link", + "label": "Practitioner Primary Contact", + "options": "Contact" + }, + { + "fetch_from": "practitioner_primary_contact.mobile_no", + "fieldname": "mobile_no", + "fieldtype": "Read Only", + "label": "Mobile No" + }, + { + "fetch_from": "practitioner_primary_contact.email_id", + "fieldname": "email_id", + "fieldtype": "Read Only", + "label": "Email Id" + }, + { + "fieldname": "column_break_26", + "fieldtype": "Column Break" + }, + { + "description": "Reselect, if the chosen address is edited after save", + "fieldname": "practitioner_primary_address", + "fieldtype": "Link", + "label": "Practitioner Primary Address", + "options": "Address" + }, + { + "fieldname": "primary_address", + "fieldtype": "Text", + "label": "Primary Address", + "read_only": 1 } ], "image_field": "image", "links": [], - "modified": "2022-06-15 08:01:05.614211", + "modified": "2023-01-24 13:24:19.191984", "modified_by": "Administrator", "module": "Healthcare", "name": "Healthcare Practitioner",