Abstract
Objective.
The aim of this study was to investigate and compare different case definitions for chronic pain to provide estimates of possible misclassification when researchers are limited by available EHR and administrative claims data, allowing for greater precision in case definitions.
Methods.
We compared the prevalences of different case definitions for chronic pain (n=3,042) in patients with autoimmune rheumatic diseases. We estimated the prevalence of chronic pain based on 15 unique combinations of pain scores, diagnostic codes, analgesic medications and pain interventions.
Results.
Chronic pain prevalence was lowest in unimodal pain phenotyping algorithms: 15% using analgesic medications, 18% using pain scores, 21% using pain diagnostic codes and 22% using pain interventions. In comparison, the prevalence using a well-validated phenotyping algorithm was 37%. The prevalences of chronic pain also increased with increasing number (bimodal to quadrimodal) of phenotyping algorithms that comprised the multimodal phenotyping algorithms. The highest estimated chronic pain prevalence (47%) was the multimodal phenotyping algorithm that combined pain scores, diagnostic codes, analgesic medications and pain interventions. However, this quadrimodal phenotyping algorithm yielded a 10% over-estimation of chronic pain compared to the well-validated algorithm.
Conclusion.
This is the first empirical study to show that established common modes of phenotyping chronic pain can lead to substantially varying estimates of number of patients with chronic pain. These findings can be a reference for biases in case definitions for chronic pain and could be used to estimate the extent of possible misclassifications or corrections in using datasets that cannot include specific data elements.
Introduction
Up to 7% of adults in the United States live with autoimmune rheumatic diseases (ARDs), including systemic lupus erythematosus, Sjögren’s syndrome, systemic sclerosis, ankylosing spondylitis, and psoriatic arthritis.1 Autoimmune rheumatic diseases are heterogeneous conditions disproportionately affecting women and are hypothesized to be caused by a dysregulated immune system triggering organ dysfunction and damage.1 The American College of Rheumatology noted pain as the most salient patient-reported outcome in autoimmune rheumatic diseases because it significantly impacts health-related quality of life and disability.2 Despite treatment advances in rheumatology, including the advent of highly specific biologics and disease-modifying antirheumatic drugs, pain remains an undertreated problem.3 Depending on the ARD diagnosis, upwards of 65% of patients with ARDs are on long-term opioid therapies and have higher rates of opioid overdose hospitalizations than the general population. 4
We need to understand the burden of chronic pain in autoimmune rheumatic diseases. People with rheumatologic conditions experience moderate to severe pain associated with the condition itself, are likely to have medical comorbidities, and are likely to experience co-occurring chronic pain from non-rheumatologic conditions (e.g., migraine or irritable bowel disease). Specifically, reliable and detailed estimates of the full burden of chronic pain in ARDs are needed to establish a basis for population-wide interventions and estimate trends. Electronic health records (EHRs) offer great potential to reduce the need for data gathering and thereby promote efficient calculation of estimates of disease burden. While EHRs are a rich data resource, accurate case definitions and algorithms are needed to ensure precision in estimating the burden of chronic pain. Accordingly, computational phenotyping is a clinical data science method that leverages data-driven methods to subtype and characterize patient conditions from heterogeneous EHR data,5 and yield phenotyping algorithms that could be applied across datasets. Indeed, the potential uses of the chronic pain phenotyping algorithm include: estimating incidence, prevalence, and trends in administrative databases/EHR; providing baseline measures to characterize pain trajectories in administrative databases; understanding the epidemiology of other chronic overlapping pain conditions; facilitating cost modeling and health utilization projections; and characterizing treatment response and effectiveness.
Variability in case definitions can create error in estimations and inferences6 by affecting the number and type of cases identified. As such, accuracy and consistency in case definitions are crucial as downstream applications of results potentially impact direct patient care, research, and health policy. Chronic pain is often considered a subjective symptom and can be clinically complex. The lack of objective tests, biomarkers and diagnostic criteria may complicate the use of EHR data for epidemiological inference. In 2012, Tian et al published a well-cited general chronic pain algorithm that applied three unimodal criteria from structured EHR data: pain scores, diagnosis codes, and prescription opioids.7,8 However, several limitations call into question the utility of this algorithm in rheumatology, including that: (1) trends in the diagnosis and management of chronic pain have evolved since the 2011–2012 study period; (2) it was developed using data from primary care thereby limiting its generalizability in the rheumatic specialty care context; (3) it was not externally validated outside of the derivation dataset; and (4) it included opioid medications only and omitted other prescription analgesics.
To create greater precision in case definitions for chronic pain in EHR, the aims of this study are to: (1) describe the extraction and prevalence of four unimodal pain criteria in EHR using pain scores, diagnostic codes associated with chronic pain, analgesic medications, and pain interventions; (2) detail the correlation between the unimodal pain criteria; (3) determine the prevalence of distinct combinations of the pain criteria into algorithmic phenotyping and compare them to the Tian et al algorithms; and (4) quantify the strength of association between several variables (as exposures) and chronic pain (as outcomes) using different case definitions based on multimodal phenotyping algorithms. We also examined sex differences for each of the four study aims. We expect our comparison of several different chronic pain phenotyping algorithms will yield useful information for future researchers depending on their data availability and research questions. The next step in this line of research will be to conduct validation of these algorithms to estimate their accuracy.
Methods
The Institutional Review Board at the Stanford School of Medicine approved this study (IRB# 53750). Stanford Health Care has ~1 million outpatient visits per year and uses EPIC as its EHR vendor. EHR data fields available for analysis include demographics, diagnostic codes, problem list, medications, laboratory studies, procedures, and clinical encounter notes. EHR records are accessed via a backend relational database (STAnford Research Repository, or STARR) that can be queried. We retrospectively queried STARR to identify patients ages ≥18 years visiting any Stanford outpatient rheumatology clinic (including joint immunology-dermatology clinics) in 2019. Further, we identified patients with ≥2 visits with ARD diagnoses ≥3 months apart using the International Classification of Diseases, Clinical Modification (ICD-10-CM) codes (Supplementary Table 1) for the following ARDs: ankylosing spondylitis, psoriatic arthritis, Sjogren’s syndrome, systemic lupus erythematosus, and systemic sclerosis. We chose to include at least 2 ARD diagnoses of the same ARD to ensure that these patients were being actively managed for each condition.
Pain scores.
Current pain intensity scores are recorded at clinic visits using the 11-point numeric pain rating scale (i.e., 0 = no pain; 10 = worst pain imaginable). The pain score is recorded as structured data in the EHR. Patients who had two or more pain scores rated as ≥4 point at least three months apart (Figure 1) were categorized as having met the unimodal chronic pain criterion.7
Figure 1. showing how unimodal chronic pain phenotypes were constructed from electronic health records.

We identified patients with chronic pain using four unimodal pain phenotyping algorithms: pain scores, dx codes, medications and interventions. First, we labelled patients as having chronic pain using the pain scores phenotype if they were recorded as having two or more high pain scores (≥4 points) at least three months apart based on the Visual Analogue Scale. Secondly, we labelled patients as having chronic pain using the diagnosis codes phenotype if they had ≥2 ICD codes for pain recorded at visits separated by ≥3 months. Codes for diagnosis such as migraine, chest pain, joint pain were extracted. Thirdly, we labelled patients as having chronic pain using the pain medications phenotype if they had ≥2 prescriptions of the pain medications recorded at visits separated by ≥3 months. Prescriptions included opioids, NSAIDS, and muscle relaxants. We labelled patients as having chronic pain using the pain interventions phenotype if they had relevant pain procedures such physical therapy/occupational therapy/acupuncture.
Pain diagnostic codes.
We defined a list of ICD-10 codes for general and non-rheumatic chronic pain conditions through an extensive literature review and expert input (Supplementary Table 1, Figure 1). We extracted ICD-10 codes for the following painful conditions: abdominal pain, chest pain, pain in joints, pain in limbs, cervicalgia, fibromyalgia, irritable bowel syndrome, urologic chronic pelvic pain syndrome, vulvodynia, migraine, chronic tension-type headache, temporomandibular disorder, chronic low back pain, myalgic encephalomyelitis /chronic fatigue syndrome, and endometriosis. We labelled patients with chronic pain using the diagnosis codes phenotyping algorithm if they had ≥2 ICD codes in Supplementary Table 1 recorded at visits separated by ≥3 months.
Pain medications.
We extracted pain-related prescriptions: opioids, non-steroidal anti-inflammatory drugs (NSAIDs), acetaminophen, anticonvulsants, antidepressants, and muscle relaxants using previously described definitions.9 We categorized patients as having chronic pain if they met the analgesic prescription criterion of 2+ prescriptions of any of the pain medications listed in this section recorded at visits separated by ≥3 months (Supplementary Table 2, Figure 1).
Pain interventions.
We identified patients with the most common Current Procedural Terminology (CPT®) codes used in interventional pain management based on conversations with rheumatologists and pain clinicians (Figure 1, Supplementary Table 3). These codes include, but are not limited to physical therapy, acupuncture, and nerve blocks. We labelled patients as having chronic pain using the pain interventions phenotyping algorithm if they had any of the procedures in Supplementary Table 3.
Data analysis.
We examined the baseline distribution of patients with each of the five rheumatic conditions by sociodemographic (sex, race, ethnicity, age at baseline, marital status, and insurance status) and lifestyle (smoking status and body mass index) variables. We estimated the prevalence of each of the four unimodal phenotyping algorithms in patients with rheumatic diseases. We also determined the sociodemographic and lifestyle variables associated with the presence of each unimodal phenotyping algorithm. We reported the associations between the unimodal phenotyping algorithms using tetrachoric correlation coefficients, a measure of association between the binary variables. Tetrachoric correlation coefficients can range from −1 (indicating strong negative correlation between two unimodal phenotypes) to 1 (indicating a strong positive correlation between two unimodal phenotypes) 10–12. A value of 0 indicates no correlation between two unimodal phenotypes. We also evaluated the prevalence of eleven combinations of the unimodal phenotyping algorithms and examined the extent of the over- or under-estimation of chronic pain prevalence compared to the Tian et al chronic pain algorithm7,8. Finally, we quantified the strength of association between sex, race and disease status with chronic pain using different case definitions based on the multimodal pain phenotyping algorithms by estimating odds ratios.
Results
The number of patients attending rheumatology clinics in 2019 ranged from 242 diagnosed with ankylosing spondylitis to 842 diagnosed with Sjogren’s syndrome (Table 1). There was a preponderance of female patients (55%–93%) in all conditions, except for ankylosing spondylitis. The proportion of non-White patients ranged from 50% in systemic lupus to 29% in psoriatic arthritis and Hispanics comprised 19% of patients with systemic lupus and 8% of patients with ankylosing spondylitis. The average age at the first visit ranged from 42 years in systemic lupus to 56 years in Sjogren’s syndrome. The proportion of publicly/privately insured did not vary considerably by disease status: overall, 93%.
Table 1.
Distribution of patients attending a rheumatology clinic at an academic medical center, 2019 (presented as n(%) unless otherwise specified)
| Ankylosing spondylitis (n=242) | Psoriatic arthritis (n=728) | Sjogrens syndrome (n=842) | Systemic lupus erythematosus (n=803) | Systemic sclerosis (n=427) | All (N=3,042) | |
|---|---|---|---|---|---|---|
| Sex | ||||||
| Female | 88 (36.4) | 398 (54.7) | 782 (92.9) | 732 (91.2) | 377 (88.3) | 2,377 (78.1) |
| Male | 154 (63.6) | 330 (45.3) | 60 (7.1) | 71 (8.8) | 50 (11.7) | 665 (21.9) |
| Race | ||||||
| Asian/PI | 64 (26.5) | 95 (13.1) | 177 (21.0) | 212 (26.4) | 75 (17.6) | 623 (20.5) |
| Black | 3 (1.2) | 6 (0.8) | 17 (2.0) | 41 (5.1) | 16 (3.8) | 83 (2.7) |
| Other | 31 (12.8) | 110 (15.1) | 118 (14.0) | 149 (18.6) | 89 (20.8) | 497 (16.3) |
| White | 144 (59.5) | 517 (71.0) | 530 (63.0) | 401 (49.9) | 247 (57.9) | 1,839 (60.5) |
| Ethnicity | ||||||
| Hispanic | 19 (7.9) | 68 (9.3) | 88 (10.5) | 150 (18.7) | 63 (14.8) | 388 (12.8) |
| Non-Hispanic | 207 (85.5) | 607 (83.4) | 697 (82.8) | 614 (76.5) | 353 (82.7) | 2,478 (81.5) |
| Unknown | 16 (6.6) | 53 (7.3) | 57 (6.8) | 39 (4.9) | 11 (2.6) | 3,042 (5.8) |
| Age, mean (SD) | 44.5 (17.9) | 52.6 (15.9) | 56.1 (14.8) | 41.7 (19.8) | 54.0 (15.2) | 50.2 (17.8) |
| Insurance | ||||||
| Unknown | 21 (8.7) | 49 (6.7) | 66 (7.8) | 58 (7.2) | 33 (7.7) | 227 (7.5) |
| Private | 155 (64.1) | 404 (55.5) | 417 (49.5) | 462 (57.5) | 189 (44.3) | 1,627 (53.5) |
| Public | 66 (27.3) | 275 (37.8) | 359 (42.6) | 283 (35.2) | 205 (48.0) | 1,188 (39.1) |
| Marital status | ||||||
| Divorced/Separated | 9 (3.7) | 35 (4.8) | 60 (7.1) | 38 (4.7) | 33 (7.7) | 175 (5.8) |
| Married/Life Partner | 152 (62.8) | 486 (66.8) | 593 (70.4) | 433 (53.9) | 284 (66.5) | 1,948 (64.0) |
| Other | 0 | 8 (1.1) | 3 (0.4) | 8 (1.0) | 7 (1.6) | 26 (0.9) |
| Single | 74 (30.6) | 173 (23.8) | 134 (15.9) | 289 (36.0) | 786 (20.1) | 756 (24.9) |
| Widowed | 7 (2.9) | 26 (3.6) | 52 (6.2) | 35 (4.4) | 17 (4.0) | 137 (4.5) |
| BMI, mean (SD) | 25.8 (7.1) | 28.8 (7.2) | 26.1 (6.1) | 23.9 (9.9) | 24.5 (5.3) | 26.9 (7.7) |
| Smoking | ||||||
| Current | 10 (4.1) | 33 (4.5) | 12 (1.4) | 11 (1.4) | 3 (0.7) | 69 (2.3) |
| Former | 51 (21.1) | 183 (25.1) | 195 (23.2) | 141 (17.6) | 117 (27.4) | 687 (22.6) |
| Never | 179 (74.0) | 510 (70.1) | 633 (75.2) | 640 (79.7) | 306 (72.0) | 2,268 (74.6) |
| Unknown | 2 (0.8) | 2 (0.3) | 2 (0.2) | 11 (1.4) | 1 (0.2) | 18 (0.6) |
Approximately 18% of patients attending the rheumatology clinics met the criteria for chronic pain using pain scores based on having two or more pain scores (≥4 points out of 10) at least three months apart. Pain scores were available for >95% of patient records. The prevalence of the pain score phenotyping algorithm varied considerably by sex: 20% in females and 12% in males. Females had a higher prevalence of each unimodal pain phenotyping algorithm (Figure 2). The prevalence of pain ICD phenotyping algorithm (i.e., having two or more pain ICD codes at least three months apart) was higher in females (23% compared to 15% in males). However, the prevalence of the pain prescriptions phenotyping algorithm (i.e., having two or more pain medications at least three months apart) was slightly higher in females (16% compared to 13% in males). Similarly, the prevalence of the pain interventions phenotyping algorithm was slightly higher in females compared to males (23% versus 19%).
Figure 2. Prevalence (and 95% confidence intervals) of unimodal pain phenotypes among patients with rheumatic diseases managed at an academic medical center stratified by sex, 2019^*.

^Pain scores that are ≥4 on the visual analog scale. *Codes are three or more months apart
Female patients had higher prevalence of each unimodal pain phenotype. The prevalence of the pain score phenotype varied by sex: 20% in females and 12% in males. The prevalence of pain dx code phenotype was higher in females (23% compared to 15% in males). However, the prevalence of the pain prescriptions phenotype was only slightly higher in females (16% compared to 13% in males). Similarly, the prevalence of the pain interventions phenotype was slightly higher in females compared to males (23% versus 19%).
There was also considerable variability in the prevalence of each unimodal pain phenotyping algorithm by rheumatologic disease (Figure 3). The prevalence of the pain score phenotyping algorithm was highest among patients with systemic lupus erythematosus (22%) and Sjogren’s syndrome (19%). The prevalence of the ICD code pain phenotyping algorithm was highest among patients with Sjogren’s syndrome (~24%). The prevalence of the pain prescriptions phenotyping algorithm was similarly highest among patients with Sjogren’s syndrome and lowest among patients with systemic sclerosis. However, 17% of patients with ankylosing spondylitis had pain interventions compared with 26% of patients with systemic sclerosis.
Figure 3. Prevalence (and 95% confidence intervals) of unimodal pain phenotypes among patients with rheumatic diseases managed at an academic medical center, 2019, by disease statu^*.

^Pain scores that are ≥4 on the visual analog scale. *Codes are three or more months apart
There was also considerable variability in the prevalence of each unimodal pain phenotype by rheumatologic disease. The prevalence of the pain score phenotype was highest among patients with lupus (22%) and lowest in AS (12%). When using the ICD codes or prescription phenotype, prevalence of chronic pain was highest among patients with Sjögren syndrome and lowest among patients with systemic sclerosis. However, 17% of patients with ankylosing spondylitis had pain interventions compared with 26% of patients with systemic sclerosis.
The correlation coefficients between the unimodal pain phenotyping algorithms were generally low to medium in strength (Supplementary Table 4). The lowest correlation was between pain ICD codes and pain interventions (~0.23), while the highest correlation was between pain scores and pain ICD codes (~0.46). There were also differences in the correlations by sex, with males tending to have lower correlation coefficients. However, male patients had the highest correlation between pain scores and analgesic prescriptions (0.50) and almost no correlation between analgesic prescriptions and pain interventions.
Table 2 shows the prevalence of chronic pain based on bimodal (combination of two phenotyping algorithms), trimodal (combination of three phenotyping algorithms), and quadrimodal phenotyping algorithms (combination of four phenotyping algorithms). Among the eleven possible combinations of the unimodal pain phenotyping algorithms, the highest estimated prevalence of chronic pain was the combination of all four unimodal algorithms into a multimodal phenotyping algorithm, #11 (47%). The lowest estimated prevalence of chronic pain was the combination comprised of two unimodal phenotyping algorithms (pain scores and pain prescriptions), #2 (28%). The Tian et al chronic pain algorithm combined pain scores, ICD codes and prescription and the prevalence of chronic pain based on this algorithm (#7) was 37%. Using the Tian et al algorithm, the prevalence of chronic pain was slightly higher among females (39% compared to 29%). The prevalence of chronic pain was also highest among black patients (~42%) compared with Asian patients (27%). The prevalence of chronic pain was also highest among the publicly insured across multiple combinations. The prevalence of chronic pain using these multimodal definitions was again highest in patients with Sjogren’s syndrome and lowest in systemic sclerosis.
Table 2.
Prevalence of chronic pain according to different combinations of unimodal pain phenotypes, 2019
| Pain scores + ICD codes | Pain scores + Prescriptions | Pain scores + Interventions | ICD codes + Prescriptions | ICD codes + Interventions | Prescriptions + Interventions | Pain scores + ICD codes + Prescriptions | Pain scores + ICD codes + Interventions | Pain scores + Prescriptions + Interventions | ICD codes + Prescriptions + Interventions | Pain scores + ICD codes + Prescriptions + Interventions | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | |
| All (n=3,042) | 930 (30.57) | 835 (27.45) | 1027 (33.76) | 899 (29.55) | 1,102 (36.23) | 971 (31.92) | 1,115 (36.65) | 1,296 (42.6) | 1,226 (40.3) | 1,274 (41.88) | 1,429 (46.98) |
| Sex | |||||||||||
| Female (n=2,377) | 780 (32.81) | 701 (29.49) | 850 (35.76) | 741 (31.17) | 900 (37.86) | 778 (32.73) | 925 (38.91) | 1062 (44.68) | 1001 (42.11) | 1025 (43.12) | 1158 (48.72) |
| Male (n=665) | 150 (22.56) | 134 (20.15) | 177 (26.62) | 158 (23.76) | 202 (30.38) | 193 (29.02) | 190 (28.57) | 234 (35.19) | 225 (33.83) | 249 (37.44) | 271 (40.75) |
| Race | |||||||||||
| Asian/PI (n=957) | 141 (22.63) | 111 (17.82) | 164 (26.32) | 137 (21.99) | 181 (29.05) | 153 (24.56) | 170 (27.29) | 209 (33.55) | 190 (30.5) | 202 (32.42) | 228 (36.6) |
| Black (n=83) | 30 (36.14) | 30 (36.14) | 35 (42.17) | 27 (32.53) | 35 (42.17) | 30 (36.14) | 35 (42.17) | 41 (49.4) | 41 (49.4) | 38 (45.78) | 44 (53.01) |
| Other (n=497) | 157 (31.59) | 139 (27.97) | 173 (34.81) | 145 (29.18) | 181 (36.42) | 153 (30.78) | 179 (36.02) | 212 (42.66) | 199 (40.04) | 204 (41.05) | 228 (45.88) |
| White (n=1,839) | 602 (32.74) | 555 (30.18) | 655 (35.62) | 590 (32.08) | 705 (38.34) | 635 (34.53) | 731 (39.75) | 834 (45.35) | 796 (43.28) | 830 (45.13) | 929 (50.52) |
| Ethnicity | |||||||||||
| Hispanic (n=388) | 121 (31.19) | 112 (28.87) | 140 (36.08) | 104 (26.8) | 134 (34.54) | 117 (30.15) | 138 (35.57) | 168 (43.3) | 156 (40.21) | 152 (39.18) | 179 (46.13) |
| Non-Hispanic (n=2,478) | 748 (30.19) | 659 (26.59) | 828 (33.41) | 736 (29.7) | 911 (36.76) | 803 (32.41) | 901 (36.36) | 1056 (42.62) | 996 (40.19) | 1050 (42.37) | 1166 (47.05) |
| Unknown (n=176) | 61 (34.66) | 64 (36.36) | 59 (33.52) | 59 (33.52) | 57 (32.39) | 51 (28.98) | 76 (43.18) | 72 (40.91) | 74 (42.05) | 72 (40.91) | 84 (47.73) |
| Insurance | |||||||||||
| Unknown (n=227) | 72 (31.72) | 62 (27.31) | 79 (34.8) | 65 (28.63) | 79 (34.8) | 71 (31.28) | 85 (37.44) | 99 (43.61) | 94 (41.41) | 93 (40.97) | 109 (48.02) |
| Private (n=1,627) | 445 (27.35) | 381 (23.42) | 467 (28.7) | 446 (27.41) | 530 (32.58) | 449 (27.6) | 537 (33.01) | 616 (37.86) | 569 (34.97) | 615 (37.8) | 686 (42.16) |
| Public (n=1,188) | 413 (34.76) | 392 (33) | 481 (40.49) | 388 (32.66) | 493 (41.5) | 451 (37.96) | 493 (41.5) | 581 (48.91) | 563 (47.39) | 566 (47.64) | 634 (53.37) |
| Disease status | |||||||||||
| AS (n=242) | 61 (25.2) | 54 (22.3) | 59 (24.4) | 71 (29.3) | 78 (32.2) | 70 (28.9) | 78 (32.2) | 86 (35.5) | 81 (33.5) | 95 (39.3) | 102 (42.2) |
| PSA (n=728) | 227 (31.2) | 193 (26.5) | 254 (34.9) | 222 (30.5) | 281 (38.6) | 254 (34.9) | 270 (37.1) | 333 (45.7) | 313 (43.0) | 337 (46.3) | 372 (51.1) |
| SjS (n=842) | 289 (34.3) | 262 (31.1) | 310 (36.8) | 293 (34.8) | 338 (40.1) | 302 (35.9) | 356 (42.3) | 392 (46.6) | 371 (44.1) | 393 (46.7) | 434 (51.5) |
| SLE (n=803) | 235 (31.5) | 229 (28.5) | 261 (32.5) | 212 (26.4) | 258 (32.1) | 204 (25.4) | 284 (35.4) | 319 (39.7) | 296 (36.9) | 282 (35.1) | 338 (42.1) |
| SSc (n=427) | 100 (23.4) | 97 (22.7) | 143 (33.5) | 101 (23.6) | 147 (34.4) | 141 (33.0) | 127 (29.7) | 166 (38.9) | 165 (38.6) | 167 (39.1) | 183 (42.9) |
When estimating the extent of the over-estimation or under-estimation of chronic pain by the multimodal pain phenotyping algorithms compared with the Tian et al algorithm, we found substantial variation overall and within key population subgroups (Figure 4). The combination that was closest in prevalence to the Tian et al algorithm was ICD codes and pain interventions (overall difference was −0.4%), with the differences in estimates of chronic pain varying from −11% to +5% in various subgroups. The combination that was furthest in prevalence to the Tian et al algorithm was pain scores, ICD codes, prescriptions, and interventions (overall difference was +10%), with over-estimation as high as 13% in subgroups.
Figure 4. Showing the extent of the over-estimation or under-estimation of chronic pain by various combinations of unimodal pain phenotypes.
AS: Ankylosing Spondylitis. PsA: Psoriatic Arthritis. SjS: Sjögren syndrome. SLE: Systemic Lupus Erythematosus. SSc: Systemic Sclerosis.
There are 15 different ways to measure chronic pain. The four unimodal phenotypes are in Figure 2a. This figure shows the prevalence of chronic pain based on evelen multimodal phenotypes. Numbers 1–6 are bimodal phenotypes – combinations of 2 unimodal phenotypes. Prevalence range from 28% (combining pain scores and prescription) to 36% (combining diagnosis codes and interventions). Numbers 7–10 are trimodal phenotypes. The Tian phenotype that combines pain scores, dx and prescriptions is #7. The estimated prevalence based on this phenotype is 37%. The highest estimated prevalence of chronic pain was the quadrimodal phenotype that combines all four unimodal phenotypes, #11 (47%).
We quantified the strength of association between sex, race and disease status, and chronic pain using different case definitions according to the multimodal pain phenotyping algorithms (Supplementary Figures 1 and 2). When estimating odds ratios comparing females to males, we found that female patients had >50% higher odds of chronic pain using the Tian et al algorithm (highlighted in red).7 While this point estimate varied by the multimodal pain phenotyping algorithm, the confidence intervals overlapped for the eleven multimodal phenotyping algorithms. Similarly, across multiple case definitions, Asian patients had 50% lower odds of chronic pain compared with white patients based on the Tian et al pain algorithm; this point estimate did not vary considerably using other case definitions. However, there were more variations in point estimates by disease status, although most confidence intervals overlapped considerably.
Discussion
This study used records from ~3,000 patients seen at rheumatology clinics to create unimodal and multimodal chronic pain phenotyping algorithms. The aim was to investigate and compare different case definitions for chronic pain for use to provide estimates of possible misclassification when researchers are limited by available EHR data. We did not determine the accuracy of each pain phenotyping algorithm – this is the subject of future research. As expected, the prevalences of chronic pain using unimodal phenotyping algorithms were lower than those using multimodal pain phenotyping algorithms. The prevalences of chronic pain also increased with increasing number (bimodal to quadrimodal) of phenotyping algorithms that comprised the multimodal phenotyping algorithms. We applied the 2012 Tian et al multimodal phenotyping algorithm that combines pain scores, ICD codes and prescription to our current data to yield a chronic pain prevalence estimate of 37%, which exceeded the 19% chronic pain prevalence estimate that the algorithm authors reported in their 2012 study.7 Moreover, we improved on the Tian et al general chronic pain phenotyping algorithm by better aligning with rheumatology clinics and patients in the following ways. First, the Tian study setting was in a multisite community center whereas we used academic rheumatology clinics in Northern California and a patient population with significant burden of chronic pain. Second, the Tian et al phenotyping algorithm restricted their examination of analgesic medications to opioids only. In contrast, we added other analgesic medications that better align with contemporary changes in the management of chronic pain, and are commonly prescribed for inflammatory pain conditions. When we limited our case definition to opioids only the prevalence of chronic pain was ~31%.
The Tian et al multimodal phenotyping algorithm showed good to excellent accuracy during derivation and validation. The positive predictive value of the Tian et al multimodal phenotyping algorithm was 98% in the derivation dataset and 91% upon validation, the sensitivity was 85% and the specificity was 98%.7 These accuracy metrics were superior to those of unimodal phenotyping algorithms (pain scores, opioids, and ICD codes). The Tian et al multimodal phenotyping algorithm (or variations of it) has been adapted for myriad purposes including: characterizing the demographics of chronic pain patients in the state of Maine,8 estimating the costs and gender differences in the use of complementary and integrative health intervention for chronic pain in veterans,13,14 predicting pain intensity improvements,15 and evaluating the burden of neuropathic pain in Canada.16
The choice of which unimodal or multimodal pain phenotyping algorithm to use depends on the availability of the data elements in EHR, claims or registry data and the research question or hypothesis. For example, most administrative claims databases such as Truven Health (IBM) MarketScan, Optum Insight, Medicare, and Medicaid may only have ICD codes, medications, and interventions, but may not have pain scores. However, a trimodal phenotyping algorithm with that combination would yield a chronic pain estimate that is 5% higher than the one estimated by the Tian et al phenotyping algorithm. An alternative would be the bimodal phenotyping algorithm that combines ICD codes and interventions where the chronic pain estimate was only 0.4% less than the Tian et al phenotyping algorithm. One caveat to bear in mind: one cannot study the effects of elements that comprise a particular phenotyping algorithm. If a chronic pain phenotyping algorithm includes prescriptions, researchers cannot study the effect or trends of prescriptions using that phenotyping algorithm. One study that adapted the Tian et al algorithm for estimating the cost of complementary and integrative health approaches for chronic musculoskeletal pain in younger US Veterans did not include the use of medications in the case definition for pain because they were evaluating the use of pain interventions.13 Researchers in that study elected to use ICD codes and pain scores, a phenotyping algorithm that yielded a 6% underestimate of chronic pain prevalence in the present study.13 This phenotyping algorithm has been shown to have a predictive value of 82%.7 In another study, improvements in pain intensity were evaluated and the chronic pain definition used only ICD codes.15 In this study, the unimodal phenotyping algorithm consisting of ICD codes yielded a chronic pain prevalence of 21%, a potential 18% underestimate. This phenotyping algorithm has been shown to have a predictive value of 89–95%, but the sensitivity ranged between 20–71%.7
As expected, the prevalence of chronic pain was higher among female patients in each case definition. Female patients had a higher prevalence of high pain scores and pain ICD codes. A female preponderance in the burden and intensity of chronic pain is well documented in the literature.17,18 For example, several studies have reported higher prevalence of temporomandibular disorders, neuropathic pain in diabetes, and postoperative pain in female patients.19–22 In a study of 72,000 patients using the EHR from Stanford Hospital and Clinics, Ruau et al found that, on average, women reported higher pain scores in 72% of diagnoses, including rheumatoid arthritis, osteoarthritis and diabetes.23 Other studies have also shown the higher use of pain medications in females compared to males, including opioid use and complementary/integrative health.24–26 To our knowledge, this study is the first to highlight sex differences across four chronic pain phenotyping algorithms. Consistent with previous research, we found higher prescriptions of pain medications and intervention in females than males, but these differences were not significant.
This study has a few limitations. We did not include patients with rheumatoid arthritis (RA) in this study because patients with this condition are selectively given the RAPID3 questionnaire at every visit in our clinics, which includes the visual analog pain scale (VAS). Thus, the inclusion of patients with RA have an artificially higher prevalence of pain relative to the other groups because of the systematic collection of VAS pain in RA (Supplementary Figure 3). We included only medications that are prescribed nationally to ensure generalizability, thus excluding pain treatment modalities such as cannabis. We were unable to capture social determinants of health such as educational attainment, income, and employment status – factors known to impact chronic pain and disability. We also did not include comorbidities such as diabetes, heart disease, and mood disorders. We did not include information on healthcare utilization metrics such as emergency department visits and surgeries. There are numerous other lifestyle factors that could potentially influence pain levels and the accuracy of pain classifications, including diet, physical activity, alcohol consumption, and sleep quality. However, we were only able to extract smoking status and BMI from the EHR system. We also did not include information on the prescribers of the pain medications and did not include status of specific conditions such as duration of disease, severity, and rheumatologic medications such as disease-modifying antirheumatic drugs.
We found that effect estimates of associations between key demographic variables and chronic pain based on the different case definitions did not vary considerably. It is impossible to tell which directions the effect sizes will go during multivariable regression modeling. In addition, these findings may not generalize beyond rheumatology clinics and these clinics’ geographical/sociodemographic contexts. However, chronic pain remains the most salient source of disability in rheumatology and the sociodemographic composition of the study participants is racially diverse (~40% non-white). We expect this phenomenon is true in other contexts, however, future studies should include validation of these findings in other specialties. We speculate that error would be on the side of underestimating. In addition, misclassification bias in case ascertainment may have profound implications for estimation of disease burden, thus, impacting risk estimations, patient care, cost estimations, and health policy decisions. However, perfect case definitions do not exist and there needs to be careful consideration of the costs of over- or under-estimation of chronic pain cases, e.g., over-screening and missed cases. We did not estimate the accuracy of the case definitions in ascertaining chronic pain. This is the subject of a future study. In addition, the current study gives a general overview of the prevalence of chronic pain in patients with ARD, however, it does not address the nuances of the pain experience in individual patients, which are influenced by disease status, but also, contextual determinants. This study is foundational as an early exploration of the epidemiological use of EHR, with need for future refinement.
In conclusion, this was the first empirical study to show that established common modes of phenotyping chronic pain can lead to substantially varying estimates of number of patients with chronic pain. As a consequence, we created a reference for biases in case definitions for chronic pain in EHR. These findings could be used to estimate the extent of possible misclassifications or corrections in using datasets that cannot include specific data elements.
Acknowledgements
Dr. Sean Mackey (K24-NS-126781 and R61-NS-11865), Dr. Titilola Falasinnu (T32-DA-035165), and Dr. Beth Darnall (K24-DA-053564) received funding from the NIH National Institute on Drug Abuse. Dr. Sean Mackey also acknowledges support from the Redlich Pain Research Endowment. Dr. Titilola Falasinnu (K01-AR-079039) received funding from the NIH National Institute of Arthritis and Musculoskeletal and Skin Diseases. The authors report no conflicts of interest.
The data that support the findings of this study are available on reasonable request from the corresponding author, TF. The data are not publicly available due to their containing information that could compromise the privacy of patient populations.
References
- 1.Marder W, Vinet É, Somers EC. Rheumatic autoimmune diseases in women and midlife health. Womens Midlife Health 2015;1. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 2.American College of Rheumatology Pain Management Task F. Report of the American College of Rheumatology Pain Management Task Force. Arthritis Care Res (Hoboken) 2010;62:590–9. [DOI] [PubMed] [Google Scholar]
- 3.Birt JA, Wu J, Griffing K, et al. Corticosteroid dosing and opioid use are high in patients with SLE and remain elevated after belimumab initiation: a retrospective claims database analysis. Lupus Sci Med 2020;7. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.Anastasiou C, Yazdany J. Review of publications evaluating opioid use in patients with inflammatory rheumatic disease. Curr Opin Rheumatol 2022;34:95–102. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Pathak J, Kho AN, Denny JC. Electronic health records-driven phenotyping: challenges, recent advances, and perspectives. J Am Med Inform Assoc 2013;20:e206–11. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Arkema EV, Jönsen A, Rönnblom L, Svenungsson E, Sjöwall C, Simard JF. Case definitions in Swedish register data to identify systemic lupus erythematosus. BMJ Open 2016;6:e007769. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7.Tian TY, Zlateva I, Anderson DR. Using electronic health records data to identify patients with chronic pain in a primary care setting. J Am Med Inform Assoc 2013;20:e275–80. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Malon J, Shah P, Koh WY, Cattabriga G, Li E, Cao L. Characterizing the demographics of chronic pain patients in the state of Maine using the Maine all payer claims database. BMC Public Health 2018;18:810. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.Frank JW, Carey E, Nolan C, et al. Increased Nonopioid Chronic Pain Treatment in the Veterans Health Administration, 2010–2016. Pain Med 2019;20:869–77. [DOI] [PubMed] [Google Scholar]
- 10.Clemens JQ, Elliott MN, Suttorp M, Berry SH. Temporal ordering of interstitial cystitis/bladder pain syndrome and non-bladder conditions. Urology 2012;80:1227–31. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Kato K, Sullivan PF, Evengård B, Pedersen NL. Importance of genetic influences on chronic widespread pain. Arthritis Rheum 2006;54:1682–6. [DOI] [PubMed] [Google Scholar]
- 12.Lee M, Whitsel E, Avery C, et al. Variation in Population Attributable Fraction of Dementia Associated With Potentially Modifiable Risk Factors by Race and Ethnicity in the US. JAMA Netw Open 2022;5:e2219672. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 13.Herman PM, Yuan AH, Cefalu MS, et al. The use of complementary and integrative health approaches for chronic musculoskeletal pain in younger US Veterans: An economic evaluation. PLoS One 2019;14:e0217831. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14.Taylor SL, Herman PM, Marshall NJ, et al. Use of Complementary and Integrated Health: A Retrospective Analysis of U.S. Veterans with Chronic Musculoskeletal Pain Nationally. J Altern Complement Med 2019;25:32–9. [DOI] [PubMed] [Google Scholar]
- 15.Dobscha SK, Lovejoy TI, Morasco BJ, et al. Predictors of Improvements in Pain Intensity in a National Cohort of Older Veterans With Chronic Pain. J Pain 2016;17:824–35. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16.Shadd JD, Ryan BL, Maddocks HL, McKay SD, Moulin DE. Neuropathic pain in a primary care electronic health record database. Eur J Pain 2015;19:715–21. [DOI] [PubMed] [Google Scholar]
- 17.Rovner GS, Sunnerhagen KS, Björkdahl A, et al. Chronic pain and sex-differences; women accept and move, while men feel blue. PLoS One 2017;12:e0175737. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18.Aloisi AM. Why We Still Need To Speak About Sex Differences and Sex Hormones in Pain. Pain Ther 2017;6:111–4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19.Abraham A, Barnett C, Katzberg HD, Lovblom LE, Perkins BA, Bril V. Sex differences in neuropathic pain intensity in diabetes. J Neurol Sci 2018;388:103–6. [DOI] [PubMed] [Google Scholar]
- 20.Cardinez N, Lovblom LE, Bai JW, et al. Sex differences in neuropathic pain in longstanding diabetes: Results from the Canadian Study of Longevity in Type 1 Diabetes. J Diabetes Complications 2018;32:660–4. [DOI] [PubMed] [Google Scholar]
- 21.Zheng H, Schnabel A, Yahiaoui-Doktor M, et al. Age and preoperative pain are major confounders for sex differences in postoperative pain outcome: A prospective database analysis. PLoS One 2017;12:e0178659. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 22.Ostrom C, Bair E, Maixner W, et al. Demographic Predictors of Pain Sensitivity: Results From the OPPERA Study. J Pain 2017;18:295–307. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23.Ruau D, Liu LY, Clark JD, Angst MS, Butte AJ. Sex differences in reported pain across 11,000 patients captured in electronic medical records. J Pain 2012;13:228–34. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 24.Mosher HJ, Krebs EE, Carrel M, Kaboli PJ, Weg MW, Lund BC. Trends in prevalent and incident opioid receipt: an observational study in Veterans Health Administration 2004–2012. J Gen Intern Med 2015;30:597–604. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 25.Richardson J, Holdcroft A. Gender differences and pain medication. Womens Health (Lond) 2009;5:79–90. [DOI] [PubMed] [Google Scholar]
- 26.Evans EA, Herman PM, Washington DL, et al. Gender Differences in Use of Complementary and Integrative Health by U.S. Military Veterans with Chronic Musculoskeletal Pain. Womens Health Issues 2018;28:379–86. [DOI] [PMC free article] [PubMed] [Google Scholar]

