fix(healthcare): Removed ignore user permissions flag in appointment (#27129)

diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
index 8162f03..cb455eb 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
@@ -282,7 +282,7 @@
  ],
  "image_field": "image",
  "links": [],
- "modified": "2021-01-22 10:14:43.187675",
+ "modified": "2021-08-24 10:42:08.513054",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Healthcare Practitioner",
@@ -295,6 +295,7 @@
    "read": 1,
    "report": 1,
    "role": "Laboratory User",
+   "select": 1,
    "share": 1,
    "write": 1
   },
@@ -307,6 +308,7 @@
    "read": 1,
    "report": 1,
    "role": "Physician",
+   "select": 1,
    "share": 1,
    "write": 1
   },
@@ -319,6 +321,7 @@
    "read": 1,
    "report": 1,
    "role": "Nursing User",
+   "select": 1,
    "share": 1,
    "write": 1
   }
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
index 6e996bd..73ec3bc 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
@@ -142,7 +142,6 @@
   {
    "fieldname": "practitioner",
    "fieldtype": "Link",
-   "ignore_user_permissions": 1,
    "in_standard_filter": 1,
    "label": "Healthcare Practitioner",
    "options": "Healthcare Practitioner",
diff --git a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py
index 2df6921..9c3392c 100644
--- a/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/test_patient_appointment.py
@@ -199,10 +199,33 @@
 
 		assert new_invoice_count == invoice_count + 1
 
+	def test_patient_appointment_should_consider_permissions_while_fetching_appointments(self):
+		patient, medical_department, practitioner = create_healthcare_docs()
+		create_appointment(patient, practitioner, nowdate())
 
-def create_healthcare_docs():
+		patient, medical_department, new_practitioner = create_healthcare_docs(practitioner_name='Dr. John')
+		create_appointment(patient, new_practitioner, nowdate())
+
+		roles = [{"doctype": "Has Role", "role": "Physician"}]
+		user = create_user(roles=roles)
+		new_practitioner = frappe.get_doc('Healthcare Practitioner', new_practitioner)
+		new_practitioner.user_id = user.email
+		new_practitioner.save()
+
+		frappe.set_user(user.name)
+		appointments = frappe.get_list('Patient Appointment')
+		assert len(appointments) == 1
+
+		frappe.set_user("Administrator")
+		appointments = frappe.get_list('Patient Appointment')
+		assert len(appointments) == 2
+
+def create_healthcare_docs(practitioner_name=None):
+	if not practitioner_name:
+		practitioner_name = '_Test Healthcare Practitioner'
+
 	patient = create_patient()
-	practitioner = frappe.db.exists('Healthcare Practitioner', '_Test Healthcare Practitioner')
+	practitioner = frappe.db.exists('Healthcare Practitioner', practitioner_name)
 	medical_department = frappe.db.exists('Medical Department', '_Test Medical Department')
 
 	if not medical_department:
@@ -213,7 +236,7 @@
 
 	if not practitioner:
 		practitioner = frappe.new_doc('Healthcare Practitioner')
-		practitioner.first_name = '_Test Healthcare Practitioner'
+		practitioner.first_name = practitioner_name
 		practitioner.gender = 'Female'
 		practitioner.department = medical_department
 		practitioner.op_consulting_charge = 500
@@ -319,3 +342,17 @@
 			'price_list': args.get('price_list') or frappe.db.get_value("Price List", {"selling": 1}),
 			'items': args.get('items') or items
 		}).insert()
+
+def create_user(email=None, roles=None):
+	if not email:
+		email = '{}@frappe.com'.format(frappe.utils.random_string(10))
+	user = frappe.db.exists('User', email)
+	if not user:
+		user = frappe.get_doc({
+			"doctype": "User",
+			"email": email,
+			"first_name": "test_user",
+			"password": "password",
+			"roles": roles,
+		}).insert()
+	return user