Britney Spears will be checking herself out of the mental health facility where she's been for 30 days -- as early as today -- but we've learned she's still dealing with a big, unresolved issue ... her meds.

Sources with direct knowledge tell TMZ, Britney's mental state is much better than it was when she checked in. As we reported, the singer was distraught over an illness her dad was battling ... made exponentially worse by the fact the meds she'd been taking for her mental illness stopped working.

Doctors were trying to find a new combo of meds, but they couldn't get the mixture right and it was doing Britney more harm than good ... to the point she stopped taking them.

Our sources say doctors still haven't figured out the right formula and call it, "a work in progress."

The sources are quick to say, Britney did NOT check into the facility to get her meds right ... it was to get her head straight. We're told she's doing "a lot better" in that department, but the doctors continue to work on the cocktail of meds.

A lot of people commented on the pic of Britney with her boyfriend, Sam Asghari, on Easter Sunday, where she looked a little off. Our sources acknowledge, she's still having difficulty, but nonetheless is in a better head space.

We're told she could leave the mental health facility as early as today but definitely by week's end ... and she's almost certainly going home. Doctors will continue to work with her on getting the medicines right.