fix: Healthcare Service Unit fixes (#27273)

* fix: validate service unit setup against practitioner schedule

* fix: service unit properties getting overwritten
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
index 989d426..5e76ed7 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
+++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
@@ -30,7 +30,7 @@
 		self.validate_one_root()
 
 	def set_service_unit_properties(self):
-		if self.is_group:
+		if cint(self.is_group):
 			self.allow_appointments = False
 			self.overlap_appointments = False
 			self.inpatient_occupancy = False
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index 36047c4..f0d5af9 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -6,7 +6,7 @@
 import frappe
 from frappe.model.document import Document
 import json
-from frappe.utils import getdate, get_time, flt
+from frappe.utils import getdate, get_time, flt, get_link_to_form
 from frappe.model.mapper import get_mapped_doc
 from frappe import _
 import datetime
@@ -333,17 +333,13 @@
 
 
 def get_available_slots(practitioner_doc, date):
-	available_slots = []
-	slot_details = []
+	available_slots = slot_details = []
 	weekday = date.strftime('%A')
 	practitioner = practitioner_doc.name
 
 	for schedule_entry in practitioner_doc.practitioner_schedules:
-		if schedule_entry.schedule:
-			practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule)
-		else:
-			frappe.throw(_('{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner').format(
-				frappe.bold(practitioner)), title=_('Practitioner Schedule Not Found'))
+		validate_practitioner_schedules(schedule_entry, practitioner)
+		practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule)
 
 		if practitioner_schedule:
 			available_slots = []
@@ -386,6 +382,19 @@
 	return slot_details
 
 
+def validate_practitioner_schedules(schedule_entry, practitioner):
+	if schedule_entry.schedule:
+		if not schedule_entry.service_unit:
+			frappe.throw(_('Practitioner {0} does not have a Service Unit set against the Practitioner Schedule {1}.').format(
+				get_link_to_form('Healthcare Practitioner', practitioner), frappe.bold(schedule_entry.schedule)),
+				title=_('Service Unit Not Found'))
+
+	else:
+		frappe.throw(_('Practitioner {0} does not have a Practitioner Schedule assigned.').format(
+			get_link_to_form('Healthcare Practitioner', practitioner)),
+			title=_('Practitioner Schedule Not Found'))
+
+
 @frappe.whitelist()
 def update_status(appointment_id, status):
 	frappe.db.set_value('Patient Appointment', appointment_id, 'status', status)