fix: filter Therapy Types and Therapy Plan in Patient Appointment
This commit is contained in:
parent
5a8a52b9c6
commit
f2a431d866
@ -22,6 +22,7 @@ frappe.ui.form.on('Patient Appointment', {
|
||||
filters: {'status': 'Active'}
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('practitioner', function() {
|
||||
return {
|
||||
filters: {
|
||||
@ -29,6 +30,7 @@ frappe.ui.form.on('Patient Appointment', {
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('service_unit', function(){
|
||||
return {
|
||||
filters: {
|
||||
@ -39,6 +41,16 @@ frappe.ui.form.on('Patient Appointment', {
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('therapy_plan', function() {
|
||||
return {
|
||||
filters: {
|
||||
'patient': frm.doc.patient
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
frm.trigger('set_therapy_type_filter');
|
||||
|
||||
if (frm.is_new()) {
|
||||
frm.page.set_primary_action(__('Check Availability'), function() {
|
||||
if (!frm.doc.patient) {
|
||||
@ -136,6 +148,24 @@ frappe.ui.form.on('Patient Appointment', {
|
||||
}
|
||||
},
|
||||
|
||||
therapy_plan: function(frm) {
|
||||
frm.trigger('set_therapy_type_filter');
|
||||
},
|
||||
|
||||
set_therapy_type_filter: function(frm) {
|
||||
if (frm.doc.therapy_plan) {
|
||||
frm.call('get_therapy_types').then(r => {
|
||||
frm.set_query('therapy_type', function() {
|
||||
return {
|
||||
filters: {
|
||||
'name': ['in', r.message]
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
therapy_type: function(frm) {
|
||||
if (frm.doc.therapy_type) {
|
||||
frappe.db.get_value('Therapy Type', frm.doc.therapy_type, 'default_duration', (r) => {
|
||||
|
@ -91,6 +91,17 @@ class PatientAppointment(Document):
|
||||
if fee_validity:
|
||||
frappe.msgprint(_('{0} has fee validity till {1}').format(self.patient, fee_validity.valid_till))
|
||||
|
||||
def get_therapy_types(self):
|
||||
if not self.therapy_plan:
|
||||
return
|
||||
|
||||
therapy_types = []
|
||||
doc = frappe.get_doc('Therapy Plan', self.therapy_plan)
|
||||
for entry in doc.therapy_plan_details:
|
||||
therapy_types.append(entry.therapy_type)
|
||||
|
||||
return therapy_types
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def check_payment_fields_reqd(patient):
|
||||
@ -145,7 +156,7 @@ def invoice_appointment(appointment_doc):
|
||||
sales_invoice.flags.ignore_mandatory = True
|
||||
sales_invoice.save(ignore_permissions=True)
|
||||
sales_invoice.submit()
|
||||
frappe.msgprint(_('Sales Invoice {0} created'.format(sales_invoice.name)), alert=True)
|
||||
frappe.msgprint(_('Sales Invoice {0} created').format(sales_invoice.name), alert=True)
|
||||
frappe.db.set_value('Patient Appointment', appointment_doc.name, 'invoiced', 1)
|
||||
frappe.db.set_value('Patient Appointment', appointment_doc.name, 'ref_sales_invoice', sales_invoice.name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user