Background and aimChina has used traditional Chinese medicine (TCM) to treat diseases for more than 2000 years. Traditionally, TCMs in medicine cabinets are arranged alphabetically or on the basis of experience, but this arrangement greatly affects dispensing efficiency. However, owing to the unique properties and qualities of TCM, very few automatic approaches or systems have specifically addressed TCM dispensing problems. Therefore, it is necessary to establish a method of optimizing the traditional Chinese medicine placement scheme (TCMPS) via computer algorithms to improve the work efficiency of pharmacists.MethodsA prescription dataset from a hospital in 2022 was obtained, and the association rule algorithm (ARA) was used to calculate the frequency of use for each type of TCM and the associations between different types of TCMs. On the basis of these association and frequency data, the optimal TCMPS was calculated using the simulated annealing algorithm (SAA) and then verified using the prescription dataset from 2023.ResultsA total of 10,601 prescriptions were collected in 2022, involving 360 different TCMs, and each prescription contained an average of 9.485 TCMs, with Danggui (3628) being the most frequently used. When the threshold of support was set to 0.05 and the confidence was set to 0.8, 78 couplet medicines used in orthopedics clinics were found through ARA. When the threshold value of support was set to 0, the confidence was set to 0, and the rule length was 2, a total of 129,240 rules were obtained, indicating support between all pairwise TCMs. The TCMPS, calculated using SAA, had a correlation sum of 14.183 and a distance sum of 3.292. The TCMPS was verified using a prescription dataset from 2023 and theoretically improved the dispensing efficiency of pharmacists by approximately 50%.ConclusionsIn this study, the ARA and SAA were successfully applied to pharmacies for the first time, and the optimal TCMPS was calculated. This approach not only significantly improves the dispensing efficiency of pharmacists and reduces patient waiting time but also enhances the quality of medical services and patient satisfaction, and provides a valuable reference for the development of smart medicine.