ObjectivesTo formulate an efficacious approach for safeguarding the privacy information of electronic medical records.DesignChinese patient electronic medical record text information.SettingThe Chinese Renal Disease Data System database.Participants3,233,174 patients between 1 Jan. 2010 and 31 Dec. 2023.Main outcome measuresAnnotated patient privacy fields and the effectiveness of privacy protectionResultsWe have developed an automated tool named EPSTII, designed to protect the privacy of patients’ sexually transmitted infection information within medical records. Through the refinement of keywords and the integration of expert knowledge, EPSTII currently achieves a 100% accuracy and recall rate. Our privacy protection measures have reached a 99.5% success rate, ensuring the utmost protection of STI patients’ privacy. As the first large-scale investigation into privacy leakage and STI identification in Chinese electronic medical records, our research paves the way for the future development of patient privacy protection laws in China and the advancement of more sophisticated tools.ConclusionsThe EPSTII method demonstrates a feasible and effective approach to protect privacy in electronic medical records from 19 hospitals, offering comprehensive insights for infectious disease research using Chinese electronic medical records, with protocols tailored for accurate STI data extraction and enhanced protection compared to traditional methods.