From 55102a7100157a863f93f14f8d94eca9807957e2 Mon Sep 17 00:00:00 2001 From: Anoop Kurungadam Date: Tue, 3 Dec 2024 15:27:00 +0530 Subject: [PATCH] fix(test): nursing task tests --- .../doctype/nursing_task/test_nursing_task.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/healthcare/healthcare/doctype/nursing_task/test_nursing_task.py b/healthcare/healthcare/doctype/nursing_task/test_nursing_task.py index c6768cc33f..dbf4f72965 100644 --- a/healthcare/healthcare/doctype/nursing_task/test_nursing_task.py +++ b/healthcare/healthcare/doctype/nursing_task/test_nursing_task.py @@ -58,6 +58,8 @@ def test_lab_test_submission_should_validate_pending_nursing_tasks(self): lab_test.descriptive_test_items[2].result_value = 2.3 lab_test.save() + start_nusing_tasks(lab_test) + self.assertRaises(frappe.ValidationError, lab_test.submit) complete_nusing_tasks(lab_test) @@ -70,6 +72,8 @@ def test_start_clinical_procedure_should_validate_pending_nursing_tasks(self): procedure_template.save() procedure = create_procedure(procedure_template, self.patient, self.practitioner) + start_nusing_tasks(procedure) + self.assertRaises(frappe.ValidationError, procedure.start_procedure) complete_nusing_tasks(procedure) @@ -86,6 +90,7 @@ def test_admit_inpatient_should_validate_pending_nursing_tasks(self): NursingTask.create_nursing_tasks_from_template( ip_record.admission_nursing_checklist_template, ip_record, start_time=now_datetime() ) + start_nusing_tasks(ip_record) service_unit = get_healthcare_service_unit() kwargs = { @@ -103,6 +108,7 @@ def test_admit_inpatient_should_validate_pending_nursing_tasks(self): NursingTask.create_nursing_tasks_from_template( ip_record.admission_nursing_checklist_template, ip_record, start_time=now_datetime() ) + start_nusing_tasks(ip_record) self.assertRaises(frappe.ValidationError, discharge_patient, inpatient_record=ip_record) @@ -116,6 +122,7 @@ def test_submit_therapy_session_should_validate_pending_nursing_tasks(self): therapy_plan = create_therapy_plan() therapy_session = create_therapy_session(self.patient, therapy_type.name, therapy_plan.name) + start_nusing_tasks(therapy_session) self.assertRaises(frappe.ValidationError, therapy_session.submit) @@ -123,6 +130,20 @@ def test_submit_therapy_session_should_validate_pending_nursing_tasks(self): therapy_session.submit() +def start_nusing_tasks(document): + filters = { + "reference_name": document.name, + "mandatory": 1, + "status": ["not in", ["Completed", "Cancelled"]], + } + tasks = frappe.get_all("Nursing Task", filters=filters) + for task_name in tasks: + task = frappe.get_doc("Nursing Task", task_name) + task.submit() + task.status = "In Progress" # should set task_start_time + task.save() + + def complete_nusing_tasks(document): filters = { "reference_name": document.name,