Medical conditions such as epilepsy or infection with human immunodeficiency virus (HIV) are known to be associated with a spectrum of adverse health outcomes if not appropriately managed by efficacious treatment and care. Medications for such conditions can be potent, and their use might sometimes have unintended health consequences. Prominent examples have emerged in HIV perinatal research in which use of antiretroviral treatment during pregnancy to treat maternal HIV infection and prevent transmission of the virus to the fetus have been shown to be associated with adverse birth outcomes. Likewise, use of antiepileptic drugs during pregnancy to treat maternal epilepsy has been shown to increase the risk of birth defects. Pharmacoepidemiology studies routinely aim to quantify the extent to which, in such settings, an observed association between an underlying medical condition and certain health outcomes can be attributed to the natural progression of the disease, and the extent to which it might be mediated by medication used to slow disease progression. We describe a simple yet principled methodology to quantify medication-mediated effects to address these types of queries. While methods for causal mediation analysis abound, there also has been much criticism of these methods as relying on untestable and sometimes unrealistic assumptions. In contrast, here we show that when the disease-free control group is also medication-free, mediated effects of the type described above are nonparametrically identified under standard no-unobserved confounding conditions, thus establishing that such effects are in a sense immune to recent criticism leveled at causal mediation methodology.