-
Notifications
You must be signed in to change notification settings - Fork 375
Description
Information about bug
I have decided on this strange title because there are a number of issues involved.
- Therapy Plan does not have any reference to a "Source Doc". And many docs in Healthcare do have this link. Having "Source Doc" in Therapy Plan will solve everything.
- So when the Patient Encounter is submitted and a Therapy plan is created, then there is no way to determine the Therapy Plan doc number, because there is no "Source Doc" field in Therapy Plan.
- And then when "Create" therapy session is selected from Service Request, the Therapy Session doc does not populate completely.
The additions as outlined below, ensured that Therapy Plan can be linked to its parent Patient Encounter and also ensures that Therapy Session is created correctly from within Service Request.
- Add fields : source_doc ( Link : DocType ) ; order_group ( Dynamic Link : source_doc ) to Therapy Plan.
- In patient_encounter.py , add these to def create_therapy_plan
doc.source_doc = "Patient Encounter"
doc.order_group = encounter.name - Modified def make_therapy_session(service_request) ...below ..............( in service_request.py )
def make_therapy_session(service_request):
if isinstance(service_request, string_types):
service_request = json.loads(service_request)
service_request = frappe._dict(service_request)
if (
frappe.db.get_single_value("Healthcare Settings", "process_service_request_only_if_paid")
and service_request.billing_status != "Invoiced"
):
frappe.throw(
_("Service Request need to be invoiced before proceeding"),
title=_("Payment Required"),
)
# Fetch the linked Therapy Plan
therapy_plan = frappe.get_value(
"Therapy Plan",
{"custom_source_doc": service_request.source_doc, "custom_order_group": service_request.order_group},
"name",
)
doc = frappe.new_doc("Therapy Session")
doc.therapy_type = service_request.template_dn
doc.service_request = service_request.name
doc.company = service_request.company
doc.patient = service_request.patient
doc.patient_name = service_request.patient_name
doc.gender = service_request.patient_gender
doc.patient_age = service_request.patient_age_data
doc.practitioner = service_request.practitioner
doc.department = service_request.medical_department
doc.start_date = service_request.occurrence_date
doc.start_time = service_request.occurrence_time
doc.invoiced = service_request.invoiced
# Assign the therapy plan if found
if therapy_plan:
doc.therapy_plan = therapy_plan
else:
frappe.msgprint(_("No linked Therapy Plan found for this Service Request."), alert=True)
return doc
- Added the following client script fro Therapy Session........
frappe.ui.form.on('Therapy Session', {
onload(frm) {
if (frm.doc.therapy_type) {
setTimeout(() => {
frm.trigger('therapy_type');
}, 500); // Small delay to ensure field is populated
}
}
});
This ensures that the Therapy Type detail is fetched.
This will also fix #614
Module
Outpatient Module
Version
ERPNext: v15.40.0 (version-15)
Frappe Framework: v15.46.0 (version-15)
Marley Health: v16.0.0-dev (develop)
Payments: v0.0.1 (develop)
Installation method
None
Relevant log output / Stack trace / Full Error Message.
NoneCode of Conduct
- I agree to follow this project's Code of Conduct