An agent who intends harm but accidentally produces good (e.g., intending to kill a neighbor but accidentally healing a boil) has not performed a morally good action, because the action was not undertaken in accordance with the moral law.
The party in a principal-agent relationship who is instructed to produce the good or service on the principal's behalf — in the medical context, the doctor
moral law(Locke's moral philosophy; The Reasonableness of Christianity)
A law constituted by God's imposition, which alone creates genuine obligation — distinct from rational counsel or advice about morality
Bolzano stresses that, in assessing an action according to the principle of advancing the general welfare, one must “not only look at its proximate consequences, but also at further ones” (RW I, 237). Since we can never know all the consequences of an action, the principle of advancing the general welfare demands that we always decide in favor of the action which seems most conducive to the welfare of the whole according to those consequences thereof which we can foresee arising from it (RW I, 2