Clinical features in primary care electronic records before diagnosis of ankylosing spondylitis: a nested case-control study

Background Ankylosing spondylitis (AS) often has a long period from first symptom presentation to diagnosis. We examined the occurrence of symptoms, prescriptions and diagnostic tests in primary care electronic records over time prior to a diagnosis of AS. Methods Nested case-control study using anonymised primary care electronic health records from Scotland. Cases were 74 adults with a first diagnosis of AS between 2000 and 2010. Controls were matched for age, sex and GP practice: (a) 296 randomly selected adults (b) 169 adults whose records contained codes indicating spinal conditions or symptoms. We extracted clinical features (symptoms, AS-related disorders, prescriptions and diagnostic tests). Conditional logistic regression was used to examine the association between clinical features (both individually and in combinations) and diagnosis of AS. We examined the associations between clinical features and diagnosis over time prior to diagnosis. Results Several new composite pointers were predictive of AS: including distinct episodes of axial pain separated by more than 6 months (OR 12.7, 95% CI 4.7 to 34.6); the occurrence of axial pain with and tendon symptoms within the same year (OR 21.7, 95% CI 2.6 to 181.5); and the co-occurrence (within 30 days) of axial pain and a prescription for nonsteroidal anti-inflammatory drug (OR 10.4, 95%CI 4.9 to 22.1). Coded episodes of axial pain increased steadily over the 3 years before diagnosis. In contrast, large joint symptoms and enthesopathy showed little or no time trend prior to diagnosis. Conclusions We identified novel composite pointers to a diagnosis of AS in GP records. These may represent valuable targets for diagnostic support systems.


Background
Ankylosing Spondylitis (AS) is an uncommon rheumatological condition in primary care, for which there is often a long time between consultation and diagnosis [1,2]. As with other conditions in which a long period between first consultation and diagnosis is often seen, symptoms of AS (such as spinal pain, stiffness and fatigue) are both nonspecific and frequently occuring [2,3]. This often leads to primary care doctors assigning the symptoms of AS to more common back pain conditions.
Most research on the clinical features of AS in primary care has focused on the characteristics of back pain. Inflammatory features such as worsening in the second half of the night, causing stiffness on waking and relief by exercise [4][5][6][7][8] have high sensitivity but relatively low specificity for AS. We considered the possibility of using data in electronic records to support earlier diagnosis of AS. While records may include codes for back pain, they do not currently include searchable information about the characteristics of pain. However other features in records may act as proxy markers for these pain charateristics. For instance the association in time between back pain and prescription of non-steroidal antiinflammatory drugs (NSAID) may suggest inflammatory back pain (which often responds well to NSAIDs). While such knowledge-derived features [9] are not immediately present in electronic records, they can be constructed [10,11]. One very recent study has used machine learning based on single items in a clinical care database but still found only low predictive values [12]..
We aimed to (a) construct enriched datasets from electronic health records which contained conventional and composite features potentially predictive of AS; (b) examine the association of these features with a subsequent diagnosis of AS in a nested case-control study; (c) examine the relationship of these features to diagnosis at different time periods before the date of diagnosis.

Data source
We analysed data from the Practice Team Information (PTI) database, a subset of the Primary Care Clinical Informatics Unit Research database held by the University of Aberdeen. The PTI database is comprised of pseudonymised electronic health records which were collected between 1996 and 2010 from approximately 224,000 patients registered with a primary care physician in Scotland. It is broadly representative of the Scottish population with regards to age, sex, deprivation and geographical location in terms of the ratio of urban: rural practices [13]. Practices which contributed their data to the PTI project were expected to record every clinical encounter using Read codes for clinical diagnoses and / or, main reasons for consultation. Diagnostic codes entered during and before the study dates were included in the data. All GP prescriptions were automatically recorded throughout the database period. Procedures for the routine recording and coding of diagnostic investigations changed over the database period as electronic linkages between laboratories and GP practices developed. Investigations were present in the data more in later years of the database period. The study was approved by the Primary Care Clinical Informatics Unit (PCCIU) team in keeping with PCCIU and local ethical committee procedures.

