RALEIGH (AP) — Far-reaching legislation designed to change how North Carolina government bills Medicaid patient treatment is going to Gov. Pat McCrory after the General Assembly approved Tuesday a final compromise measure that was years in the making.

The legislation, voted for separately by the Senate and House, lays out the pathway by 2018 or 2019 to end the current fee-for-service system in which Medicaid in North Carolina reimburses doctors and hospitals for each service performed on a patient. Medicaid critics contend the practice has led to cost overruns and uncertainty.

It directs the state to enter into contracts with an array of commercial managed-care companies or local hospital or doctor networks. Three such “prepaid health plans” will operate statewide, while up to 10 contracts that cover regions of the state would go to the provider-led networks.

The plans will receive fixed monthly amounts for each patient they treat, set by the Department of Health and Human Services. The organizations take the profit or loss — shifting the risks away from the state, which under the current system is expected to spend more than $3.7 billion on Medicaid this year.

“It is a fundamental change in how Medicaid is done,” said Sen. Ralph Hise, R-Mitchell, the Senate’s chief Medicaid negotiator.

House members passed a bill earlier this year that allowed only provider-led networks to participate, which McCrory’s administration also supported. Senate Republicans insisted on a hybrid model.

“It is a very good framework that resolves the reform conflict and moves North Carolina forward, just as many other states are already doing,” said Rep. Donny Lambeth, R-Forysth, the House’s top negotiator, adding there will be an emphasis on patient satisfaction, quality treatment and budget stability.

McCrory’s office didn’t immediately respond to emails late Tuesday seeking comment from the governor, who will be asked to sign the bill into law. In an interview last week, McCrory expressed eagerness in seeing final Medicaid reform.

Only three Democrats overall voted ‘yes’ for the final plan. Many Democrats argued private insurance companies would erode Medicaid patient treatment to increase their bottom lines. Other complained the agreement failed to expand Medicaid under the federal health care law.

“It’s not reform, its regression,” said Rep. Joe Sam Queen, D-Haywood. “There will not be better satisfaction, there will not be lower costs … there will not be better outcomes.”

Six Republicans overall voted no, including Rep. Nelson Dollar, R-Wake, who had earlier led the charge for the House version of a Medicaid overhaul. Dollar said the introduction of commercial managed care companies could reverse a recent trend of reduced per-patient Medicaid claims costs over the past five years even as Medicaid enrollment has grown.

“We need reform in North Carolina that is based on caring for our citizens, and not for a group of stockholders,” Dollar said.

Federal regulatory hurdles await the new plan, which also would replace the Division of Medical Assistance with a new Division of Health Benefits. The division would oversee Medicaid, which has 1.8 million patients — mostly poor children, older adults and the disabled.

The new program wouldn’t apply to dental coverage. Services for the mentally ill, substance abusers and people with developmental disabilities would remain in their current, separate managed-care format until at least the early 2020s.

The North Carolina Medical Society and N.C. Hospital Association opposed permitting managed-care companies to enter into contracts. Nearly 40 states already have some kind of coordinated care for Medicaid enrollees, according to Medicaid Health Plans of America. Jeff Myers, the group’s CEO, praised the final legislation Tuesday night.

Community Care of North Carolina, a nonprofit that helped primary-care physicians oversee Medicaid patient medical care, ultimately would see its contract with the state end when “prepaid health plans” begin enrolling patients.