From 513b443861a9611a52a7d1d79ccc54516e36191e Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Mon, 3 Feb 2020 23:42:21 +0530 Subject: [PATCH] fix: make check availability as the primary action button --- .../patient_appointment/patient_appointment.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index 49de78c21d..28c326a9ad 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -29,6 +29,19 @@ frappe.ui.form.on('Patient Appointment', { } }; }); + + if (frm.is_new()) { + frm.page.set_primary_action(__('Check Availability'), function() { + if (!frm.doc.patient) { + frappe.throw(__('Please select a patient first')); + } else { + check_and_set_availability(frm); + } + }); + } else { + frm.page.set_primary_action(__('Save'), () => frm.save()); + } + if(frm.doc.patient){ frm.add_custom_button(__('Patient History'), function() { frappe.route_options = {"patient": frm.doc.patient}; @@ -103,9 +116,6 @@ frappe.ui.form.on('Patient Appointment', { } }); }, - check_availability: function(frm) { - check_and_set_availability(frm); - }, onload:function(frm){ if(frm.is_new()) { frm.set_value("appointment_time", null);