Bovine respiratory diseases (BRD) are a major concern for the beef cattle industry, as beef calves overwhelmingly develop BRD symptoms during the first weeks after their arrival at fattening units. These cases occur after weaned calves from various cow-calf producers are grouped into batches to be sold to fatteners. Cross-contaminations between calves from different origins (potentially carrying different pathogens), together with increased stress because of the process of batch creation, can increase their risks of developing BRD symptoms. This study investigated whether reducing the number of different origins per batch is a strategy to reduce the risk of BRD cases. We developed an algorithm aimed at creating batches with as few origins as possible, while respecting constraints on the number and breed of the calves. We tested this algorithm on a dataset of 137,726 weaned calves grouped into 9701 batches by a French organization. We also computed an index assessing the risks of developing BRD because of the batch composition by considering four pathogens involved in the BRD system. While increasing the heterogeneity of batches in calf bodyweight, which is not expected to strongly impact the performance, our algorithm successfully decreased the average number of origins in the same batch and their risk index. Both this algorithm and the risk index can be used as part of decision tool to assess and possibly minimize BRD risk at batch creation, but they are generic enough to assess health risk for other production animals, and optimize the homogeneity of selected characteristics.