Populations
We conducted a nested case-control study. Cases were patients whose first recorded diagnosis of AS was between 1/1/2000 and 31/12/2010 and who were aged between 18 and 50 years at the time of diagnosis. We excluded patients whose first recorded diagnosis occurred within 1 year of registering with their GP practice as (a) it was possible that this represented the coding of an earlier diagnosis for the purposes of updating record summaries i.e. a prevalent rather than incident case of AS (b) it did not allow sufficient period of time in which relevant data before diagnosis could be examined for features predictive of AS. We then excluded patients who had been prescribed a disease modifying antirheumatic drug (sulphasalazine or methotrexate) more than 1month prior to their coded diagnosis. We did this in order to ensure that our analysis was limited to incident cases rather than prevalent cases in whom an earlier diagnosis had not been coded at the time it was made.
Population controls who did not have a diagnosis of AS at the index date were identified electronically from the database for each case. Controls were individually matched on age, sex and GP practice. Where more than four matched controls were available for a given case the computer randomly selected four. A second control group comprised patients with codes for other spinal diagnoses including degenerative, mechanical and intervertebral disc disorders or for a symptom of axial pain, but with no recorded diagnosis of AS. These controls were also electronically selected for each case and individually matched by age (within 2 years), sex and GP practice, with up to four symptomatic controls per case. We defined the index date for cases as the date of diagnosis of AS and for controls as the date of diagnosis of AS in the matched case.

Data extraction and preparation
For all cases and controls, data were extracted which detailed the dates of consultation for particular symptoms, disorders, tests and procedures and drugs prescribed. Table 1 lists the key data extracted and the categories into which we grouped related items.
As well as examining various individual features e.g. axial pain, we enriched the data by calculating when a number of composite features had occurred e.g. axial pain occurring within 30 days of a prescription for a non-steroidal anti-inflammatory drug (NSAID). We specified composite features according to one of three relationships: proximity (where two features occurred within a given number of days of each other), separate (where two consecutive instances of the same features occurred more than a given number of days apart), and exclusive (where one code occurred and another was not present). We used the separate composite features in order to identify discrete episodes as opposed to a single episode comprising multiple instances of a feature.
For each feature (single and composite) we ascertained its presence in the record of each individual at any time in the record, and during a series of overlapping threeyear time windows set at different intervals from the index date (for diagnosis or matching). We defined the windows using intervals between the end of the window and the index date of 0, 3, 6, 12, 18, 24 and 36 months. We then examined the appearance of statistical associations between available information in the record and diagnosis over time by comparing the same measure in different windows. The purpose of this was to differentiate between features which were present long before diagnosis (and might thus indicate missed diagnostic opportunities) and those which appeared only shortly before diagnosis (and may thus have triggered referral).

Analysis of association of features and patterns with diagnosis
We carried out conditional logistic regression to examine the association between each feature (conventional or composite) and the diagnosis of AS. Each feature was reported as either present or absent within the time period. Rather than use counts of how often a feature occurred, we used the "separated" composite variables to indicate multiple episodes. Analyses were reported as the odds ratio, OR (with 95% confidence intervals, CI). All analyses were conducted in R 3.6 [14].
We conducted the analysis separately with population and symptomatic control groups. For the time window analysis, we limited the data to patients who had been registered with their practice for at least 1year before the beginning of the relevant gap prior to diagnosis. We plotted the odds ratios for each feature at each of the six different time gaps in order to visualise the appearance of predictive features over time.

Patient characteristics
There were 74 newly diagnosed cases who met the study criteria. The annual number of diagnoses was broadly similar between 2000 and 2006 (representing an incidence of approximately 4/100,000 registered patients per year) but fell after 2006this coincided with a progressive reduction in the size of the database as GP practice computer systems were replaced.
Cases were matched to 296 population controls and 169 symptomatic controls. 53 cases (72%) were men and median age at diagnosis of AS was 37 years (interquartile range 31 to 43).

