Original Paper
Abstract
Background: The emergency department (ED) is increasingly used for behavioral health visits by adults and children, posing a challenge in delivering high-quality care to these populations. Mechanisms are needed to stratify patients presenting to the ED with behavioral health concerns to initiate more personalized care. Prior clustering methods have been applied to behavioral health datasets to establish patterns within clinical data and identify patient phenotypes with distinct clinical outcomes, but few studies have used event-based timeline clustering techniques to identify phenotypes in the acute care setting.
Objective: This study sought to use a patient event timeline cluster analysis to identify phenotypes of ED patients with behavioral health concerns and evaluate clinical outcomes among the phenotype clusters.
Methods: This was a retrospective observational study using electronic health records to analyze adult and pediatric behavioral health ED visits at an academic hospital from January 1 to December 31, 2023. Patients with behavioral health concerns were identified by visits that included a behavioral health diagnosis, behavioral health consultation, and/or presence of an ED behavioral health boarding status change. We created event timelines and used the modified Damerau-Levenshtein edit distance to identify patient phenotype clusters based on the sequence of events that occurred during the care episode. Primary outcomes evaluated included ED length of stay, ED behavioral health boarding, physical restraint use, intramuscular antipsychotic medication administration, 3-day and 30-day ED return visits, and 90-day patient mortality. Further analysis evaluating percent difference and risk ratio (RR) by cluster was performed for ED length of stay, intramuscular antipsychotic medication administration, use of physical restraints, 3-day ED returns, and 90-day mortality, with adjustment for patient age, sex, means of arrival, and triage acuity.
Results: A total of 5566 behavioral health ED visits were identified and included in the analysis. Ten distinct patient event timeline clusters were identified from 5219 visits, with the remaining 347 not clustered due to lower similarity. Cluster 0 demonstrated a significantly longer ED length of stay and greater use of intramuscular antipsychotic medications compared with all other clusters. Using cluster 0 as the reference, cluster 1 demonstrated the highest use of physical restraints, with an RR of 1.34 (95% CI 1.02-1.76), and the highest 90-day mortality, with an RR of 3.81 (95% CI 1.79-8.12). Cluster 6 demonstrated the highest 3-day ED return RR of 2.69 (95% CI 1.71-4.23).
Conclusions: Clusters demonstrated unique combinations of clinically relevant outcomes, including prolonged length of stay, ED boarding, admission rates, restraint use, ED return rates, and mortality. The novel use of patient clustering based on event timelines can effectively identify groups of patients with similar characteristics, creating an opportunity for tailoring clinical interventions to be more specific to their needs.
doi:10.2196/93188
Keywords
Introduction
Fueled by a growing prevalence of behavioral health (BH) disorders and inadequate access to psychiatric care, emergency departments (EDs) are increasingly being used for BH visits by adults and children [-], therefore serving as the front line of the nation’s BH crisis. BH disorders encompass both mental health disorders and substance use disorders []. Diagnoses in either category are associated with increased ED visits, and even more so among patients with codiagnoses [-].
The quality of care delivered to patients with BH concerns varies by ED and is often inadequate []. ED BH boarding, or the practice of holding patients in the ED after the disposition decision is made, remains a persistent problem and is associated with increased adverse events such as agitation, restraint use, and medication errors [-]. Multiple interventions have been trialed to improve the delivery of ED-based BH care, with variable success and levels of strain on the overall ED system [].
Patients presenting to the ED with BH concerns represent a vulnerable, heterogeneous population. There is a need to develop effective mechanisms for stratifying BH visits so that more patient-centered care can be delivered. Clustering methods have been used to establish patterns within highly variable clinical data and identify patient phenotypes that extend beyond categorization by diagnosis alone. Within BH data, prior studies have applied latent class analysis to identify subgroups with clinically distinct outcomes for patients with opioid-related ED visits and ED patients with mental health disorders based on patient characteristics and service use patterns [,]. Other approaches have used latent Dirichlet allocation, a natural language processing technique, to identify patterns using the electronic health record (EHR), including a prior study applying this method to patients with opioid-related disorders presenting to the ED to identify differences in clinical outcomes [].
Recent developments have moved from analysis of aggregate data toward methods that aim to cluster patterns of events into groups, allowing abstraction of medical decision-making and patient phenotyping based on the patient journey. Prior studies have suggested that sequences of medical events can be clustered using first-order Markov chains, while others have suggested a 2-step approach using hidden Markov models [-]. The complexity of these models can lead to difficulty with interpretation in a clinical setting, and some, for example, lower-order Markov chains, are unable to consider the long-range temporal aspects of clinical pathways. Moreover, Markov models often misinterpret rare events as unpredictable noise due to limited data when modeling state transition probabilities, which can lead to critical events in patient care being disregarded because they were uncommon.
An alternative to probabilistic transition-based methods is the development of string representations for clinical pathways and subsequent clustering by distance metrics []. Common distance metrics rely on calculating similarity based on the “edit distance” of any two strings, as demonstrated in the Levenshtein distance method, and pathways are subsequently clustered by their edit distance [].
In this paper, we hypothesized that the application of a string-based edit distance clustering algorithm would best account for rare but high importance clinical events and identify distinct clinical pathway phenotypes. Our objective was to create a patient event timeline analysis to identify phenotypes of patients who were cared for in the ED for BH concerns. We hypothesized that the application of a novel clustering algorithm would identify significant differences in clinical outcomes among patient phenotype clusters.
Methods
Study Design, Setting, and Population
This was a retrospective observational study using EHR to create patient event timelines. Clinical data were collected from an academic, tertiary care hospital ED with annual volumes of approximately 80,000 patients per year, including approximately 13,500 pediatric visits and approximately 5500 BH visits (adult and pediatric). The department includes a 4-bed dedicated psychiatric treatment area, with overflow to the main ED for treatment of additional patients as needed. Emergency psychiatry consultation is available 24 hours per day. Data were collected from a registry of all ED patients created from the EHR and maintained by the Department of Emergency Medicine. This registry includes patient demographics, visit information, events, and disposition.
All adult and pediatric patients with BH visits who presented to the ED from January 1 to December 31, 2023 were included in the analysis. Inclusion criteria were any ED patient encounter that met the definition of a BH visit, determined based on the presence of any one of 3 variables: a psychiatric or substance use disorder diagnosis associated with the visit (Table S1 in ) [-], BH consultation, or a status change to BH boarder. Multiple encounters meeting the inclusion criteria from the same patient were each included as independent observations. There were no specific exclusion criteria.
Variables
Patient-specific event variables included in the timeline-based cluster analysis were laboratory orders (L), clinical notes (N), medication administration (M), imaging orders (I), specialty consultation (C), admissions (A), electrocardiograms (E), other patient care events (ie, nursing interventions; O), procedures (P), and disposition (D). Admissions (A) indicated an admission order to any hospital service or to hospital observation, whereas disposition (D) indicated an order for placement in ED observation or transfer. Categorization and determination of relevance of variables were performed by 2 independent reviewers (EB and LW). To avoid bias, any discrepancies were reconciled by discussion and mutual agreement. The initial rate of agreement demonstrated a Cohen κ of 0.896.
Other baseline patient characteristics evaluated were patient age, sex, disposition, arrival via emergency medical services (EMS), and primary diagnoses, and chief concerns. The primary diagnosis category was based on the primary ED International Classification of Diseases, Tenth Revision (ICD-10) diagnosis. It was then grouped according to the clinical classifications software Refined for International Classification of Diseases, Tenth Revision, Clinical Modification (ICD-10-CM) diagnoses from the Agency for Healthcare Research and Quality []. Chief concerns were categorized based on the World Health Organization International Classification of Primary Care system []. The primary outcomes evaluated included ED length of stay (LOS), ED BH boarding, violent and any physical restraint use in the ED, any physical restraint use in the hospital, intramuscular antipsychotic medication administration, ED return visits to the same institution or any of the institution’s 18 surrounding community hospitals on the same EHR within 3 and 30 days, and 90-day patient mortality. Prolonged LOS was defined as greater than 8 hours. Eight hours is consistent with definitions of prolonged ED encounters in the Hospital Outpatient Quality Reporting on Emergency Care Access and Timeliness by the Centers for Medicare and Medicaid Services that will begin implementation as the national quality standard in 2027 []. ED BH boarder status is a status change on the EHR ED track board determined by the ED clinician based on clinical judgment. Both outcomes were analyzed as complementary measures of delays in care delivery. Mortality data were obtained from the study institution’s patient registration data that included any death reported within the institution or from outside sources.
Data Analysis
Patient care events were arranged sequentially to create timelines for each ED BH encounter. Events that occurred at the same recorded time were arranged in the order reported by the EHR. Duplicate events recorded at the same time were removed, but multiple events within the same category recorded at the same time were included in the timeline. A modified Damerau-Levenshtein similarity score was calculated for each pair of encounters to determine timelines with similar order and composition of events []. These similarity scores were then used in a density-based clustering algorithm (ordering points to identify clustering structure [OPTICS]) that identified the predominant clusters of similar BH encounters [,].
To identify the major timeline clusters among ED BH encounters, a maximum neighborhood radius threshold (ε) of 10 and a minimum of 150 encounters were required to define a cluster, which resulted in 10 timeline clusters being identified. A minimum group size of 150 encounters was used to ensure that the final clusters were robust to potential noise from minor differences in patient care timelines while still allowing for the capture of a variety of meaningful patient phenotypes. This threshold relative to the sample size is consistent with prior similar clustering algorithms using clinical care events []. Refer to [-] for a full description of the similarity calculations and clustering algorithm.
The only identified variable with missing data was ED disposition, which is reported in results as a standalone category. Encounters with unknown disposition were excluded from analyses specifically related to disposition but included in analyses elsewhere. For in-hospital outcomes, including antipsychotic medication and physical restraint use, data were based on orders placed in the EHR. Therefore, a lack of an order was assumed to indicate that the corresponding intervention did not occur during the encounter. For patient mortality, a lack of data indicating patient death was assumed to indicate that the patient remained alive. Similarly, a lack of ED encounters within the 3-day and 30-day return time frames was assumed to indicate that the patient did not return to the ED. Our data included patient follow-up beyond 30 days for 96.4% (5364/5566) encounters, supporting the assumption that outcomes through this time frame were being adequately captured.
Statistical Methods
Numeric characteristics were summarized with medians and IQRs; categorical characteristics were summarized with frequency counts and percentages. The use of intramuscular antipsychotic medications, orders placed for physical restraints, return ED visits within 3 or 30 days, and mortality within 90 days were also summarized with 95% CIs on the rate of occurrence using Jeffreys binomial intervals.
Patient LOS was compared between clusters using Poisson generalized estimating equations (GEEs) accounting for repeat encounters from the same patient. Similarly, use of intramuscular antipsychotic medications, physical restraints, ED returns, and patient mortality were compared between clusters using log-binomial GEEs. All models assumed constant within-patient correlation across all repeat encounters, and SEs were determined using the Eicker-Huber-White sandwich estimator. Models were adjusted for patient age, sex, means of arrival, and triage Emergency Severity Index (ESI) acuity. These variables were chosen as core demographics and surrogates for clinical severity that are readily identifiable upon arrival to the ED. Results for LOS were reported as adjusted percent differences with 95% CIs, whereas results for all other outcomes were reported as adjusted risk ratios (RRs) with 95% CIs. CIs were corrected for multiple comparisons using the Hochberg multiplicity step-up procedure [].
All analyses were conducted using R (version 4.4.1; R Foundation for Statistical Computing), and density-based clustering was performed with the package dbscan (version 1.2-0).
Ethical Considerations
This study (application number 24-004845) was submitted to the institutional review board (IRB) at Mayo Clinic and was determined to be exempt from the requirement of IRB approval (45 CFR 46.104d, Category/Subcategory 4(iii)). The requirement for informed consent was waived by the IRB. Data were deidentified prior to analysis, and no individually identifiable information was disclosed. Data were stored and handled in accordance with institutional data security protocols to ensure confidentiality throughout the study.
Results
Participants
There were 75,375 ED visits during the study period. Of the 75,375 visits, a total of 5566 (7.4%) BH ED visits from 3864 distinct patients were identified and included in the analysis; 4181 encounters had a psychiatric diagnosis, 3896 visits included a BH consultation, and 1576 encounters involved status change to BH boarding. Overlap existed in these categories—1453 patients had both a BH consultation and BH boarding, 2530 had a BH consultation and psychiatric diagnosis, 1349 had BH boarding status and a psychiatric diagnosis, and 1254 encounters met all 3 inclusion criteria (Figure S1 in ) [-]. In total, 10 distinct patient event timeline clusters were identified, comprising 93.8% (5219/5566) of BH visits. The remaining 6.2% (347/5566) of BH visits were not clustered due to low similarity.
Descriptive Data
Clusters were arranged by size, numbered 0 (largest cluster) to 9 (smallest cluster), and were summarized based on event combinations (). Patient demographics were compared across clusters (). The median age was 37 (IQR 23-53) years. Male patients comprised 53.2% (2963/5566) of the study population. Arrival by EMS occurred in 40.2% (2240/5566) of visits, ranging from 25.7% (80/311; cluster 5) to 58% (556/958; cluster 1). The most frequent disposition was discharge (2636/5566, 47.4%), followed by hospital admission (2315/5566, 41.6%).
| Visits (n=5566), n (%) | Clinical description | Example visits | |
| Cluster 0 | 1193 (21.4) |
| LLLLLLLNCNMMN |
| Cluster 1 | 958 (17.2) |
| NELLLLLLMLAM |
| Cluster 2 | 926 (16.6) |
| NELLLLLLLLLNMNCCLAANN |
| Cluster 3 | 598 (10.7) |
| NELLLLLLELLLLLLLLN |
| Cluster 4 | 316 (5.7) |
| NNNNN |
| Cluster 5 | 311 (5.6) |
| NCNNNN |
| Cluster 6 | 273 (4.9) |
| NLLLLLLLLNN |
| Cluster 7 | 264 (4.7) |
| NCNCAN |
| Cluster 8 | 208 (3.7) |
| NLLLLLLLNLLLLNNA |
| Cluster 9 | 172 (3.1) |
| NLNNNMNN |
| Not clustered | 347 (6.2) | —a | — |
aNot applicable.
| Overall (N=5566 visits) | Cluster 0 (n=1193 visits) | Cluster 1 (n=958 visits) | Cluster 2 (n=926 visits) | Cluster 3 (n=598 visits) | Cluster 4 (n=316 visits) | Cluster 5 (n=311 visits) | Cluster 6 (n=273 visits) | Cluster 7 (n=264 visits) | Cluster 8 (n=208 visits) | Cluster 9 (n=172 visits) | |||||||||||||
| Total patients, n | 3864 | 985 | 803 | 840 | 528 | 292 | 289 | 247 | 232 | 197 | 155 | ||||||||||||
| Visits by age (y), median (IQR) | 37 (23-53) | 35 (24-46) | 50 (36-64) | 41 (29-60) | 38 (29-53) | 23 (15-38) | 18 (14-31) | 36 (25-47) | 16 (13-30) | 38 (27-44) | 32 (18-49) | ||||||||||||
| Visits by age <18 y, n (%) | 798 (14.3) | 104 (8.7) | 44 (4.6) | 80 (8.6) | 27 (4.5) | 110 (34.8) | 143 (46) | 19 (7) | 147 (55.7) | 17 (8.2) | 22 (12.8) | ||||||||||||
| Visits by male patients, n (%) | 2963 (53.2) | 622 (52.1) | 543 (56.7) | 458 (49.5) | 353 (59) | 159 (50.3) | 160 (51.4) | 152 (55.7) | 115 (43.6) | 120 (57.7) | 107 (62.2) | ||||||||||||
| EMSa arrivals, n (%) | 2240 (40.2) | 329 (27.6) | 556 (58) | 431 (46.5) | 298 (49.8) | 88 (27.8) | 80 (25.7) | 113 (41.4) | 69 (26.1) | 79 (38) | 59 (34.3) | ||||||||||||
| EDb behavioral health boarder status, n (%) | 1575 (28.3) | 900 (75.4) | 52 (5.4) | 284 (30.7) | 31 (5.2) | 7 (2.2) | 38 (12.2) | 34 (12.5) | 105 (39.8) | 60 (28.8) | 8 (4.7) | ||||||||||||
| Intramuscular antipsychotic medication used, n (%) | 259 (4.7) | 127 (10.6) | 24 (2.5) | 44 (4.8) | 25 (4.2) | 1 (0.3) | 1 (0.3) | 10 (3.7) | 6 (2.3) | 12 (5.8) | 2 (1.2) | ||||||||||||
| Physical restraints sued in the ED, n (%) | 212 (3.8) | 77 (6.5) | 31 (3.2) | 44 (4.8) | 21 (3.5) | 2 (0.6) | 0 (0) | 10 (3.7) | 8 (3) | 5 (2.4) | 5 (2.9) | ||||||||||||
| ED disposition, n (%) | |||||||||||||||||||||||
| Discharge | 2636 (47.4) | 405 (33.9) | 27 (2.8) | 347 (37.5) | 571 (95.5) | 297 (94) | 306 (98.4) | 265 (97.1) | 58 (22) | 39 (18.8) | 172 (100) | ||||||||||||
| Admit to hospital | 2315 (41.6) | 676 (56.7) | 664 (69.3) | 455 (49.1) | 4 (0.7) | 4 (1.3) | 1 (0.3) | 0 (0) | 197 (74.6) | 151 (72.6) | 0 (0) | ||||||||||||
| Admit to ICUc or PCUd | 371 (6.7) | 3 (0.3) | 262 (27.3) | 77 (8.3) | 0 (0) | 0 (0) | 0 (0) | 0 (0) | 0 (0) | 8 (3.8) | 0 (0) | ||||||||||||
| Other disposition | 236 (4.2) | 105 (8.8) | 5 (0.5) | 45 (4.9) | 22 (3.7) | 15 (4.7) | 4 (1.3) | 7 (2.6) | 9 (3.4) | 10 (4.8) | 0 (0) | ||||||||||||
| Unknown | 8 (0.1) | 4 (0.3) | 0 (0) | 2 (0.2) | 1 (0.2) | 0 (0) | 0 (0) | 1 (0.4) | 0 (0) | 0 (0) | 0 (0) | ||||||||||||
| ED length of stay (h), median (IQR) | 6.0 (3.9-12.9) | 20.8 (8.2-43.4) | 5.2 (3.8-7.1) | 7.7 (5.1-15.6) | 5.4 (3.9-7.4) | 2.8 (1.7-4.1) | 4.0 (3.1-5.8) | 5.6 (3.8-8.5) | 5.6 (4.0-18.1) | 5.8 (3.8-12.3) | 3.4 (2.1-4.9) | ||||||||||||
| ED length of stay ≥8 h, n (%) | 2011 (36.1) | 905 (75.9) | 151 (15.8) | 434 (46.9) | 124 (20.7) | 11 (3.5) | 46 (14.8) | 76 (27.8) | 105 (39.8) | 71 (34.1) | 18 (10.5) | ||||||||||||
aEMS: emergency medical services.
bED: emergency department.
cICU: intensive care unit.
dPCU: progressive care unit.
Clusters demonstrated patterns in chief concerns and primary diagnoses (). Initial ED chief concerns of suicidal ideation and psychological evaluation were highest in cluster 0 (37.5% and 36.3%), cluster 5 (37.6% and 32.8%), and cluster 7 (47.7% and 30.7%), respectively (A). By contrast, nonpsychological chief concerns were highest in cluster 1 (50.7%), cluster 2 (39.7%), and cluster 3 (31.8%). Similar patterns were found in the final primary diagnoses given by the ED clinician for the patient’s visit (B). The highest rates of ED primary diagnoses of suicidal ideation and self-harm were seen in cluster 7 (58.7%), cluster 0 (45.7%), cluster 8 (33.7%), and cluster 5 (33.1%). Other nonpsychological diagnoses were most commonly seen in cluster 1 (34.7%) and cluster 2 (31.6%).

