The New York state Medicaid system was found to have improperly shelled out nearly a million dollars for the treatment of erectile dysfunction over a six-year period, with more than $60,000 going toward registered sex offenders who are barred from such benefits.

The numbers came from a state audit, as reported by the Rochester Democrat & Chronicle. The audit states that between April 1, 2012, and July 1, 2018, the state improperly paid $933,594 for "drugs, procedures, and supplies to treat ED," even though state and federal laws prohibit Medicaid payments for ED treatments like Viagra.

FEDERAL JUDGE BLOCKS MEDICAID WORK RULES IN SETBACK FOR TRUMP

"There are clear rules about what conditions Medicaid will cover when it comes to erectile dysfunction drugs," State Comptroller Thomas DiNapoli said in a statement. "And paying for sex offenders who’ve committed terrible crimes to get these drugs should never be lost in the bureaucratic administration of this program.”

Medicaid funds are only permitted to be spent on ED drugs if there is an additional FDA-approved use and the drugs are meant for that other use. New York law has even stricter prohibitions when it comes to registered sex offenders, barring any Medicaid funding to them for ED-related drugs or treatment.

According to the state audit, 47 sex offenders (30 of whom were classified as level 2 or 3 offenders) benefitted from Medicaid assistance for ED treatment, totaling $63,301.

The New York State Health Department said it "strongly disagrees with the Comptroller’s conclusions," noting that ED drugs are also used for hypertension and other conditions.

"In these cases, we thoroughly review the sex offender registry to prevent sex offenders from receiving drugs that could treat ED/SD," the Health Department said, according to the Democrat & Chronicle.

CALIFORNIA DEMS AGREE TO FULL HEALTH BENEFITS FOR MANY LOW-INCOME ILLEGAL IMMIGRANTS, IN SWIPE AT TRUMP

DiNapoli's audit, however, stated that more often than not, Medicaid recipients' sex offender statuses were not properly checked through the proper Erectile Dysfunction Verification System.

The Health Department admitted that overall there may have been $8,000 in payments during the audit period that raised flags, but that was out of a budget of more than $60 billion per year.