The joint optimization problem of multiresource capacity planning and multitype patient scheduling under uncertain demands and random capacity consumption poses a significant computational challenge. The common practice in solving this problem is to first identify capacity levels and then determine patient scheduling decisions separately, which typically leads to suboptimal decisions that often result in ineffective outcomes of care. In order to overcome these inefficiencies, in this paper, we propose a novel two-stage stochastic optimization model that integrates these two decisions, which can lower costs by exploring the coupling relationship between patient scheduling and capacity configuration. The patient scheduling problem is modeled as a Markov decision process. We first analyze the properties for the multitype patient case under specific assumptions and then establish structural properties of the optimal scheduling policy for the one-type patient case. Based on these findings, we propose optimal solution algorithms to solve the joint optimization problem for this special case. Because it is intractable to solve the original two-stage problem for a general multitype system with large state space, we propose a heuristic policy and a two-stage stochastic mixed-integer programming model solved by the Benders decomposition algorithm, which is further improved by combining an approximate linear program and the look-ahead strategy. To illustrate the efficiency of our approaches and draw managerial insights, we apply our solutions to a data set from the day surgery center of a large public hospital in Shanghai, China. The results show that the joint optimization of capacity planning and patient scheduling could significantly improve the performance. Furthermore, our model can be applied to a rolling-horizon framework to optimize dynamic patient scheduling decisions. Through extensive numerical analyses, we demonstrate that our approaches yield good performances, as measured by the gap against an upper bound, and that these approaches outperform several benchmark policies. Summary of Contribution: First, this paper investigates the joint optimization problem of multiresource capacity planning and multitype patient scheduling under uncertain demands and random capacity consumption, which poses a significant computational challenge. It belongs to the scope of computing and operations research. Second, this paper formulates a mathematical model, establishes optimality properties, proposes solution algorithms, and performs extensive numerical experiments using real-world data. This work includes aspects of dynamic stochastic control, computing algorithms, and experiments. Moreover, this paper is motivated by a practical problem (joint management of capacity planning and patient scheduling in the day surgery center) in our cooperative hospital, which is also key to numerous other applications, for example, the make-to-order manufacturing systems and computing facility systems. By using the optimality properties, solution algorithms, and management insights derived in this paper, the practitioners can be equipped with a decision support tool for efficient and effective operation decisions.