From b2c9268ece2feaef11dab0aaa07f60e576f771c9 Mon Sep 17 00:00:00 2001 From: Jamsheer Date: Mon, 19 Nov 2018 16:05:34 +0530 Subject: [PATCH] fix: Patient Appointment - Calendar - set color from appointment type --- .../patient_appointment/patient_appointment.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py index 5364031fce..7ac44b6cc2 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -337,11 +337,19 @@ def get_events(start, end, filters=None): from frappe.desk.calendar import get_event_conditions conditions = get_event_conditions("Patient Appointment", filters) - data = frappe.db.sql("""select name, patient, practitioner, status, - duration, timestamp(appointment_date, appointment_time) as - 'start' from `tabPatient Appointment` where - (appointment_date between %(start)s and %(end)s) - and docstatus < 2 {conditions}""".format(conditions=conditions), + data = frappe.db.sql(""" + select + `tabPatient Appointment`.name, `tabPatient Appointment`.patient, + `tabPatient Appointment`.practitioner, `tabPatient Appointment`.status, + `tabPatient Appointment`.duration, + timestamp(`tabPatient Appointment`.appointment_date, `tabPatient Appointment`.appointment_time) as 'start', + `tabAppointment Type`.color + from + `tabPatient Appointment` + left join `tabAppointment Type` on `tabPatient Appointment`.appointment_type=`tabAppointment Type`.name + where + (`tabPatient Appointment`.appointment_date between %(start)s and %(end)s) + and `tabPatient Appointment`.docstatus < 2 {conditions}""".format(conditions=conditions), {"start": start, "end": end}, as_dict=True, update={"allDay": 0}) for item in data: