Skip to content

Commit

Permalink
Merge pull request #180 from Sajinsr/pract-primary-contact
Browse files Browse the repository at this point in the history
Primary Address and Contact in Healthcare Practitioner
  • Loading branch information
akashkrishna619 authored Feb 6, 2023
2 parents 8d773b2 + 61808ae commit c8f226a
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'};

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit c8f226a

Please sign in to comment.