您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

36 行
1.1 KiB

  1. import frappe
  2. @frappe.whitelist()
  3. @frappe.validate_and_sanitize_search_inputs
  4. def get_healthcare_service_units(doctype, txt, searchfield, start, page_len, filters):
  5. table = frappe.qb.DocType("Healthcare Service Unit")
  6. query = (
  7. frappe.qb.from_(table)
  8. .where(table.is_group == 0)
  9. .where(table.company == filters.get("company"))
  10. .where(table.name.like("%{0}%".format(txt)))
  11. .select("name")
  12. .get_sql()
  13. )
  14. if filters and filters.get("inpatient_record"):
  15. from healthcare.healthcare.doctype.inpatient_medication_entry.inpatient_medication_entry import (
  16. get_current_healthcare_service_unit,
  17. )
  18. service_unit = get_current_healthcare_service_unit(filters.get("inpatient_record"))
  19. # if the patient is admitted, then appointments should be allowed against the admission service unit,
  20. # inspite of it being an Inpatient Occupancy service unit
  21. if service_unit:
  22. query += " and (allow_appointments = 1 or name = {service_unit})".format(
  23. service_unit=frappe.db.escape(service_unit)
  24. )
  25. else:
  26. query += " and allow_appointments = 1"
  27. else:
  28. query += " and allow_appointments = 1"
  29. return frappe.db.sql(query, filters)