Problem definition: Determining the optimal length of stay (LOS) and posttreatment location is critical for hematology-oncology (blood cancer) patients, who are highly vulnerable to life-threatening infections. Early discharge to home care reduces infection risk, whereas extended hospital observation minimizes mortality risks if an infection occurs. We address this trade-off by developing LOS optimization models tailored to these patients. Methodology/results: We develop a newsvendor-type model to explore how infection and mortality risks influence optimal LOS of individual patients. We further consider the social optimization problem in which capacity constraints limit the ability of hospitals to keep patients for the entirety of their optimal LOS. We find that, in the optimal solution to the fluid model used to approximate the original stochastic system, each type of patient is discharged at at most two discrete time points, one of which might be equal to zero or to the optimal uncapacitated length of stay. Based on this analysis, we propose an online index-based speedup policy (ISP) to guide patient discharge decisions. Managerial implications: Our model enables physicians to personalize LOS based on patients’ risk profiles and dynamically adapt to hospital capacity constraints. In a case study, we show that around 75% of the patients need some observation, and a speedup-only policy that discharges all patients at the same discrete time point is optimal for 90% of patient types during high demand. Adopting ISP can reduce the patient mortality rate by 27.7% compared with current practice. Supplemental Material: The online appendix is available at https://doi.org/10.1287/msom.2021.0189 .