I found a issue when creating a new Patient Appointment, in Healthcare module. Concretely, when I click the “Check Availability” button, a new dialog window opens. In this, I should select the “Medical Department”, “Healthcare Practitioner” and the “Date” of the appointment. Both “Medical Department” and “Healthcare Practitioner” are link fields. I have no problem with “Medical Department” and “Date”. However, when I what to select the Practitioner, the field doesn’t fetch the list of available Practitioners:
I thought it could be because it seems to filter Practitioners based on Department. However, I removed the following piece of code (it appears two times) and nothing happened:
I didn’t have a “Service Unit” though, but I just created two and assigned to each Practitioner. But still the same result: nothing is fetched in Partitioner field. I tried with both root and child Service units.
Yes, I double-checked that. All Practitioner have a Medical Department assigned. Furthermore, i just created a new Department and assigned to one Practitioner: nothing changes.
As I mentioned, there are two sections in the client code (erpnext/healthcare/doctype/patient_appointment/patient_appointment.js) which apply a filter over Practitioner by Department:
I’m not quite sure, the two things I know of are the Department filters and the Active flag. It’s best you create an issue on GitHub with relevant details to reproduce this.
Long story short, the query in get_practitioner_list (erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py) should be:
query = \
"""select %s from `tabHealthcare Practitioner` where docstatus < 2
and (%s like %s or first_name like %s) and active = 1
%s
order by case when name like %s then 0 else 1 end,
case when first_name like %s then 0 else 1 end,
name, first_name limit %s, %s""" \
% (
', '.join(fields),
frappe.db.escape(searchfield),
"\'%%%s%%\'" % txt,
"\'%%%s%%\'" % txt,
match_conditions,
"\'%%%s%%\'" % txt,
"\'%%%s%%\'" % txt,
start,
page_len,
)
result = frappe.db.sql(query)
return result
Explanation: the problem is with "%%%s%%" % frappe.db.escape(txt) which when the formatting is applied results in %'txt'% (where txt is the actual text in the input field) but it should be '%txt%' (that is the ' symbol enclosing the % pair, not the other way around).
Any update for this? is it merged? I checked healthcare_practitioner.py … but seems like the code has been changed since. I am still having the same error. can you help me? really appreciate it… Thank you
Really thank you for the reply. I have assigned the department and all practitioners are in active mode. but still its the same way… (tested in official 14 day trial version, V11 and V12… seems like its showing the same in all installs)
On Web Form I guess you should enable Allow Read On All Link Options for the link field.
But then, booking appointment from via the portal is not currently supported, you’ll need to do necessary customizations to get the availability slots for the practitioner.