Modified patient save function