A federal judge has ordered the Arizona prison system to improve the way it administers health care and detains people.