"Real Housewives of Beverly Hills" star Kim Richards checked herself into an inpatient rehab facility late Wednesday, just hours before she was slated to appear in court in an ongoing public intoxication case.

Nearly three weeks after experiencing what appeared to be a severe relapse at her daughter's wedding and after a series of other public meltdowns, RadarOnline reports 50-year-old Richards agreed to enter the intensified program that could last up to two years.

Richards is also facing battery and resisting arrest charges stemming from the April 16 incident at the Beverly Hills Polo Lounge where she allegedly kicked a police officer. She did not attend Thursday morning's early court hearing.

Richards first entered rehab at the end of April; but while out on a pass to attend her daughter's wedding, she suffered an apparent relapse and never returned to the facility. On June 2, she entered another program in the Pacific Palisades that specializes in the treatment of mental disorders.

"Her bosses were aware she was entering a long term treatment program that allows her to work because she desperately wants to save the relationship with the network now," a source told Radar of Thursday's development.

Earlier this month, network officials announced plans to fire Richards in the face of all her struggles.

"It was decided this morning at a meeting that Kim is not being asked back on the show because of her failure to communicate everything with her bosses," a source told Radar on June 3.

Although it's reported that some had long considered her "a liability to the show," her week-long disappearing act following her drunken display at her daughter's wedding in late May seems to have sealed her fate.

"When Kim went missing in action she refused to answer calls of anyone from the network for the entire time," added a source. "They had to find out about her entering rehab again from a family member."