How long do patients with gastroparesis stay on medication?

Depends. I would assume that depends on the cause of gastroparesis. If this is acute and self limited due to a viral illness then that should resolve in days to weeks. If it is related to a chronic condition then that may depend on how well controlled the chronic condition may be (i.e. diabetes). Sorry but cannot give you a definitive answer.
Long. Mind you the cause matters when answering this question, gastroparesis is usually long term therapy illness, most times lifelong.