סדר יצירת הולד נמצא בכ"י בבית עקד הספרים בלייפציג אשר ממנו העתיק יעלינעק בבית המדרש שלו ח״א, ונוסחא כזו יש באבקת רוכל דף כ״ג ע״א דפוס אמשטרדם, ונוסחא משונה מזו בס' לקוטי הפרדס המיוחס לרש״י ז״ל דף ד׳ ע״ד. The order of the fetus's formation can be found in the manuscript collection in the "Beit Aked Sefarim" in Leipzig. From there, Ya'alinak copied it into his "Beit Hamidrash", Part 1. A similar version is found in "Avkat Rochel", page 23a, Amsterdam edition. Another variant is in the book "Likutei Hapardes", attributed to Rashi, on page 4d.
מקור המדרש הוא בתלמוד מה שדרש ר׳ שמלאי, למה הולד דומה במעי אמו לפנקס שמקופל ומונח ידיו על שתי צדעיו, שתי אציליו על שתי ארכובותיו ושתי עקביו על שתי עגבותיו וראשו מונח לו בין ברכיו ופיו סתום וטבורו פתוח ואוכל ממה שאמו אוכלת ושותה ממה שאמו שותה ואינו מוציא רעי שמא יהרוג את אמו, וכיון שיצא לאויר העולם נפתח הסתום ונסתם הפתוח, שאלמלא כן אינו יכול לחיות אפילו שעה אחת, ונר דלוק לו על ראשו וצופה ומביט מסוף העולם ועד סופו וכו' (נדה ל׳:). ואמר רבי אליעזר למה ולד דומה במעי אמו לאגוז מונח בספל של מים, אדם נותן אצבעו עליו שוקע לכאן ולכאן. ת״ר שלשה חדשים הראשונים ולד דר במדור התחתון, אמצעיים ולד דר במדור האמצעי, אחרונים ולד דר במדור העליון, וכיון שהגיע זמנו לצאת מתהפך ויוצא, וזהו חבלי לידה. והיינו דתנן חבלי של נקבה מרובין משל זכר וכו׳ זה בא כדרך תשמישו וזה בא כדרך תשמישו, זו הופכת פניה וזה אין הופך פניו וכו׳ (שם ל״א.). The origin of this Midrash is from the Talmud, as taught by Rabbi Simlai: Why is a fetus in its mother's womb similar to a notebook that's folded? Its hands are on its two sides, its temples on its two thighs, its heels on its buttocks, and its head rests between its knees. Its mouth is sealed, and its navel is open. It eats from what its mother eats and drinks from what its mother drinks. It does not excrete waste, lest it harm its mother. When it emerges into the world, the sealed mouth opens, and the open navel seals. If not for this, it couldn't live even an hour. A candle burns above its head, and it sees from one end of the world to the other, etc. (Niddah 30b). Rabbi Eliezer said: Why is a fetus in its mother's womb similar to a nut in a cup of water? When a person places a finger on it, it sinks here and there. The Sages taught: In the first three months, the fetus resides in the lower chamber. In the middle months, it resides in the middle chamber. In the final months, it resides in the upper chamber. When the time comes for it to be born, it turns and exits, which is the pain of childbirth. As we've learned, the birth pangs of a female are more intense than those of a male. One comes in the manner of intercourse, and the other in the manner of its intercourse. One turns its face, and the other does not turn its face, etc. (Niddah 31a).