Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patient Appointment form doesn’t fetch Practitioner data #44

Open
roquegv opened this issue Feb 11, 2019 · 2 comments
Open

Patient Appointment form doesn’t fetch Practitioner data #44

roquegv opened this issue Feb 11, 2019 · 2 comments
Assignees

Comments

@roquegv
Copy link

roquegv commented Feb 11, 2019

Hello ERPNext Community,

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:

captura de pantalla de 2019-02-08 14-45-08_cut

It should fetch the active Practitioners I’ve created:

captura de pantalla de 2019-02-08 14-48-32

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:

frm.set_query("practitioner", function() {
	return {
		filters: {
			'department': frm.doc.department
		}
	};
});

No errors in console (JS nor Python).

Testing Scenario:

  • Version: ERPNext v11.1.4, Frappe v11.1.3
  • Each Practitioner has a valid and Enabled Practitioner Schedule and has valid time slots (monday to friday, from 8am to 8pm, 15min each).
  • Each Practitioner has a valid Service Unit
  • Each Practitioner has a valid Medical Department
  • Only experiencing this issue in v11; also tried with v10 and works well.

Discussion in the forum: https://discuss.erpnext.com/t/patient-appointment-form-doesnt-fetch-practitioner-data/45403

@roquegv
Copy link
Author

roquegv commented Feb 14, 2019

I finally solve the issue.

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).

@manan-ft
Copy link

manan-ft commented Oct 7, 2019

@roquegv Thanks for your solution, it worked for me

@ChillarAnand ChillarAnand transferred this issue from frappe/erpnext Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants