Skip to content

Commit

Permalink
fix: Change field name automate_appointment_invoicing to show_payment…
Browse files Browse the repository at this point in the history
…_popup in Healthcare Settings
  • Loading branch information
Sajinsr authored and akashkrishna619 committed Sep 4, 2023
1 parent a103390 commit 9968652
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 182 deletions.
19 changes: 13 additions & 6 deletions healthcare/healthcare/doctype/fee_validity/fee_validity.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def check_fee_validity(appointment, date=None, practitioner=None):
}
if appointment.status != "Cancelled":
filters["status"] = "Active"
else:
filters["patient_appointment"] = appointment.name

validity = frappe.db.exists(
"Fee Validity",
Expand All @@ -92,8 +94,8 @@ def check_fee_validity(appointment, date=None, practitioner=None):
return
else:
validity = get_fee_validity(appointment.get("name"), date) or None
if validity:
return validity
if validity and len(validity):
return frappe.get_doc("Fee Validity", validity[0].get("name"))
return

validity = frappe.get_doc("Fee Validity", validity)
Expand Down Expand Up @@ -155,30 +157,35 @@ def manage_fee_validity(appointment):


@frappe.whitelist()
def get_fee_validity(appointment_name, date):
def get_fee_validity(appointment_name, date, ignore_status=False):
"""
Get the fee validity details for the free visit appointment
:params appointment_name: Appointment doc name
:params date: Schedule date
:params ignore_status: status will not filter in query
:return fee validity name and valid_till values of free visit appointments
"""
if appointment_name:
appointment_doc = frappe.get_doc("Patient Appointment", appointment_name)
fee_validity = frappe.qb.DocType("Fee Validity")
child = frappe.qb.DocType("Fee Validity Reference")

return (
query = (
frappe.qb.from_(fee_validity)
.inner_join(child)
.on(fee_validity.name == child.parent)
.select(fee_validity.name, fee_validity.valid_till)
.where(fee_validity.status == "Active")
.where(fee_validity.start_date <= date)
.where(fee_validity.valid_till >= date)
.where(fee_validity.patient == appointment_doc.patient)
.where(fee_validity.practitioner == appointment_doc.practitioner)
.where(child.appointment == appointment_name)
).run(as_dict=True)
)

if not ignore_status:
query = query.where(fee_validity.status == "Active")

return query.run(as_dict=True)


def update_validity_status():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_fee_validity(self):
healthcare_settings.enable_free_follow_ups = 1
healthcare_settings.max_visits = 1
healthcare_settings.valid_days = 7
healthcare_settings.automate_appointment_invoicing = 1
healthcare_settings.show_payment_popup = 1
healthcare_settings.op_consulting_charge_item = item
healthcare_settings.save(ignore_permissions=True)
patient, practitioner = create_healthcare_docs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ frappe.tour['Healthcare Settings'] = [
description: __('If your Healthcare facility bills registrations of Patients, you can check this and set the Registration Fee in the field below. Checking this will create new Patients with a Disabled status by default and will only be enabled after invoicing the Registration Fee.')
},
{
fieldname: 'automate_appointment_invoicing',
title: __('Automate Appointment Invoicing'),
description: __('Checking this will automatically create a Sales Invoice whenever an appointment is booked for a Patient.')
fieldname: 'show_payment_popup',
title: __('Show Payment Popup'),
description: __('Checking this will popup to invoice appointment')
},
{
fieldname: 'validate_nursing_checklists',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"column_break_9",
"collect_registration_fee",
"registration_fee",
"automate_appointment_invoicing",
"show_payment_popup",
"enable_free_follow_ups",
"max_visits",
"valid_days",
Expand Down Expand Up @@ -231,10 +231,10 @@
},
{
"default": "0",
"description": "Manage Appointment Invoice submit and cancel automatically for Patient Encounter",
"fieldname": "automate_appointment_invoicing",
"description": "Checking this will popup dialog for Appointment Invoicing",
"fieldname": "show_payment_popup",
"fieldtype": "Check",
"label": "Automate Appointment Invoicing"
"label": "Show Payment Popup"
},
{
"default": "0",
Expand Down Expand Up @@ -360,7 +360,7 @@
],
"issingle": 1,
"links": [],
"modified": "2023-01-13 17:51:25.440851",
"modified": "2023-08-10 17:51:25.440851",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Settings",
Expand Down
Loading

0 comments on commit 9968652

Please sign in to comment.