In the study of the sustainable development of public health in China, academic circles have little to do with the unique hierarchical medical system and online appointment diagnosis system in China's medical system. Therefore, based on the medical situation in Shanghai, China, in addition to the traditional dimension of medical expenses, this paper fully considers the impact of the current hierarchical medical policy, constructs a selection model for medical treatment behavior under the hierarchical medical system and online appointment diagnosis system, and carries out simulation analysis through the cellular automata grid dynamic model. This paper finds that the time-cost-oriented medical treatment behavior of Chinese patients will have different distribution under the current hierarchical medical system and online appointment diagnosis system. (1) When the medical treatment system neither allows online appointment nor referral, a large number of patients congregated in high-grade hospitals, with the most unreasonable distribution. (2) With the implementation of the system of allowing referral and online appointment, patients are gradually diverted to lower-grade hospitals or off-peak hours, and the distribution is relatively improved.(3) If the medical treatment system allows both referral and online appointment, the distribution of patients is the most reasonable. Therefore, China's current hierarchical medical system and online appointment diagnosis system will, to a considerable extent, become a policy tool that affects patients' choice of hospitals and an effective means to achieve the rational allocation of existing medical resources, which will play an important role in the sustainable development of public health in China.