Officials said the gunman was fatally shot by the police and that two officers and three staff members at UPMC Memorial hospital in York County, Pa., were wounded but were in stable condition.