Skip to content

Commit

Permalink
fix(test): nursing task tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akurungadam committed Dec 3, 2024
1 parent 9ab8a6f commit 55102a7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions healthcare/healthcare/doctype/nursing_task/test_nursing_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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 = {
Expand All @@ -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)

Expand All @@ -116,13 +122,28 @@ 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)

complete_nusing_tasks(therapy_session)
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,
Expand Down

0 comments on commit 55102a7

Please sign in to comment.