Real Time change in the doctype

I was trying to change the status of studnet enable/disable on the basis of thir fee paid .
what i did make an api req and then use frappe.call on refresh doc . I want that when the function triggers it changes the field value of the doc type and then save automaticlly.