The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
"Down smitten with a direful illness," etc.--This story the Master told at Jetavana about a certain man. We learn that there lived at Sāvatthi a man tormented by jaundice, given up by the doctors as a hopeless case. His wife and
son wondered who could be found to cure him. The man thought, "If I can only get rid of this disease, I will take to the religious life." Now it happened that some days after he took something that did him good, and got well. Then he went to Jetavana, and asked admission into the Order. He received the lesser and greater orders from the Master, and before long attained to sainthood. One day after this the brethren were talking together in the Hall of Truth: "Friend, So and so had jaundice, and vowed that if he got well he would embrace the religious life; he did so, and now he has attained sainthood." The Master came in, and asked what they talked about, sitting there together.  They told him. Then he said: "Brothers, this is not the only man who has done so. Long ago wise men, recovering from sickness, embraced a religious life, and secured their own advantage." And he told an old-world tale.
Once upon a time, when Brahmadatta was king of Benares, the Bodhisatta was born in a Brahmin family. He grew up, and began to amass wealth: but he fell sick of the jaundice. Even the physicians could do nothing for him, and his wife and family were in despair. He resolved that if he ever got well, he would embrace the religious life; and having taken something that did him good, he did get well, whereupon he went away to Himalaya and became a religious. He cultivated the Faculties and the Attainments, and dwelt in ecstatic happiness. "All this time," thought he, "I have been without this great happiness!" and he breathed out this aspiration:
"The noble seems ignoble, and pure the impure seems,
He that is blind, all beautiful a sink of foulness deems.
"Shame on that sickly body, shame, I say,
Loathsome, impure, and full of foul decay!
When fools are indolent, they fail to win
New birth in heaven, and wander from the way."
 Thus did the Great Being describe in various ways the nature of impurity and constant disease, and being disgusted with the body and all its parts, cultivated all his life the four excellent conditions of life, till he went to Brahma's world.
When the Master had ended this discourse, he proclaimed the Truths, and identified the Birth--many were they who attained the fruition of the First Path, and so forth--"At that time I myself was the ascetic."