mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-28 09:24:45 +00:00
fix: create fee validity for new patients only
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Healthcare Practitioner",
|
"label": "Healthcare Practitioner",
|
||||||
"options": "Healthcare Practitioner",
|
"options": "Healthcare Practitioner",
|
||||||
|
"read_only": 1,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
@@ -38,23 +39,27 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Patient",
|
"label": "Patient",
|
||||||
"options": "Patient",
|
"options": "Patient",
|
||||||
|
"read_only": 1,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "visited",
|
"fieldname": "visited",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Visited yet"
|
"label": "Visited yet",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "valid_till",
|
"fieldname": "valid_till",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Valid till"
|
"label": "Valid till",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "section_break_3",
|
"fieldname": "section_break_3",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Validity"
|
"label": "Validity",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_6",
|
"fieldname": "column_break_6",
|
||||||
@@ -63,7 +68,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "max_visits",
|
"fieldname": "max_visits",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Max number of visit"
|
"label": "Max number of visit",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
@@ -89,7 +95,8 @@
|
|||||||
"fieldname": "ref_appointments",
|
"fieldname": "ref_appointments",
|
||||||
"fieldtype": "Table MultiSelect",
|
"fieldtype": "Table MultiSelect",
|
||||||
"label": "Reference Appointments",
|
"label": "Reference Appointments",
|
||||||
"options": "Fee Validity Reference"
|
"options": "Fee Validity Reference",
|
||||||
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
@@ -97,8 +104,9 @@
|
|||||||
"fieldtype": "Section Break"
|
"fieldtype": "Section Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"in_create": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-03-17 18:29:01.163961",
|
"modified": "2020-03-17 20:25:06.487418",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Fee Validity",
|
"name": "Fee Validity",
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ class FeeValidity(Document):
|
|||||||
|
|
||||||
|
|
||||||
def create_fee_validity(appointment):
|
def create_fee_validity(appointment):
|
||||||
|
if not check_is_new_patient(appointment):
|
||||||
|
return
|
||||||
|
|
||||||
fee_validity = frappe.new_doc('Fee Validity')
|
fee_validity = frappe.new_doc('Fee Validity')
|
||||||
fee_validity.practitioner = appointment.practitioner
|
fee_validity.practitioner = appointment.practitioner
|
||||||
fee_validity.patient = appointment.patient
|
fee_validity.patient = appointment.patient
|
||||||
@@ -42,3 +45,19 @@ def create_fee_validity(appointment):
|
|||||||
})
|
})
|
||||||
fee_validity.save(ignore_permissions=True)
|
fee_validity.save(ignore_permissions=True)
|
||||||
return fee_validity
|
return fee_validity
|
||||||
|
|
||||||
|
def check_is_new_patient(appointment):
|
||||||
|
validity_exists = frappe.db.exists('Fee Validity', {
|
||||||
|
'practitioner': appointment.practitioner,
|
||||||
|
'patient': appointment.patient
|
||||||
|
})
|
||||||
|
if validity_exists:
|
||||||
|
return False
|
||||||
|
|
||||||
|
appointment_exists = frappe.db.get_all('Patient Appointment', {
|
||||||
|
'name': ('!=', appointment.name),
|
||||||
|
'status': ('!=', 'Cancelled')
|
||||||
|
})
|
||||||
|
if len(appointment_exists) and appointment_exists[0]:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
Reference in New Issue
Block a user