In medicine, the term opiate describes any of the narcotic opioid alkaloids found as natural products in the opium poppy plant, as well as many semisynthetic chemical derivatives of such alkaloids.
Opiates are so named because they are constituents or derivatives of constituents found in opium, which is processed from the latex sap of the opium poppy, Papaver somniferum. The major biologically active opiates found in opium are morphine, codeine, thebaine, and papaverine. Semi-synthetic opioids such as heroin, oxycodone, and hydrocodone are derived from these substances, especially morphine, codeine, and thebaine. Noscapine, along with approximately 25 other alkaloids, are also present in opium, but have little to no effect on the human central nervous system, and are not usually considered to be opiates.
Opiates belong to the large biosynthetic group of benzylisoquinoline alkaloids.
The full synthesis of opiates from naphthoquinone (Gates synthesis) or from other simple organic starting materials is tedious and not economical. Thus, all the opiate-type analgesics in use today are extracted from Papaver somniferum or semi-synthesized from thebaine. 
In the traditional sense, opiate has referred to not only the alkaloids in opium but also the natural and semi-synthetic derivatives of opium. The term is often incorrectly used to refer to all drugs with opium- or morphine-like pharmacological action, which are more properly classified under the broader terms opioid.
Morphine is by far the most prevalent alkaloid in opium, making up anywhere from 10% to 16% of the total mass, and is responsible for many of its potentially harmful effects, such as pulmonary edema, respiratory depression, coma, cardiac and/or respiratory failure, with a normal lethal dose of 120 to 250 mg which corresponds to approximately two grams of opium.) However, the occurrence of pulmonary edema is uncommon. The most frequently-reported occurrences of opiate-induced pulmonary edema are among recreational heroin users. Although uncommon, reports of morphine-induced pulmonary edema are not unheard of. The primary difference is the more careful supervision of morphine administration compared to the lack of supervision and medical expertise among illicit heroin users. On the other hand, morphine may also be used in the treatment of pulmonary edema. Despite morphine's being the most medically-significant alkaloid, larger quantities of the milder codeine—most of it manufactured from morphine—are consumed medically, as codeine has a greater and more predictable oral bioavailability than morphine, making it easier to titrate one's dose.
Full article ▸