Data quality
54 cases (73%) were registered with the same GP practice (and therefore had continuous records in the PTI database) for at least 6 years before diagnosis. Similar proportions were seen for population and symptomatic controls (81 and 72% respectively). A code for one or more prescription of an appropriate treatment (e.g. a NSAID) was present for 68 cases (92%). Diagnostic tests were coded less oftenany relevant diagnostic code (such as for a full blood count, ESR or x-ray) was present in only 30 cases (41%).

Occurrence of diagnostic features
The numbers and proportions of patients with at least one instance of each feature, either in the 3 years prior to the index date or at any time are shown in Table 2 (vs. population controls) and Table 3 (vs. symptomatic controls). Tables 2 & 3 also show the ORs (with 95% CIs) for the two comparisons. As expected axial pain was more common in cases than population controls (OR 9.8, 95% CI 5.1 to 18.9) but not than symptomatic controls (OR 1.0, 95% CI 0.6 to 1.8) in the 3 years period before the index date. Tendon related disorders and iritis were both more common in cases than population controls (OR 3.4, 95% CI 1.3 to 8.7 and OR 32.0, 95% CI 4.0 to 255.9) but were recorded in only 21 and 16% of cases respectively. Urethral symptoms were infrequently recorded in all groups. Fatigue was not more common in cases when compared to population and symptomatic controls (OR 1.9, 95% CI 0.8 to 4.2 and 2.1, 95% CI 0.8 to 5.7) respectively. A history of inflammatory bowel disease was present in 16% of cases at any time before diagnosis. Codes indicating recording of x-rays and MRI scans were rare among cases and controls.

Occurrence of prescribed treatments
In both the population and the symptomatic group comparisons, both analgesics (OR 6.0, 95% CI 3.3 to 10.8 and OR 2.0, 95% CI 1.1 to 3.6) and NSAIDS (OR 12.9, 95% CI 6.3 to 26.8 and OR 3.6, 95% CI 1.8 to 7.1) were more commonly prescribed in the 3 year period before the index date to cases than controls. Prescriptions of tricyclic antidepressants, typically prescribed for chronic pain, were more common compared to population controls, unlike prescriptions for other antidepressants. Table 4 shows the number and proportion of patients with at least one instance of each of the composite features over the 3 years before date of diagnosis/ matching. Several composite features appeared relatively infrequently. Only three occurred in more than 15% of    Feature names follow the format X relationship Y where relationship is defined as follows X within N days of Yany occurrence of X within N days of any occurrence of Y (in either order) X separated by > N daystwo consecutive occurrences of X separated by more than N days X without ever Yone or more occurrences of X and no occurrences of Y cases: distinct episodes of axial pain separated by more than 6 months (OR 12.7, 95% CI 4.5 to 34.6); the occurrence of axial pain with and tendon symptoms within the same year (OR 21.7, 95% CI 2.6 to 181.5); and the co-occurrence (within 30 days) of axial pain and a prescription for nonsteroidal anti-inflammatory drug (OR 10.4, 95% CI 4.9 to 22.1).

Composite features
Occurrence of diagnostic features over the time prior to diagnosis Figure 1 shows histograms of the number of years between first episode of back pain or NSAID prescription and diagnosis (or matching) for cases and symptomatic controls. The median time between first coded episode of back pain and diagnosis of AS was 4 years (interquartile range 2 to 7). For the same patients the median time between first prescription for a NSAID was 4 years (interquartile range 2 to 6). The plot for axial pain shows that the odds ratio for coded episodes of axial pain rose steadily from the 3 year period ending 3 years before diagnosis to the 3 year period ending at the time of diagnosis when compared to population controls. On the other hand, the plots for large joint symptoms and (in the 2 years prior to diagnosis) enthesopathy suggests little or no time trend. The combination of axial pain and large joint symptomswhile relatively infrequentshows a strong signal beginning at least 2 years before diagnosis.

Summary of main findings
This study demonstrates new and potentially useful composite features within electronic health records, such as two or more distinct episodes of axial pain, which appear to have predictive value and may in turn lead to earlier diagnosis.

