The order Tuesday came after doctors evaluated O'Ryan, who had traveled from Florida to Los Angeles to try to meet the gymnast.
During trial, a prosecutor described O'Ryan as harboring a dangerous obsession involving Johnson.
After the arrest of O'Ryan, police found two loaded guns, a knife and love notes addressed to Johnson in his car.