In the field of pharmacy, compounding (performed in compounding pharmacies) is preparation of custom medications to fit unique needs of patients that cannot be met with mass-produced products. This may be done, for example, to provide medication in a form easier for a given patient to ingest (e.g., liquid vs. tablet), or to avoid a non-active ingredient a patient is allergic to, or to provide an exact dose that isn't otherwise available. This kind of patient-specific compounding, according to a prescriber's specifications, is referred to as "traditional" compounding. The nature of patient need for such customization can range from absolute necessity (e.g. avoiding allergy) to individual optimality (e.g. ideal dose level) to even preference (e.g. flavor or texture).
 Hospital pharmacies typically engage in compounding medications for intravenous administration, whereas outpatient or community pharmacies typically engage in compounding medications for oral or topical administration. Due to the rising cost of compounding and drug shortages, some hospitals outsource their compounding needs to large-scale compounding pharmacies, particularly of sterile-injectable medications.
 Compounding preparations of a given formulation in advance batches, as opposed to preparation for a specific patient on demand, is known as "non-traditional" compounding and is akin to small-scale manufacturing. Jurisdictions have varying regulations that apply to drug manufacturers and pharmacies that do advance bulk compounding.
 The earliest chemists were familiar with various natural substances and their uses. They compounded a variety of preparations such as medications, dyes, incense, perfumes, ceremonial compounds, preservatives and cosmetics. In the medieval Islamic world in particular, Muslim pharmacists and chemists developed advanced methods of compounding drugs. The first drugstores were opened by Muslim pharmacists in Baghdad in 754. The modern age of pharmacy compounding began in the 19th century with the isolation of various compounds from coal tar for the purpose of producing synthetic dyes. From this came the earliest antibacterial sulfa drugs, phenolic compounds made famous by Joseph Lister, and plastics.
 During the 1800s, pharmacists specialized in the raising, preparation and compounding of crude drugs.  Crude drugs, like opium, are from natural sources and usually contain several chemical compounds.  The pharmacist extracted these drugs using solvents such as water or alcohol to form extracts, concoctions and decoctions. They eventually began isolating and identifying the active ingredients in these drug concoctions. Using fractionation or recrystallization, they separated an active ingredient from the crude preparation, and compounded a medication using this active ingredient.
 With the isolation of medications from the raw materials or crude drugs came the birth of the modern pharmaceutical company. Pharmacists were trained to compound the preparations made by the drug companies, but they could not do it efficiently on a small scale. So economies of scale, not lack of skill or knowledge, produced the modern pharmaceutical industry. With the turn of the 20th century came greater government regulation of the practice of medicine.  These new regulations forced the drug companies to prove that any new medication they brought to market was safe. With the discovery of penicillin, modern marketing techniques and brand promotion, the drug manufacturing industry came of age.  Pharmacists continued to compound most prescriptions until the early 1950s when the majority of dispensed drugs came directly from the large pharmaceutical companies.
 A physician may choose to prescribe a compounded medication for a patient with an unusual health need that cannot be met with commercially manufactured products. The physician may choose to prescribe a compounded medication for reasons such as
 In hospitals, pharmacists and pharmacy technicians often make compounded sterile preparations (CSPs) using manual methods. The error rate for manually compounded sterile IV products is high. The Institute for Safe Medication Practices (ISMP) has expressed concern with manual methods, particularly the error-prone nature of the syringe pull-back method of verifying sterile preparations. To increase accuracy, some U.S. hospitals have adopted IV workflow management systems and robotic compounding systems. These technologies use barcode scanning to identify each ingredient and gravimetric weight measurement to confirm the proper dose amount. The workflow management systems incorporate software to guide pharmacy technicians through the process of preparing IV medications. The robotic systems prepare IV syringes and bags in an ISO Class 5 environment, and support sterility and dose accuracy by removing human error and contamination from the process.
 In Australia the Pharmacy Board of Australia is responsible for registration of pharmacists and professional practice including compounding. Although almost all pharmacies are able to prepare at least simple compounded medicines, some pharmacy staff undertake further training and education to be able to prepare more complex products. Although pharmacists who have undertaken further training to do complex compounding are not yet easily identified, the Board has been working to put a credentialing system in place. In 2011 the Pharmacy Board convened a Compounding Working Party to advise on revised compounding standards. Draft compounding guidelines for comment were released in April 2014. Pharmacists must comply with current guidelines or may be sanctioned by the Board.
 Both sterile and non-sterile compounding are legal provided the compounding is done for therapeutic use in a particular patient, and the compounded product is supplied on or from the compounding pharmacy. There are additional requirements for sterile compounding. Not only must a laminar flow cabinet [laminar flow hood] be used, but the environment in which the hood is located must be strictly controlled for microbial and particulate contamination and all procedures, equipment and personnel must be validated to ensure the safe preparation of sterile products. In non-sterile compounding, a powder containment hood is required when any hazardous material (e.g. hormones) are prepared or when there is a risk of cross-contamination of the compounded product. Pharmacists preparing compounded products must comply with these requirements and others published in the Australian Pharmaceutical Formulary & Handbook.[citation needed]
 In the United States, compounding pharmacies are licensed and regulated by states. National standards have been created by Pharmacy Compounding Accreditation Board (PCAB), however, obtaining accreditation is not mandatory and inspections for compliance occur only every three years. The Food and Drug Administration (FDA) has authority to regulate "manufacturing" of pharmaceutical products—which applies when drug products are not made or modified as to be tailored in some way to the individual patient—regardless of whether this is done at a factory or at a pharmacy.
 In the Drug Quality and Security Act (DQSA) of 2013 (H.R. 3204), Congress amended the Federal Food, Drug, and Cosmetic Act (FFDCA) to clarify limits of FDA jurisdiction over patient-specific compounding, and to provide an optional pathway for "non-traditional" or bulk compounders to operate. The law established that pharmacies compounding only "patient-specific" preparations made in response to a prescription (503A pharmacies) cannot be required to obtain FDA approval for such products, as they will remain exclusively under state-level pharmacy regulation. At the same time, section 503B of the law regulates "outsourcing facilities" which conduct bulk compounding or are used as outsourcing for compounding by other pharmacies. These outsourcing facilities can be explicitly authorized by the Food and Drug Administration under specified circumstances, while being exempted from certain requirements otherwise imposed on mass-producers. In any pharmacy, compounding is not permitted for a drug product that is "essentially a copy" of a mass-produced drug product, however outsourcing pharmacies are subject to a broader definition of "essentially a copy". For traditional/patient-specific compounding, 503A's definition of "copy" retains its original focus on drug products or ultimate dosage forms rather than drug substances or active ingredients, and in any event it explicitly excludes from its definition any compounded drug product that a given patient's prescribing practitioner determines makes a "significant difference" for the patient.
 The FDA weighs the following factors in deciding whether it has authority to "exercise its discretion" to require approval for a custom-compounded drug product:
 The DQSA amended the FFDCA to create a new class of FDA-regulated entities known as "outsourcing facilities" whose compounding activities "may or may not" be patient-specific based on individualized prescriptions.  Registered outsourcing facilities, unlike traditional compounding facilities, are subject to the FDA's oversight. In addition to being subjected to Food and Drug Administration inspections, registration, fees, and specified reporting requirements, other requirements of outsourcing facilities include:
 Poor practices on the part of drug compounders can result in contamination of products, or products that do not meet their stated strength, purity, or quality. Unless a complaint is filed or a patient is harmed, drugs made by compounders are seldom tested. In Texas, one of only two states that does random testing, significant problems have been found. Random tests by the state's pharmacy board over the last several years have found that as many as one in four compounded drugs was either too weak or too strong. In Missouri, the only other state that does testing, potency varied by as much as 300 percent.
 In 2002, the Food and Drug Administration, concerned about the rising number of accidents related to compounded medications, identified "red flag" factors and issued a guide devoted to human pharmacy compounding,  These factors include instances where pharmacists are:
 In October 2012 news reports surfaced of an outbreak of fungal meningitis tied to the New England Compounding Center, a pharmacy which engaged in bulk compounding.
 At that time it was also disclosed that the United States and Massachusetts state health regulators were aware in 2002 that steroid treatments from the New England Compounding Center could cause adverse patient reactions. It was further disclosed that in 2001–02, four people died, more than a dozen were injured and hundreds exposed after they received back-pain injections tainted with a common fungus dispensed by two compounding pharmacies in California and South Carolina.
 In August 2013 further reports tied to the New England compounding center said that about 750 people were sickened, including 63 deaths, and that  infections were linked to more than 17,600 doses of methylprednisolone acetate steroid injections used to treat back and joint pain that were shipped to 23 states. At that time, another incident was reported  after at least 15 people at two Texas hospitals developed bacterial infections. All lots of  medications dispensed since May 9, 2013,  made by Specialty Compounding, LLC of Cedar Park, Texas were recalled. The hospitals reported affected  were Corpus Christi Medical Center Bay Area and Corpus Christi Medical Center Doctors Regional. The patients had received intravenous infusions of calcium gluconate, a drug used to treat calcium deficiencies and too much potassium in the blood. Implicated in these cases is the Rhodococcus bacteria, which can cause symptoms such as fever and pain.
 The FDA, among others, claims that larger compounding pharmacies act like drug manufacturers and yet circumvent FDA regulations under the banner of compounding. Drugs from compounding pharmacies can be cheaper or alleviate shortages, but can pose greater risk of contamination due in part to the lack of oversight. "Non-traditional" compounders behave like drug manufacturers in some cases by having sales teams that market non-personalized drug products or production capability to doctors, by making drugs that are essentially the same as commercially available mass-produced drug products, or by preparing large batches of a given drug product in anticipation of additional prescriptions before actually receiving them. An FDA spokesperson stated, "The methods of these companies seem far more consistent with those of drug manufacturers than with those of retail pharmacies.  Some firms make large amounts of compounded drugs that are copies or near copies of FDA-approved, commercially available drugs. Other firms sell to physicians and patients with whom they have only a remote professional relationship." The head of the FDA has recently requested the following authority from Congress:
 Various ideas have been proposed to expand federal US regulation in this area, including laws making it easier to identify misuse or misnomered-use and/or stricter enforcement of the longstanding distinction between compounding versus manufacturing. Some US states have also taken initiatives to strengthen oversight of compounding pharmacies. A major source of opposition to new Food and Drug Administration regulation on compounding is makers of dietary supplements.