Postoperative pain scores are widely monitored and collected in the electronic health record, yet current methods fail to fully leverage the data with fast implementation. A robust linear regression was fitted to describe the association between the log-scaled pain score and time from discharge after total knee replacement. The estimated trajectories were used for a subsequent K-medians cluster analysis to categorize the longitudinal pain score patterns into distinct clusters. For each cluster, a mixture regression model estimated the association between pain score and time to discharge adjusting for confounding. The fitted regression model generated the pain trajectory pattern for given cluster. Finally, regression analyses examined the association between pain trajectories and patient outcomes. A total of 3442 surgeries were identified with a median of 22 pain scores at an academic hospital during 2009-2016. Four pain trajectory patterns were identified and one was associated with higher rates of outcomes. In conclusion, we described a novel approach with fast implementation to model patients' pain experience using electronic health records. In the era of big data science, clinical research should be learning from all available data regarding a patient's episode of care instead of focusing on the "average" patient outcomes.
Keywords: K-medians cluster analysis; electronic health records; pain scores; robust linear regression.