Cost Functions for a Service Firm with Variable Quality and Stochastic Demand: The Case of Hospitals