A memory of Joseph may have been merged into the legend of Imhotep:
“According to Egyptologists, the Pharaoh Djoser employed an adviser named Imhotep, who designed his pyramid. Prior to that time, Pharaohs were buried in low, rectangular structures called mastaba. Imhotep’s design used a creative combination of stone and architecture to create a “step pyramid.” This building was significantly larger, more durable, and more beautiful than the tombs that preceded it. Djoser was so impressed with the result that he allowed Imhotep’s name to be inscribed within the tomb—something incredibly rare in Egyptian history.
“Secondary evidence suggests Imhotep was an accomplished physician. There are reasons to believe he wrote the Edwin Smith Papyrus, an ancient text on diagnosing and treating different medical conditions. Mythology of later centuries considered Imhotep a god or demigod of medicine.
“Legend also connects Imhotep to Egypt’s rescue from a seven-year famine. Inscriptions, carved many centuries later during the reign of Ptolemy, credit Imhotep with ending a long drought connected to the lack of flooding of the Nile River. Imhotep’s deliverance of Egypt involved his receiving a dream from one of the Egyptian gods and counseling the Pharaoh on the best way to make amends with the offended deity.” [Gotquestions.org]