Outcome Data
Clusters represented unique combinations of visit complexity and clinical outcomes ( and ). ED LOS was further compared among clusters (). The overall median ED LOS was 6.0 hours, ranging from 2.8 hours (cluster 4) to 20.8 hours (cluster 0). These trends correlated with the proportion of patients under BH ED boarder status, which was lowest in cluster 4 (7/316, 2.2%) and highest in cluster 0 (900/1193, 75.4%). Administration of intramuscular antipsychotic medication occurred in 4.7% (259/5566) of visits, from 0.3% (1/316, cluster 4; 1/311, cluster 5) to 10.6% (127/1193, cluster 0). The use of physical restraints occurred in 6.9% (384/5566) of visits, with 3.8% (212/5566) occurring in the ED. Use was lowest in cluster 5 (n=0). While the incidence of any physical restraint use was highest in cluster 1 (111/958, 11.6%), physical restraint use in the ED specifically was highest in cluster 0 (77/1193, 6.5%). This corresponds with the distinction in the use of physical restraints for violent behavior, which comprised a larger proportion in cluster 0 (103/1193, 8.6% total and 100/1193, 8.4% violent) compared with cluster 1 (111/958 11.6% total and 63/958, 6.6% violent). The overall rates of ED returns within 3 days and 30 days were 5.8% (324/5566) and 25.8% (1435/5566), respectively. Mortality within 90 days averaged 2.4% (136/5566), reaching 6.7% (64/958) in cluster 1, with no deaths in clusters 5, 6, and 7.


