Skip to content

Commit

Permalink
fix: initialize task_end_time before calculating task_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
akurungadam committed Dec 3, 2024
1 parent 63cb480 commit b8fce81
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions healthcare/healthcare/doctype/nursing_task/nursing_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@

class NursingTask(Document):
def before_insert(self):
# set requested start / end
self.set_task_schedule()

self.title = "{} - {}".format(_(self.patient), _(self.activity))

self.age = frappe.get_doc("Patient", self.patient).get_age()

def validate(self):
if self.status == "Requested":
# auto submit if status is Requested
self.docstatus = 1

def on_submit(self):
Expand All @@ -47,10 +43,11 @@ def on_update_after_submit(self):
self.db_set("task_start_time", now_datetime())

elif self.status == "Completed":
task_end_time = now_datetime()
self.db_set(
{
"task_end_time": now_datetime(),
"task_duration": time_diff_in_seconds(self.task_end_time, self.task_start_time),
"task_end_time": task_end_time,
"task_duration": time_diff_in_seconds(task_end_time, self.task_start_time),
}
)

Expand Down

0 comments on commit b8fce81

Please sign in to comment.