The 1984 federal law that spawned the generic pharmaceutical industry was designed to use the basic idea of economic competition to lower the cost of prescription medicine for millions of Americans.

The law has largely served its intended purpose. The Centers for Medicare and Medicaid Services said in January that the national rate of retail prescription drug spending slowed in 2012, growing only 0.4 percent because of "numerous drugs losing patent protection, leading to increased sales of lower-cost generics."

But no market can be perfect, even good, for every participant all the time, and some of the 12,000 generic drugs on that market have skyrocketed in price in the last 18 months, according to people in the industry.

Generic drugs usually still cost less than their brand-name equivalents, but makers of generic drugs are in business to make money. Companies have stopped making certain products or stopped selling them in certain places because the competition is too great or the demand too low to make what they deem an acceptable profit. Companies have bought out competitors to pare the field.

"We are the only country in the world where drug companies can charge whatever they like because they can, and to me, it's not right," said Bridesburg resident Casimir Janczewski, who saw the out-of-pocket price of his generic prescription skin cream rise from about $26 in April to about $112 in October, even with insurance from Aetna. Janczewski's annoyance increased when he learned that the drug's manufacturer, Teva Pharmaceutical Industries Ltd., had increased its profits on generics.

Janczewski, 73, said this week he went to a neighborhood Rite Aid pharmacy and learned that the cash price of his fluocinonide cream had risen to $159. But by then, he had abandoned the product.

"When I went to get it refilled in October and the pharmacist said it was $112, I said, 'No way,' " Janczewski said. "I used antibiotic skin cream I bought off the shelf for $3. They lost a customer."

For patients with more serious conditions, that is not an option. And Janczewski is not alone in his concern. A federal grand jury in Philadelphia and the Connecticut attorney general are looking into possible antitrust violations by generic drugmakers. The U.S. Senate Subcommittee on Primary Care and Aging will hold a hearing Thursday in Washington in the hope of getting some answers.

"We've got to get to the bottom of these enormous price increases," the subcommittee chairman, Bernie Sanders (Ind., Vt.), said in a statement. "It is unacceptable that Americans pay by far the highest prices in the world for prescription drugs. Generic drugs were meant to help make medications affordable for the millions of Americans who rely on prescriptions to manage their health needs, and now some of them are becoming unaffordable."

A spokesman for the Generic Pharmaceutical Association (GPhA), an industry trade group, cited numerous articles and studies about how generic drugs have lowered the cost of health care and increased the availability of medicine. He declined to comment Wednesday on the Senate hearing, but said the association would release a statement Thursday. On Sept. 24, the 30th anniversary of the signing of the Drug Price Competition and Patent Term Restoration Act, the CEO of the GPhA, Ralph Neas, noted that studies suggest the law saved $239 billion in health-care costs in 2013 and created "a new framework allowing safe, affordable generic drugs to come to the market."

To reward innovation, brand-name drugs get a monopoly position in the U.S. market, which allows companies to charge more money until the patent expires. After that, assuming they have FDA approval, generic companies can sell their replica versions. The assumption is that the generic will be cheaper because most consumers would opt for the original if it were the same price - but there is no guarantee other market forces won't push generic prices higher than they were previously.

A few of the highest-price new drugs get a public price tag. However, throughout the circuitous drug supply chain, prices are often opaque. Manufacturers, wholesalers, pharmacy benefit managers, drugstore chains, and insurers all negotiate the cost of drugs and payment terms. That applies to brand-name and generic drugs.

Adam J. Fein of Philadelphia, who follows the pharmaceutical supply chain as president of Pembroke Consulting, wrote in August that half of all retail generics got more expensive in the previous 12 months, with one out of 11 more than doubling in cost and some increasing more than 1,000 percent.

Sanders' committee sent letters to 14 generic-drug companies, seeking explanations for price increases. Twelve of the 14 companies have headquarters or U.S. generic operations in Pennsylvania or New Jersey.

In alphabetical order, the Pennsylvania companies were Endo International P.L.C. (Malvern), Impax Laboratories Inc.'s subsidiary Global Pharmaceuticals (Chalfont), Lannett Co. (Philadelphia), Mylan Inc. (Canonsburg), and Teva Pharmaceutical Industries Ltd. (North Wales). The New Jersey companies were Actavis P.L.C. (Parsippany), Dr. Reddy's Laboratories Ltd. (Princeton), Heritage Pharmaceuticals Inc. (Eatontown), Par Pharmaceutical Cos. (Woodcliff Lake), Sun Pharmaceutical Industries Inc. (Cranbury), West-Ward Pharmaceutical Corp. (Eatontown), and Zydus Pharmaceuticals USA Inc. (Pennington).

Teva chief executive officer Erez Vigodman and Lannett CEO Arthur Bedrosian were among those invited to testify. Teva spokeswoman Denise Bradley said Vigodman was in Israel, where Teva is based, and would not attend the hearing. Robert Jaffe, a spokesman for Lannett, said the company did not want to be interviewed.

Impax and Lannett said in filings with the Securities and Exchange Commission that they received subpoenas Nov. 3 from the Justice Department's antitrust division, which wanted documents relating to "communications or correspondence with competitors regarding the sale of generic prescription medications," according to the Lannett filing.

Robert Frankil, who will testify Thursday, owns two pharmacies in Sellersville, Bucks County, where Teva is closing a factory.

"When the number of manufacturers drops to one or two or three, that's when you see the prices skyrocket," said Frankil, who noted that insurance company reimbursement adjustments are not made until months later, so he might have to sell a drug for a $20 co-pay while it costs him $300 or $400 to buy it wholesale.

"I understand the law of supply and demand," he added, "but I'm seeing 3,000 percent increases, which goes way beyond supply and demand."

dsell@phillynews.com 215-854-4506