diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js index d0ab94c792..de5bce0aa6 100644 --- a/erpnext/healthcare/doctype/patient/patient.js +++ b/erpnext/healthcare/doctype/patient/patient.js @@ -120,3 +120,16 @@ var btn_invoice_registration = function (frm) { } }); }; + +frappe.ui.form.on('Patient Relation', { + patient_relation_add: function(frm){ + frm.fields_dict['patient_relation'].grid.get_field('patient').get_query = function(frm){ + var patient_list = []; + if(!frm.doc.__islocal) patient_list.push(frm.doc.name); + $.each(frm.doc.patient_relation, function(idx, val){ + if (val.patient) patient_list.push(val.patient); + }); + return { filters: [['Patient', 'name', 'not in', patient_list]] }; + }; + } +}); \ No newline at end of file