diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py index 4336fe51606..9bdba032e4a 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -69,12 +69,13 @@ class PatientAppointment(Document): if fee_validity.ref_invoice: frappe.db.set_value("Patient Appointment", appointment.name, "invoiced", True) frappe.msgprint(_("{0} has fee validity till {1}").format(appointment.patient, fee_validity.valid_till)) - confirm_sms(self) if frappe.db.get_value("Healthcare Settings", None, "manage_appointment_invoice_automatically") == '1' and \ frappe.db.get_value("Patient Appointment", self.name, "invoiced") != 1: invoice_appointment(self) + send_confirmation_msg(self) + @frappe.whitelist() def invoice_appointment(appointment_doc): if not appointment_doc.name: @@ -303,10 +304,14 @@ def set_pending_appointments(): "('Scheduled','Open') and appointment_date < %s", today) -def confirm_sms(doc): - if frappe.db.get_value("Healthcare Settings", None, "app_con") == '1': - message = frappe.db.get_value("Healthcare Settings", None, "app_con_msg") - send_message(doc, message) +def send_confirmation_msg(doc): + if frappe.db.get_single_value("Healthcare Settings", "app_con"): + message = frappe.db.get_single_value("Healthcare Settings", "app_con_msg") + try: + send_message(doc, message) + except Exception: + frappe.log_error(frappe.get_traceback(), _("Appointment Confirmation Message Not Sent")) + frappe.msgprint(_("Appointment Confirmation Message Not Sent"), indicator="orange") @frappe.whitelist() def create_encounter(appointment):