ObjectiveTo analyze the influencing factors of moderate-to-severe (MTS) pain on the first postoperative day (POD1) in patients who underwent abdominal laparoscopic surgery and construct machine learning prediction model based on these factors, and concurrently to design a digital pain diagnosis system based on a large language model (LLM, hereinafter referred to as the “LLM system” ) that integrates structured clinical data with unstructured preoperative and intraoperative medical record texts, to realize computer-aided pain diagnosis using multi-source data. MethodsAdult patients who underwent elective abdominal laparoscopic surgery from January 2022 to December 2024 were retrospectively enrolled. MTS pain was defined as a numerical rating scale (NRS) score of ≥4 on the POD1. Based on domain expertise, univariate analysis, and collinearity diagnosis, multivariate forward stepwise logistic regression was applied to identify influencing factors of MTS pain; additionally, LASSO logistic regression incorporating all candidate variables was performed for sensitivity analysis. Subsequently, the dataset was stratified by pain outcome and surgical site, and split into training and validation sets in a 7∶3 ratio. The predictive performance of four algorithms—LASSO logistic regression, random forest, support vector machine (SVM), and XGBoost—was compared to select the optimal model. The LLM system consisted of five layers: a data input layer, a natural language processing layer, an optimal machine learning prediction layer (integrating the previously selected best algorithm), an LLM-assisted diagnosis layer, and a visualization output layer. The NRS score was categorized into four grades (0: no pain; 1–3: mild; 4–6: moderate; 7–10: severe). The Cohen Kappa coefficient was used to assess the consistency between the patients’ self-reported NRS grades (reference standard) and the four-grade pain evaluation results generated by the LLM system. ResultsA total of 748 patients were enrolled in this study, among whom 335 (44.8%) developed MTS pain on the POD1. Multivariate analysis demonstrated that female, older age, history of preoperative pain, American Society of Anesthesiologists physical status Ⅲ–Ⅳ, cholecystectomy or gastrointestinal surgery, prolonged operative duration, and an increased number of drainage tubes placed were independently associated with an elevated risk of MTS pain (all P<0.05). Perioperative administration of esketamine, flurbiprofen axetil, or dexamethasone, as well as the application of patient-controlled intravenous analgesia (PCIA), was independently associated with a reduced risk of MTS pain (all P<0.05). The area under the receiver operating characteristic curve (95%CI) of the four models, namely LASSO logistic regression, random forest, SVM, and XGBoost, were 0.793 (0.734, 0.851), 0.766 (0.705, 0.827), 0.781 (0.722, 0.840), and 0.803 (0.745, 0.860), respectively. XGBoost yielded the best performance and was integrated into the LLM system. The overall agreement rate between the four-grade pain stratification assessed by the LLM system and patients’ self-reported NRS grades on the POD1 was 87.3% (653/748), with a Cohen Kappa coefficient of 0.820. ConclusionsFemale sex, older age, cholecystectomy or gastrointestinal surgery, prolonged operative duration, and an increased number of drainage tubes placed, among others, are independent risk factors for MTS pain on the POD1 after abdominal laparoscopic surgery. Perioperative use of esketamine, flurbiprofen axetil, dexamethasone, and PCIA can reduce this risk. Among the four machine learning models, XGBoost exhibits the best discriminative ability for postoperative MTS pain. The LLM system integrating this model shows high consistency with patients’ self-reported NRS grades on the POD1, and can serve as an effective auxiliary tool for early identification and individualized management of perioperative pain.