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

Syntax error when creating Therapy Session/Patient Appointment. #478

Open
diwakarrankawat opened this issue Jun 27, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@diwakarrankawat
Copy link

Information about bug

When I installed frappe, ERPNext and healthcare, dev version for all of them was installed by default. I've changed the versions using bench switch-to-branch version-15 (I tried version-14 as well, but it failed).
After switching branch, I've also run: bench update --patch, and just for making sure I also ran bench migrate.
But still the issue persists.

NOTE: I've not changed any code inside the healthcare app after installation. I've also tried running bench reinstall previously(when I had dev versions).

Module

Rehab & Physiotherapy

Version

When running bench list-apps

  • Frappe Version - 15.x.x-develop (develop)
  • ERPNext Version - 15.28.0 (version-15)
  • Frappe Health Version - 15.0.0 (version-15)
  • PostgreSQL 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1) pg_config --version

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
	"erpnext": "15.28.0",
	"frappe": "16.0.0-dev",
	"healthcare": "15.0.0"
}

Route

Form/Patient Appointment/new-patient-appointment-zadbsrhwos

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1808, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/desk/form/save.py", line 39, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 340, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 362, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 293, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1127, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 979, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1362, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1340, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 976, in fn
    return method_object(*args, **kwargs)
  File "apps/healthcare/healthcare/healthcare/doctype/patient_appointment/patient_appointment.py", line 40, in validate
    self.validate_overlaps()
  File "apps/healthcare/healthcare/healthcare/doctype/patient_appointment/patient_appointment.py", line 112, in validate_overlaps
    overlapping_appointments = frappe.db.sql(
  File "apps/frappe/frappe/database/postgres/database.py", line 220, in sql
    return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
  File "apps/frappe/frappe/database/database.py", line 236, in sql
    self._cursor.execute(query, values)
psycopg2.errors.SyntaxError: syntax error at or near "duration"
LINE 8: ...t_time<'10:00:00' AND appointment_time + INTERVAL duration M...
                                                             ^


Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Patient Appointment\",\"name\":\"new-patient-appointment-zadbsrhwos\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"HLC-APP-.YYYY.-\",\"status\":\"\",\"appointment_for\":\"Practitioner\",\"company\":\"ScaleupAlly\",\"add_video_conferencing\":0,\"invoiced\":0,\"reminded\":0,\"appointment_time\":\"10:00:00\",\"duration\":60,\"department\":\"Microbiology\",\"service_unit\":\"Unit Main - SA\",\"appointment_type\":\"Service\",\"patient_name\":\"Ritik\",\"inpatient_record\":null,\"patient_sex\":\"Male\",\"patient\":\"Ritik\",\"patient_age\":\"1 Years(s) 5 Month(s) 17 Day(s)\",\"practitioner\":\"HLC-PRAC-2024-00001\",\"appointment_date\":\"2024-06-28\"}",
		"action": "Save"
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": null
}

Response Data

{
	"exception": "",
	"exc_type": "SyntaxError",
	"_exc_source": "healthcare (app)",
	"_debug_messages": "[\"Syntax error in query:\\nSELECT\\n\\t\\t\\t\\tname, practitioner, patient, appointment_time, duration, service_unit\\n\\t\\t\\tFROM\\n\\t\\t\\t\\t\\\"tabPatient Appointment\\\"\\n\\t\\t\\tWHERE\\n\\t\\t\\t\\tappointment_date=%(appointment_date)s AND name!=%(name)s AND status NOT IN (\\\"Closed\\\", \\\"Cancelled\\\") AND\\n\\t\\t\\t\\t(practitioner=%(practitioner)s OR patient=%(patient)s) AND\\n\\t\\t\\t\\t((appointment_time<%(appointment_time)s AND appointment_time + INTERVAL duration MINUTE>%(appointment_time)s) OR\\n\\t\\t\\t\\t(appointment_time>%(appointment_time)s AND appointment_time<%(end_time)s) OR\\n\\t\\t\\t\\t(appointment_time=%(appointment_time)s)) {'appointment_date': '2024-06-28', 'name': 'HLC-APP-2024-00001', 'practitioner': 'HLC-PRAC-2024-00001', 'patient': 'Ritik', 'appointment_time': '10:00:00', 'end_time': datetime.time(11, 0)}\"]"
}


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@diwakarrankawat diwakarrankawat added the bug Something isn't working label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant