While he was trapped inside Gluttony, Edward performed human transmutation on himself in order to access his Gate. This means that he had to deconstruct and reconstruct himself, but I don't understand how he was able to re-create himself when he doesn't even have basic medical knowledge.
Alchemy is not a walk-in-the-park task. The process of learning alchemy is arduous. While some people are naturally talented and intellectual than others, perfecting alchemy takes years of practice. From a young age, Edward and Alphonse Elric were exposed to alchemy, especially as their father had been a brilliant alchemist and left a gargantuan collection of books behind for the kids to read. This, however, was in addition to their already curious minds and their prodigal level of skill.
[picture from this answer (please upvote if you like my answer)]
[...] he doesn't even have basic medical knowledge.
Wrong. Edward Elric was an alchemical prodigy and almost everyone considered him to be a genius. From wiki:
Edward Elric is an alchemical prodigy of genius level intellect. From early childhood, he displayed proficiency for alchemy, acquiring self-taught alchemy skills and comprehension from the advanced literature in his father's abandoned study at an age. Having incorporated alchemy into his life during his developmental stages, Edward sees the world alchemically and is, therefore, able to solve complicated codes, puzzles, and mysteries much more easily than normal. He has also shown himself to be exceptionally adept at chemistry and reasonably competent with biology; indeed even his preparations for the failed attempt to resurrect his mother were indicative of these. Edward's near-encyclopedic knowledge of alchemical theory is astounding and contributed to his incredible success with emergency Soul Binding experimentation. He shows an uncanny level of focus that allows him to effectively shut out everything from his surroundings and devote all of his considerable mental power to whatever problem demands his attention, especially in the case of books.
He did had a superior medical knowledge and hence attempted to resurrect his mother with the help of the laws of alchemy but due to limited experience it failed. But after years and years of study and practice and sheer perseverance, he gained knowledge and perfected alchemy and successfully performed human transmutation on himself.