A FUNGAL meningitis infection last year that spread in contaminated vials of medicine distributed by the New England Compounding Center in Framingham, Mass., led to 749 people becoming ill and 61 deaths in 20 states. Without doubt, this outbreak could and should have been prevented. Now, Congress is making headway toward writing laws that would prevent similar occurrences.

This is not the first time Congress has attempted to tackle the problems of so-called compounding pharmacies, lightly regulated firms that mix and ship medicines to hospitals and clinics, but previous efforts were frustrated by lawsuits and ultimately were ineffective. A legacy of the 2012 outbreak must be hard and fast rules that would prevent another disaster.

The Senate is poised to act soon — perhaps this week — on legislation already reported out of committee that would take a large step in the right direction. The Pharmaceutical Quality, Security and Accountability Act would put some of the firms in question clearly under the regulatory control of the Food and Drug Administration (FDA).

The legislation creates a category of “compounding manufacturer” that would include large-scale firms, such as the New England Compounding Center, that mix the medicines prior to, or without, a prescription and ship them across state lines. This category of firms had largely fallen through the cracks. In the spring, FDA officials released initial results of a targeted inspection of 30 compounding pharmacies that mix sterile drugs, considered the highest risk because any breakdown in the process can result in contamination. The inspectors found dozens of potentially dangerous safety problems, including unidentified black particles in vials of sterile solution and rust and mold in clean rooms.

Under the legislation, these firms would be required to meet current “good manufacturing practices,” the high standards that are set for regular pharmaceutical manufacturers, and they would have to register with and be inspected by the FDA. Although there are always good reasons to ask hard questions about more federal regulation, this area of the drug business seems worthy of more oversight. The bill has been drafted so that traditional pharmacies, which were not the source of the problem, would continue to be regulated by states.

Because drafting legislation like this is difficult, the bill is not perfect. It contains some exemptions that cause us unease, including one for traditional compounders who mix drugs for health-care providers for use in their offices. This will continue to be beyond the FDA’s reach. Hopefully, that will not become the next source of an outbreak.

The legislation has been combined with a bill to fight counterfeit drug distribution, and we urge the Senate to vote expeditiously, despite recent lobbying from some business interests against the legislation. It is not yet clear whether or how the House will act, but Senate passage of the legislation would provide an important signal that Congress is ready to make sure such a catastrophe is not repeated.