feat: show linked Sales Invoice in Patient Appointment after booking
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
index dde720b..a332d4c 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
@@ -40,8 +40,30 @@
 
 		if (frm.is_new()) {
 			frm.page.set_primary_action(__('Check Availability'), function() {
+				frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'manage_appointment_invoice_automatically', (settings) => {
+					if (settings.manage_appointment_invoice_automatically) {
+						if (!frm.doc.mode_of_payment) {
+							frappe.msgprint({
+								title: __('Not Allowed'),
+								message: __('Please select a Mode of Payment first'),
+								indicator: 'red'
+							});
+						}
+						if (!frm.doc.paid_amount) {
+							frappe.msgprint({
+								title: __('Not Allowed'),
+								message: __('Please set the Paid Amount first'),
+								indicator: 'red'
+							});
+						}
+					}
+				});
 				if (!frm.doc.patient) {
-					frappe.throw(__('Please select a patient first'));
+					frappe.msgprint({
+						title: __('Not Allowed'),
+						message: __('Please select Patient first'),
+						indicator: 'red'
+					});
 				} else {
 					check_and_set_availability(frm);
 				}
@@ -301,7 +323,7 @@
 	} else {
 		frappe.msgprint({
 			title: __('Not Allowed'),
-			message: __('Please select Patient first')
+			message: __('Please select a Patient first')
 		});
 	}
 };
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index 7aa41c5..1a4b7df 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -103,6 +103,7 @@
 	sales_invoice.save(ignore_permissions=True)
 	sales_invoice.submit()
 	frappe.msgprint(_("Sales Invoice {0} created as paid".format(sales_invoice.name)), alert=True)
+	frappe.db.set_value('Patient Appointment', appointment_doc.name, 'ref_sales_invoice', sales_invoice.name)
 
 def appointment_cancel(appointment_id):
 	appointment = frappe.get_doc("Patient Appointment", appointment_id)