This paper discusses the modeling and solution of a hierarchical supply chain problem in the pharmaceutical industry. The considered supply chain includes the levels of suppliers, production centers, and distribution, which are taken into account in the decisions of the location of capacity facilities, optimal allocation of flow, and vehicle routing at the same time. Due to the indeterminacy of the problem environment, the two-stage probabilistic programming method has been used to control the model, and the new WOGA algorithm has been used to solve the problem. The presented algorithm is a combination of the Whale Optimization Algorithm (WOA) and Genetic Algorithm (GA) algorithms, which are used to minimize the costs of the entire designed network. The results obtained from the model analysis show that WOGA has a high efficiency in solving the developed mathematical model compared to GA and WOA. There was no significant difference between the averages of the objective function and the computational time between different solution methods. Since the perishability of the drug in transportation was considered in this article, it was observed that the cost of the entire network reaches its highest level if the period of perishability is 1. Because the production and distribution centers cannot have inventory in their warehouses and must meet the demand of pharmacies in every period.