In Romans 3:8, Paul teaches that it is wrong to do evil to achieve good:
And why not say—as we are accused and as some claim we say—that we should do evil that good may come of it? Their penalty is what they deserve.
This principle is explicitly reaffirmed by the Catechism of the Catholic Church, paragraph 1789. However, in Catholicism, a distinction is drawn between physical evil and moral evil. "Physical evil" is what St. Thomas Aquinas would call "corruption* and defect" ("corruptio et defectus"), corruption being the change from existence to non-existence.**
*cf. "What are “generation and corruption” in Aristotle's philosophy?"
**Summa contra Gentiles III cap. 71 ("That divine providence does not entirely exclude evil from things")
According to Catholicism, is it ever permissible to produce physical evil so that good may result?
My understanding is that the answer is yes. For example, when performing a medical surgery, it is acceptable for the surgeon to intentionally damage the patient's skin (physical evil) as a means to saving the patient's life (a good end). I want to make sure I'm thinking about this correctly. I would most appreciate answers drawing on quotes from the Magisterium, but I'd also appreciate relevant quotes from Catholic theologians.