Main Results
Clinical outcomes were compared among clusters using percent differences and RRs with 95% CIs (). Cluster 0 served as the reference due to comprising the largest cluster size. Cluster 0 demonstrated a longer LOS compared with all other clusters, with percent differences ranging from –91.3% (95% CI –93.0% to –89.1%) in cluster 4 to –44.9% (95% CI –64.3% to –14.9%) in cluster 7. Use of intramuscular antipsychotics was also higher in cluster 0 compared with all other clusters except cluster 8 (RR 0.54, 95% CI 0.29-1.02), with the lowest observed RRs of 0.03 (95% CI 0.00-0.24) in cluster 4 and 0.03 (95% CI 0.00-0.25) in cluster 5. Use of physical restraints demonstrated a lower RR in cluster 3 at 0.45 (95% CI 0.28-0.71), cluster 4 at 0.11 (95% CI 0.04-0.35), cluster 6 at 0.42 (95% CI 0.21-0.84), and cluster 9 at 0.34 (95% CI 0.14-0.81), and it was higher in cluster 1 at 1.34 (95% CI 1.02-1.76). The 3-day ED return RR was lower in cluster 1 at 0.57 (95% CI 0.34-0.96) and higher in cluster 3 at 2.24 (95% CI 1.51-3.32), cluster 4 at 2.42 (95% CI 1.52-3.85), cluster 5 at 1.90 (95% CI 1.14-3.17), and cluster 6 at 2.69 (95% CI 1.71-4.23). Cluster 1 had a higher risk of 90-day mortality (RR 3.81, 95% CI 1.79-8.12).
| Patient cluster | Length of stay | Intramuscular antipsychotic medication use | Physical restraint use | 3-day ED return | 90-day mortality | |||||
| Median (IQR) | PD (95% CI) | Percentage (95% CI) | RR (95% CI) | Percentage (95% CI) | RR (95% CI) | Percentage (95% CI) | RR (95% CI) | Percentage (95% CI) | RR (95% CI) | |
| Cluster 0 (n=1193) | 20.8 (8.2-43.4) | Reference | 10.6 (9.0 to 12.5) | Reference | 8.6 (7.1 to 10.3) | Reference | 4.2 (3.2 to 5.4) | Reference | 0.8 (0.4 to 1.4) | Reference |
| Cluster 1 (n=958) | 5.2 (3.8-7.1) | –80.4 (–83.0 to –77.4) | 2.5 (1.7 to 3.6) | 0.24 (0.15 to 0.38) | 11.6 (9.7 to 13.7) | 1.34 (1.02 to 1.76) | 2.7 (1.8 to 3.9) | 0.57 (0.34 to 0.96) | 6.7 (5.3 to 8.5) | 3.81 (1.79 to 8.12) |
| Cluster 2 (n=926) | 7.7 (5.1 to 15.6) | –49.2 (–58.5 to –37.8) | 4.8 (3.5 to 6.3) | 0.45 (0.32 to 0.64) | 9.0 (7.3 to 10.9) | 1.04 (0.79 to 1.37) | 5.3 (4.0 to 6.9) | 1.16 (0.77 to 1.75) | 3.2 (2.3 to 4.7) | 2.09 (0.93 to 4.71) |
| Cluster 3 (n=598) | 5.4 (3.9 to 7.4) | –78.0 (–81.9 to –73.2) | 4.2 (2.8 to 6.0) | 0.39 (0.25 to 0.61) | 3.8 (2.5 to 5.6) | 0.45 (0.28 to 0.71) | 10.5 (8.3 to 13.2) | 2.24 (1.51 to 3.32) | 1.8 (1.0 to 3.2) | 1.69 (0.67 to 4.42) |
| Cluster 4 (n=316) | 2.8 (1.7 to 4.1) | –91.3 (–93.0 to –89.1) | 0.3 (0.0 to 1.5) | 0.03 (0.00 to 0.24) | 0.9 (0.3 to 2.5) | 0.11 (0.04 to 0.35) | 10.4 (7.4 to 14.2) | 2.42 (1.52 to 3.85) | 0.6 (0.1 to 2.0) | 1.29 (0.27 to 6.23) |
| Cluster 5 (n=311) | 4.0 (3.1 to 5.8) | –81.6 (–86.9 to –74.1) | 0.3 (0.0 to 1.5) | 0.03 (0.00 to 0.25) | 0.0 (0.0 to 0.8) | —b | 7.7 (5.1 to 11.1) | 1.90 (1.14 to 3.17) | 0.0 (0.0 to 0.8) | — |
| Cluster 6 (n=273) | 5.6 (3.8 to 8.5) | –72.6 (–78.6 to –65.0) | 3.7 (1.9 to 6.4) | 0.34 (0.17 to 0.67) | 3.7 (1.9 to 6.4) | 0.42 (0.21 to 0.84) | 12.1 (8.6 to 16.3) | 2.69 (1.71 to 4.23) | 0.0 (0.0 to 0.9) | — |
| Cluster 7 (n=264) | 5.6 (4.0 to 18.1) | –44.9 (–64.3 to –14.9) | 2.3 (1.0 to 4.6) | 0.21 (0.09 to 0.48) | 5.3 (3.1 to 8.5) | 0.61 (0.34 to 1.08) | 1.5 (0.5 to 3.6) | 0.38 (0.13 to 1.11) | 0.0 (0.0 to 0.9) | — |
| Cluster 8 (n=208) | 5.8 (3.8 to 12.3) | –67.4 (–72.5 to –61.4) | 5.8 (3.2 to 9.6) | 0.54 (0.29 to 1.02) | 4.8 (2.5 to 8.4) | 0.56 (0.29 to 1.09) | 4.8 (2.5 to 8.4) | 1.41 (0.72 to 2.76) | 1.9 (0.7 to 4.5) | 2.08 (0.60 to 7.22) |
| Cluster 9 (n=172) | 3.4 (2.1 to 4.9) | –89.1 (–91.7 to –85.7) | 1.2 (0.2 to 3.7) | 0.11 (0.03 to 0.46) | 2.9 (1.1 to 6.3) | 0.34 (0.14 to 0.81) | 6.4 (3.4 to 10.8) | 1.36 (0.79 to 2.33) | 1.7 (0.5 to 4.6) | 2.49 (0.61 to 10.16) |
aPDs and RRs were adjusted for patient age, sex, means of arrival, and triage Emergency Severity Index acuity. CIs were corrected for multiple comparisons using the Hochberg multiplicity step-up procedure.
bNot applicable.
Discussion
Principal Findings
This study identified 10 clusters using a modified Damerau-Levenshtein edit distance as a method to differentiate emergency patients presenting with BH concerns. To our knowledge, this study is novel in its application of time-based clustering algorithms to evaluate ED BH datasets. Clustering techniques have been used in multiple ways, including patient risk stratification []. Application of these techniques can contribute to advances in personalized medicine and facilitate improved understanding of patients.
Despite numerous approaches to clustering, few incorporate a chronological course as part of the methodology [,]. The ED is a setting where clinical events are typically condensed into a short time frame, without long periods between activities. Incorporation of chronology into acute patient phenotype identification represents a novel approach. Longer timelines have been evaluated as tools to quickly synthesize patient characteristics for care teams and to predict patient mortality [-]. Large language models have been used to create patient timelines using unstructured notes to improve care for patients receiving cancer-directed therapies and patients with rare diseases [,]. Our analysis shifts the use of timelines from a tool used to inform care of a specific patient to one that sorts patients into similar groups that may benefit from directed interventions based on their cluster.
There are clear patient phenotypes that emerge through this analysis from a clinical standpoint. Cluster characteristics are summarized below.
Cluster 0 (1193/5566, 21.4%) was notable for high rates of suicidal ideation and psychotic disorders requiring psychiatric consultation. The majority experienced prolonged ED LOS and ED BH boarding. This cluster had the highest rates of intramuscular antipsychotic medication use, ED physical restraint use. and violent restraint use. These findings indicate a phenotype with prolonged ED encounters with complex psychiatric needs and violent events. However, it experienced relatively low rates of ED return and mortality.
Cluster 1 (958/5566, 17.2%) represented the oldest patients, with frequent EMS arrivals, high intensive care unit admission rates, and the highest 90-day mortality rate. More than half had a nonpsychological chief concern. None received ED psychiatric consultation, consistent with medically ill patients with psychiatric comorbidities. This cluster demonstrated the highest rate of total restraint use (including nonviolent restraints), but not the highest rate of violent restraint use.
Cluster 2 (926/5566, 16.6%) always received psychiatric consultation with relatively high rates of ED LOS over 8 hours, hospital admission, and ED return within 30 days. It demonstrated a relatively high rate of nonpsychological diagnoses and average rate of suicidal ideation.
Cluster 3 (598/5566, 10.7%) had high EMS arrival and ED return rates, but none required psychiatric consultation or admission. A relatively high percentage presented with alcohol intoxication, indicating an important comorbidity. The majority were discharged from the ED.
Cluster 4 (316/5566 5.7%) was a relatively young population that typically presented for suicidal ideation, psychological evaluation, or alcohol use. None had psychiatry consultation. This cluster had relatively short LOS and had very low rates of physical restraints and intramuscular medications. The majority were discharged and demonstrated relatively high ED return rates.
Cluster 5 (311/5566, 5.6%) was a relatively young population that typically presented for suicidal ideation or psychological evaluation. All received psychiatric consultation. This cluster had very low rates of intramuscular medication administration, and physical restraints were never used during their visit. It had a relatively short median LOS but did have a notable proportion with prolonged LOS and ED BH boarding. Most patients were discharged.
Cluster 6 (273/5566, 4.9%) demonstrated a relatively high rate of alcohol use as a chief concern. None had imaging, consultations, or admissions. A relatively high proportion had ED LOS over 8 hours. Most patients were discharged. It represented the highest ED return rate within 3 days, but there was zero mortality.
Cluster 7 (264/5566, 4.7%) represented the youngest cluster and often presented with suicidal ideation or a psychological chief concern. There was a relatively high rate of ED LOS over 8 hours and ED BH boarding. All patients received psychiatric consultation, and the majority were admitted to the hospital. It had the lowest ED return rates and zero mortality.
Cluster 8 (208/5566, 3.7%) involved a mixture of chief concerns. There was a relatively high admission rate with no imaging or consultations. It demonstrated relatively high rates of ED LOS over 8 hours and ED BH boarding. It had low mortality rates.
Cluster 9 (172/5566, 3.1%) had minimal interventions, relatively short LOS, and the highest ED return rate within 30 days. All patients in this cluster were discharged from the ED. A relatively high proportion were male.
Most patients are represented in clusters 0 to 3. These clusters represent high use of resources, including prolonged ED LOS (cluster 0), EMS use (clusters 1 and 3), increased hospitalization (cluster 1), and frequent diagnostic testing and consultations (clusters 0 and 2). Our analysis demonstrates a method of differentiating these important populations, which has applicability for future study designs focused on ED BH resource utilization.
Our clustering approach also allowed for a more granular characterization of patient phenotypes compared with direct stratification of events identified in conventional patient timelines. In most cases, separate clusters that were defined by similar ED utilization had notably different outcomes, even when presenting chief concerns were similar. For instance, clusters 0, 5, and 7 were distinctly characterized as patient encounters with consultation and no imaging orders. These clusters had the highest rates of suicidal ideation (37.5%, 37.6%, and 47.6%) and lowest rates of nonpsychological concerns (7%, 7.1%, and 4.5%). However, these groups differed substantially across patient outcomes and characteristics, with large differences in physical restraint use (8.6%, 0%, and 5.3%), intramuscular antipsychotic medication administration (10.6%, 0.3%, and 2.3%), LOS exceeding 8 hours (75.9%, 14.8%, and 39.8%), ED discharge (33.9%, 98.4%, and 22%), and 3-day ED returns (4.2%, 7.7%, and 1.5%). The ability to isolate these subsets by clinically important outcomes is a powerful tool. For instance, differentiating subsets with prolonged LOS can help identify gaps in efficient care delivery. Likewise, identifying patient phenotypes with high rates of intramuscular antipsychotic medication administration could help improve patient and staff safety, as evidence suggests negative outcomes associated with this intervention, including prolonged LOS, increased use of physical restraints, and the need for supplemental oxygen [].
Limitations
While there is value in the application of a novel clustering algorithm on clinical data, the novelty itself carries limitations. For instance, methods for choosing minimum group size for density-based clusters vary, and changing the threshold would affect the number of clusters identified and potentially alter the resulting cluster characteristics. While this study’s group size is consistent with similar prior clustering algorithms [], validation of this clustering algorithm on external data is needed to support the robustness of our identified phenotypes. Further studies are also needed to focus on the translation of algorithm use into measurable clinical action. Additional use cases will provide further information on algorithm reliability and its potential impact on clinical practice. However, we believe that the novelty of chronological assessment in the acute care setting has valuable potential. Limitations also include those inherent in the use of EHR data and its limited ability to reflect qualitative factors in the clinical course that may impact patient care. This study did not incorporate unstructured data from notes to reflect any qualitative events, only discrete events where a definite action occurred.
The use of a clustering algorithm for identifying patient phenotypes has potential use in evaluating clinically relevant outcomes for a population of interest and identifying areas for health care delivery improvement. However, any future application of this clustering algorithm would require assessment for appropriateness in each clinical scenario, particularly as it applies to different patient populations and clinical environments, as this method has not yet been externally validated. The findings at our single institution with our specific patient population indicate that this model can provide meaningful clinical insight.
Conclusions
The use of clustering based on patient event timelines can identify clinically relevant patient phenotypes. Extrapolating the patient phenotypes and their clinical course has the potential to affect care for patients with BH emergencies, as well as guide further interventions to decrease unnecessary resource utilization, avoid recidivism, and improve outcomes.
Future areas for development include translation of this clustering algorithm into clinical action, including the potential for early identification of patients with phenotype characteristics associated with adverse outcomes such as those evaluated in this study. The application of more personalized clinical management approaches can help support staff in their care delivery for patients presenting with BH concerns to the ED.
Acknowledgments
The authors would like to acknowledge Katie Bobroske for her inspiration in idea generation for the methodology used.
Data Availability
The datasets generated or analyzed during this study are available from the corresponding author on reasonable request.
Funding
The authors declared that no financial support was received for this work.
Generative AI Use
The AI tool ChatGPT was used to identify references during the literature review process. These references were then thoroughly reviewed for credibility and suitability by the authors prior to their use as citations. It was also used for generating ideas for formatting the results prior to writing. The authors attest that generative AI technology did not generate the text, figures, or other content of this manuscript.
Authors' Contributions
Conceptualization: EB, AM, KK, LW
Data curation: LW
Formal analysis: EB, AM, SH, LW
Investigation: EB, LW
Methodology: EB, AM, KK, LW
Project administration: EB, LW
Writing – original draft: EB, AM, SH, KK, LW
Writing – review & editing: EB, AM, SH, KK, LW
Conflicts of Interest
None declared.
Supplemental methods.
DOCX File , 123 KBReferences
- Halmer TC, Beall RC, Shah AA, Dark C. Health policy considerations in treating mental and behavioral health emergencies in the United States. Emerg Med Clin North Am. Nov 2015;33(4):875-891. [CrossRef] [Medline]
- Thomas KC, Ellis AR, Konrad TR, Holzer CE, Morrissey JP. County-level estimates of mental health professional shortage in the United States. Psychiatr Serv. Oct 2009;60(10):1323-1328. [CrossRef] [Medline]
- Lo CB, Bridge JA, Shi J, Ludwig L, Stanley RM. Children's mental health emergency department visits: 2007-2016. Pediatrics. Jun 2020;145(6):e20191536. [CrossRef] [Medline]
- Bommersbach TJ, McKean AJ, Olfson M, Rhee TG. National trends in mental health-related emergency department visits among youth, 2011-2020. JAMA. May 02, 2023;329(17):1469-1477. [FREE Full text] [CrossRef] [Medline]
- Behavioral health and substance use disorders. Agency for Healthcare Research and Quality. 2024. URL: https://www.ahrq.gov/ncepcr/research/behavioral-health/index.html [accessed 2026-06-03]
- Baillargeon J, Thomas CR, Williams B, Begley CE, Sharma S, Pollock BH, et al. Medical emergency department utilization patterns among uninsured patients with psychiatric disorders. Psychiatr Serv. Jul 2008;59(7):808-811. [CrossRef] [Medline]
- Chaput YJ, Lebel MJ. Demographic and clinical profiles of patients who make multiple visits to psychiatric emergency services. Psychiatr Serv. Mar 2007;58(3):335-341. [CrossRef] [Medline]
- Curran GM, Sullivan G, Williams K, Han X, Allee E, Kotrla KJ. The association of psychiatric comorbidity and use of the emergency department among persons with substance use disorders: an observational cohort study. BMC Emerg Med. Dec 03, 2008;8:17. [FREE Full text] [CrossRef] [Medline]
- Nolan JM, Fee C, Cooper BA, Rankin SH, Blegen MA. Psychiatric boarding incidence, duration, and associated factors in United States emergency departments. J Emerg Nurs. Jan 2015;41(1):57-64. [CrossRef] [Medline]
- McEnany FB, Ojugbele O, Doherty JR, McLaren JL, Leyenaar JK. Pediatric mental health boarding. Pediatrics. Oct 2020;146(4):e20201174. [CrossRef] [Medline]
- Ibeziako P, Kaufman K, Scheer KN, Sideridis G. Pediatric mental health presentations and boarding: first year of the COVID-19 pandemic. Hosp Pediatr. Sep 01, 2022;12(9):751-760. [CrossRef] [Medline]
- Hsu CC, Chan HY. Factors associated with prolonged length of stay in the psychiatric emergency service. PLoS One. Aug 20, 2018;13(8):e0202569. [FREE Full text] [CrossRef] [Medline]
- Major D, Rittenbach K, MacMaster F, Walia H, VandenBerg SD. Exploring the experience of boarded psychiatric patients in adult emergency departments. BMC Psychiatry. Sep 27, 2021;21(1):473. [FREE Full text] [CrossRef] [Medline]
- Bakhsh HT, Perona SJ, Shields WA, Salek S, Sanders AB, Patanwala AE. Medication errors in psychiatric patients boarded in the emergency department. Int J Risk Saf Med. 2014;26(4):191-198. [CrossRef] [Medline]
- Austin EE, Cheek C, Richardson L, Testa L, Dominello A, Long JC, et al. Improving emergency department care for adults presenting with mental illness: a systematic review of strategies and their impact on outcomes, experience, and performance. Front Psychiatry. Feb 29, 2024;15:1368129. [FREE Full text] [CrossRef] [Medline]
- Chhabra N, Smith DL, Maloney CM, Archer J, Sharma B, Thompson HM, et al. The identification of subphenotypes and associations with health outcomes in patients with opioid-related emergency department encounters using latent class analysis. Int J Environ Res Public Health. Jul 21, 2022;19(14):8882. [FREE Full text] [CrossRef] [Medline]
- Fleury MJ, Cao Z, Grenier G. Emergency department use among patients with mental health problems: profiles, correlates, and outcomes. Int J Environ Res Public Health. Jun 30, 2024;21(7):864. [FREE Full text] [CrossRef] [Medline]
- Taylor RA, Gilson A, Schulz W, Lopez K, Young P, Pandya S, et al. Computational phenotypes for patients with opioid-related disorders presenting to the emergency department. PLoS One. Sep 15, 2023;18(9):e0291572. [FREE Full text] [CrossRef] [Medline]
- Ferreira D, Zacarias M, Malheiros M, Ferreira P. Approaching process mining with sequence clustering: experiments and findings. In: Alonso G, Dadam P, Rosemann M, editors. Business Process Management. Berlin, Heidelberg. Springer; 2007:360-374.
- Rebuge Á, Ferreira DR. Business process analysis in healthcare environments: a methodology based on process mining. Inf Syst. Apr 01, 2012;37(2):99-116. [FREE Full text] [CrossRef]
- Najjar A, Reinharz D, Girouard C, Gagné C. A two-step approach for mining patient treatment pathways in administrative healthcare databases. Artif Intell Med. May 2018;87:34-48. [CrossRef] [Medline]
- Aspland E, Harper PR, Gartner D, Webb P, Barrett-Lee P. Modified Needleman-Wunsch algorithm for clinical pathway clustering. J Biomed Inform. Mar 2021;115:103668. [FREE Full text] [CrossRef] [Medline]
- Doan A, Halevy A, Ives Z. Chapter 4 - String matching. In: Doan A, Halevy A, Ives Z, editors. Principles of Data Integration. Waltham, MA. Morgan Kaufmann; 2012:95-119.
- Ester M, Kriegel HP, Sander J, Xu X. A density-based algorithm for discovering clusters in large spatial databases with noise. In: KDD'96: Proceedings of the Second International Conference on Knowledge Discovery and Data Mining. Menlo Park, CA. AAAI Press; Aug 02, 1996:226-231.
- Ankerst M, Breunig MM, Kriegel HP, Sander J. OPTICS: ordering points to identify the clustering structure. In: SIGMOD '99: Proceedings of the 1999 ACM SIGMOD International Conference on Management of Data. New York, NY. Association for Computing Machinery; Jun 01, 1999:49-60.
- Bobroske K, Larish C, Cattrell A, Bjarnadóttir MV, Huan L. The bird's-eye view: a data-driven approach to understanding patient journeys from claims data. J Am Med Inform Assoc. Jul 01, 2020;27(7):1037-1045. [FREE Full text] [CrossRef] [Medline]
- Clinical Classifications Software Refined (CCSR) for ICD-10-CM diagnoses. Agency for Healthcare Research and Quality. URL: https://hcup-us.ahrq.gov/toolssoftware/ccsr/dxccsr.jsp [accessed 2026-08-05]
- International Classification of Primary Care, 2nd edition (ICPC-2). World Health Organization. URL: https://www.who.int/standards/classifications/other-classifications/international-classification-of-primary-care [accessed 2026-08-05]
- Emergency care access and timeliness (HOQR), CMS ID 1244, version 1.2.000. eCQI Resource Center. URL: https://ecqi.healthit.gov/sites/default/files/ecqm/measures/CMS1244-v1.2.000-QDM.html [accessed 2026-05-14]
- Brill E, Moore RC. An improved error model for noisy channel spelling correction. In: Proceedings of the 38th Annual Meeting of the Association for Computational Linguistics. New York, NY. Association for Computational Linguistics; Oct 2000:286-293.
- Efird JT, Nielsen SS. A method to compute multiplicity corrected confidence intervals for odds ratios and other relative effect estimates. Int J Environ Res Public Health. Dec 2008;5(5):394-398. [FREE Full text] [CrossRef] [Medline]
- Lambert J, Leutenegger AL, Baudot A, Jannot AS. Improving patient clustering by incorporating structured variable label relationships in similarity measures. BMC Med Res Methodol. Mar 15, 2025;25(1):72. [FREE Full text] [CrossRef] [Medline]
- Aljohani A. Optimizing patient stratification in healthcare: a comparative analysis of clustering algorithms for EHR data. Int J Comput Intell Syst. Jul 02, 2024;17(1):173. [CrossRef]
- Nguyen HT, Phan TH, Pham LT, Pham NH. Clustering-based visualizations for diagnosing diseases on metagenomic data. Signal Image Video Process. Jun 17, 2024;18(8-9):5685-5699. [CrossRef]
- Momen N, Kendall M, Barclay S, Murray S. Using timelines to depict patient journeys: a development for research methods and clinical care review. Prim Health Care Res Dev. Feb 04, 2013;14(4):403-408. [CrossRef]
- Ledesma A, Bidargaddi N, Strobel J, Schrader G, Nieminen H, Korhonen I, et al. Health timeline: an insight-based study of a timeline visualization of clinical data. BMC Med Inform Decis Mak. Aug 22, 2019;19(1):170. [FREE Full text] [CrossRef] [Medline]
- Jiang S, Han R, Chakrabarty K, Page D, Stead WW, Zhang AR. Timeline registration for electronic health records. AMIA Jt Summits Transl Sci Proc. Jun 16, 2023;2023:291-299. [FREE Full text] [Medline]
- Yao J, Goldner E, Hochheiser H, Finan S, Levander J, Harris D, et al. Systemic anticancer therapy timelines extraction from electronic medical records text: algorithm development and validation. JMIR Bioinform Biotechnol. Sep 03, 2025;6:e67801. [FREE Full text] [CrossRef] [Medline]
- Andrew JJ, Potier J, Garcelon N, Burgun A, Vincent M. Using large language models for temporal relation extraction from pediatric clinical reports. JAMIA Open. Nov 22, 2025;8(6):ooaf121. [FREE Full text] [CrossRef] [Medline]
- Lippert SC, Xu RH, Tucker LS, DiLena DD, Rauchwerger AS, Rabbani J, et al. Patterns of intramuscular chemical sedation use for patients receiving a mental health consultation while in the emergency department. Ann Emerg Med. Jul 2026;88(1):26-35. [FREE Full text] [CrossRef] [Medline]
Abbreviations
| BH: behavioral health |
| ED: emergency department |
| EHR: electronic health record |
| EMS: emergency medical services |
| ESI: Emergency Severity Index |
| GEE: generalized estimating equation |
| ICD-10: International Classification of Diseases, Tenth Revision |
| ICD-10-CM: International Classification of Diseases, Tenth Revision, Clinical Modification |
| IRB: institutional review board |
| LOS: length of stay |
| OPTICS: ordering points to identify clustering structure |
| RR: risk ratio |
Edited by I Steenstra; submitted 09.Feb.2026; peer-reviewed by D Khezrimotlagh, D Chartash; comments to author 05.May.2026; revised version received 05.Nov.2026; accepted 11.Nov.2026; published 03.Dec.2026.
Copyright©Elizabeth Bermudez, Aidan Mullan, Sara Hevesi, Katharina Kohler, Laura Walker. Originally published in JMIR Medical Informatics (https://medinform.jmir.org), 03.Dec.2026.
This is an open-access article distributed under the terms of the Creative Commons Attribution License (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work, first published in JMIR Medical Informatics, is properly cited. The complete bibliographic information, a link to the original publication on https://medinform.jmir.org/, as well as this copyright and license information must be included.