Strengths and limitations
Our choice of features as pointers used principles of selection based on expert input [15] and methods of data Fig. 1 Histograms of number of years before diagnosis when back pain and NSAID prescription first present in electronic records consolidation and aggregation which have been developed for use with clinical data sources other than GP records [10,16]. This sequence of steps is broadly comparable with other recent approaches to the summarisation of clinical data [16,17]. We used an established anonymised GP record set which contained both diagnostic and symptom codes using the Read code format as well as prescribing data which means that the method is transferrable to other datasets of primary care data and potentially into clinical use.
There were limitations relating to the data. The first was the small number of incident cases of AS. This meant that confidence intervals were wide and it is possible that we lacked statistical power to detect some potentially meaningful associations. The data was from stand-alone primary care records with no linkage to Fig. 2 Plots of odds ratio for individual features over three years, by gap between the end of the three year window and the date of diagnosis / matching. Dotted lines indicate 95% confidence intervals for odds ratios secondary care records so we could not assess the reliability of GPs' diagnosis of AS, however in our experience GP practices tend not to code such diagnoses without specialist opinion and in a recent US study a over 80% of a sample of coded diagnoses of AS were confirmed on chart review [18]. It should be noted that the annual incidence (approximately 4 per 100,000 per year in adults aged 18-60 years) is compatible with the lifetime prevalence of approximately 15 per 10,000 observed in other studies [19,20]. The diagnostic criteria for AS and the wider spondyloarthropathies evolved during the exposure time period [21] and it is increasingly recognised that disorders in the spondyloarthritis spectrum are much more common than full AS [22].
The data on symptoms and investigations were more sparse than anticipated with only around half of cases having back pain coded in the 3 years prior to diagnosis. This probably reflects the limited use of symptom codes by GPs, even in this database where a reason for consultation was meant to be given for each attendance. For those cases where a code for axial pain was entered, there were not long periods of GPs issuing NSAID prescriptions prior to a symptom code. The use of diagnostic tests was under-reported in the database, particularly until around 2006 when the direct importing of laboratory tests into electronic records began being used widely in contributing practices. While tests such as inflammatory markers have low predictive value, [23] the fact that they were being carried out suggests GPs may have had a raised index of suspicion for AS in at least some patients.

Comparison with existing literature
Previous studies of the clinical features of AS have used patient self-report rather than entries coded in GP records [4,5,24]. One recent machine learning study used a broadly similar range of single items from a different clinical dataset [12] but did not explicitly code composites which were clinically intuitive. We are not aware of studies which have looked for combinations of features. Our analysis of the emergence of clinical features over time confirms that in some cases there is an observably long time to diagnosis but also shows that the predictive value of clinical features does increase with proximity to diagnosis [12].

Implications for research and practice
The ultimate purpose of this research is to identify clinically useful predictors of a diagnosis of AS in order to facilitate early diagnosis. None of the features examined here are sufficient on their own, but merit examination in a larger dataset. However some features (such as the multiple episodes of axial pain) may be useful triggers to clinicians to ask more specific questions about inflammatory back pain. Diagnostic support prompts are more effective at the beginning of a consultation (influencing the clinician's prior probabilities and triggering specific questions) than at the end [25] so computation of the composite indicators of the kind we found, might not need to be carried out in real-time, but could run during quiet periods for the database and be used to inform future consultations.
The next step in research is to repeat this work with a larger, more recent and less sparse dataset. This should be able to access more information about diagnostic tests (through automatic transfer of results from laboratories to electronic records in general practice) and linkage to hospital records (to confirm diagnosis). Additionally, machine learning techniques [12,26,27] have potential value in feature reduction and model selection. Ultimately the aim must be to apply these observations within predictive models for earlier referral and diagnosis of AS.

Conclusion
We have developed and tested conventional and new composite pointers to a diagnosis of ankylosing spondylitis in GP records. Some of these were present several years before the diagnosis and may be valuable targets for systems to support earlier diagnosis.