Skip to content

Commit

Permalink
feat: Add nursing tasks for therapy sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillarAnand committed Nov 22, 2021
1 parent 3789b6e commit e126d38
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions healthcare/healthcare/doctype/therapy_plan/therapy_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def validate(self):
self.set_totals()
self.set_status()

def on_submit(self):
healthcare_settings = frappe.get_single("Healthcare Settings")
if not healthcare_settings.validate_nursing_checklists:
return
from healthcare.healthcare.utils import validate_nursing_tasks
validate_nursing_tasks(self)

def set_status(self):
if not self.total_sessions_completed:
self.status = 'Not Started'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ frappe.ui.form.on('Therapy Session', {
}
});
}

frm.add_custom_button(__("Nursing Tasks"), function () {
frappe.set_route("List", "Nursing Task", {"reference_name": frm.doc.name});
});

},

therapy_plan: function(frm) {
Expand Down
14 changes: 14 additions & 0 deletions healthcare/healthcare/doctype/therapy_session/therapy_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
get_income_account,
get_receivable_account,
)
from healthcare.healthcare.doctype.nursing_task.nursing_task import NursingTask


class TherapySession(Document):
Expand Down Expand Up @@ -47,6 +48,11 @@ def validate_duplicate(self):

def on_submit(self):
self.update_sessions_count_in_therapy_plan()
healthcare_settings = frappe.get_single("Healthcare Settings")
if not healthcare_settings.validate_nursing_checklists:
return
from healthcare.healthcare.utils import validate_nursing_tasks
validate_nursing_tasks(self)

def on_update(self):
if self.appointment:
Expand All @@ -58,6 +64,14 @@ def on_cancel(self):

self.update_sessions_count_in_therapy_plan(on_cancel=True)

def after_insert(self):
therapy_plan = frappe.get_doc('Therapy Plan', self.therapy_plan)
if therapy_plan.therapy_plan_template:
plan_template = frappe.get_doc('Therapy Plan Template', therapy_plan.therapy_plan_template)
template = plan_template.nursing_checklist_template
if template:
NursingTask.create_nursing_tasks_from_template(template, 'Therapy Session', self.name)

def update_sessions_count_in_therapy_plan(self, on_cancel=False):
therapy_plan = frappe.get_doc('Therapy Plan', self.therapy_plan)
for entry in therapy_plan.therapy_plan_details:
Expand Down

0 comments on commit e126d38

Please sign in to comment.