Skip to main content
npj Health Systems logoLink to npj Health Systems
. 2026 Jun 19;3:49. doi: 10.1038/s44401-026-00099-8

TimeX: Phenotype Onset Extraction from Clinical Narratives

Fangyi Chen 1,#, Shiyi Jiang 1,#, Quan M Nguyen 2,3, Casey N Ta 1, Kai Wang 3, Wendy K Chung 4, Chunhua Weng 1,✉
PMCID: PMC13282170  PMID: 42328682

Abstract

Disease phenotype onset is critical for timely and accurate diagnosis and clinical decision-making, yet it remains poorly characterized in the literature. Estimating phenotype onset using electronic health record (EHR) data holds promise but remains challenging. Researchers often resort to EHR documentation timestamps as proxies for phenotype onset, which can be inaccurate. Conventional natural language processing (NLP) approaches suffer from limited scalability and generalizability, and struggle to interpret implicit or vague temporal expressions. To address these gaps, we introduce TimeX, a novel open-source pipeline that leverages Llama-3.1, using instruction-based prompting for extracting phenotype onset from clinical narratives. TimeX employs a modular workflow comprising family history filtering, phenotype extraction, negation handling, and temporal information extraction to estimate phenotype onset. It yielded an average accuracy of 81.24% in timestamp extraction using 102 manually annotated clinical notes from the Columbia University Irving Medical Center, substantially outperforming all five baselines by at least 14.86%. A case study of four rare disease cohorts revealed that narrative-derived phenotype onset is more precise than that based on documentation timestamps. TimeX supports accurate and scalable phenotype onset extraction, with the potential to enable more precise disease trajectory characterization and timely disease diagnosis.

Subject terms: Computational biology and bioinformatics, Diseases, Medical research

Introduction

Electronic health record (EHR) data are a rich resource for analyzing phenotypes, identifying early risks, and supporting timely diagnosis of diseases. Traditional phenotyping efforts primarily focus on what symptoms or conditions are present, while largely overlooking when they emerge, evolve, or resolve1–4. Understanding when a phenotype first appears provides key diagnostic and prognostic insights, aiding differential diagnosis, severity assessment, and treatment planning5–7. However, extracting phenotype onset from EHRs remains a significant hurdle, as temporal information in EHRs is often implicit, inconsistently documented, and embedded within unstructured narratives8. Documentation timestamps are often used as surrogates for disease onset; however, they reflect when events are recorded rather than when they occur, introducing systematic errors that can distort event sequencing, bias time-to-event analyses, and undermine model validity9–12. Instead of relying solely on recorded timestamps, we hypothesize that temporal information extracted from narrative notes may provide a more accurate representation of the true onset and progression of patient symptoms and clinical events.

Temporal information extraction (TIE) has been a longstanding challenge in natural language processing, especially for the tasks of automatic identification and normalization of temporal expressions and their association with events in text13. Such pipelines usually perform three sequential subtasks: detecting medical events, extracting and normalizing temporal expressions, and establishing temporal relations to support chronological reasoning. Early foundational work by Zhou et al. proposed one of the first comprehensive architectures for TIE and reasoning in EHRs14. The pipeline integrated temporal tagging, event encoding, and constraint-based reasoning to model clinical narratives and continues to influence modern clinical TIE systems.

Early TIE approaches15–19 combined rule-based heuristics (e.g., regular expressions, pattern matching) with machine-learning models (e.g., conditional random fields, support vector machines). These hybrid systems achieved moderate success but required extensive feature engineering and domain-specific annotation, limiting their scalability and generalizability among different diseases and institutions. Subsequently, the emergence of deep learning and transformer-based architectures (e.g., BioBERT20, ClinicalBERT21) substantially improved performance in entity recognition and temporal relation extraction by learning contextualized representations that capture event semantics and temporal dependencies22–28. Nevertheless, these models still face persistent challenges, including the reliance on large amounts of annotated datasets, difficulty in reasoning over implicit temporal cues, and limitations in modeling long-range document-level dependencies.

Recently, large language models (LLMs) have become the most powerful tools capable of performing diverse tasks, including text summarization, text generation, and question answering29–31. There have been some studies that leverage LLMs to extract phenotypes or medical concepts from clinical narratives32–34. However, using LLMs for TIE has not received much attention. Despite their success across general-domain applications, it remains unclear how effectively LLMs can identify, interpret, and reason over the ambiguous and context-dependent temporal expressions in clinical text.

In this paper, we present TimeX, a lightweight, LLM-based pipeline for extracting phenotype onset from clinical narratives. Although current knowledge bases such as Human Phenotype Ontology (HPO)35 incorporate information on phenotype onset from existing literature, they remain scarce (only 1.2% of the phenotypic abnormality annotations had onset information36) and lack the fine-grained temporal granularity necessary for comprehensive clinical interpretation or modeling. To the best of our knowledge, TimeX is the first open-source, portable, end-to-end system specifically designed for temporal phenotype onset extraction. Our proposed system, TimeX, as shown in Fig. 1, consists of the following key modules: (1) data preprocessing, (2) phenotype extraction, (3) temporal expression extraction and normalization, and (4) phenotype onset estimation. In a case study, we applied TimeX to four rare disease cohorts to characterize systematic discrepancies between phenotype onset times estimated from narrative text and corresponding documentation timestamps. These findings show that using clinical narratives to extract onset information can more accurately approximate true clinical timelines. Through streamlining the estimation of phenotype onset at scale, TimeX contributes to more accurate disease trajectory modeling and facilitates earlier disease diagnosis.

Fig. 1. The proposed computational pipeline TimeX for temporal phenotype onset extraction.

Fig. 1

TimeX includes preprocessing, phenotype extraction, temporal extraction/normalization, and onset estimation. Clinical notes were first filtered to remove family history mentions, followed by phenotype extraction with negation detection. A large language model was used for temporal extraction and normalization for the extracted phenotypes. Lastly, we aggregated the temporal information per phenotype from available data to precisely estimate the average phenotype onset.

Results

TimeX evaluation

We reached a high level of inter-annotator agreement with Cohen’s κ of over 0.8 for all evaluations of TimeX and baselines. TimeX achieved 97.06% accuracy (precision: 1.0, recall/sensitivity: 0.92, F1 score: 0.96, and specificity: 1.0) for family history exclusion and 81.24% (95% CI: 78.49–83.87%) accuracy for phenotype onset extraction using truncated clinical notes, and 84.07% (95% CI: 81.32–86.4%) accuracy for phenotype onset extraction when applied to full-length notes. The configuration combining text truncation with instruction-based prompting (hidden chain-of-thought (CoT)) showed a slight performance advantage over the alternative. TimeX achieved 82.92% accuracy (precision: 0.76, recall: 0.74, and F1 score: 0.75) in extracting verbatim time expressions. By comparison, the Llama-3.1-based baseline achieved only 32.35% accuracy (precision: 0.22, recall/sensitivity: 1.0, F1 score: 0.36, and specificity: 0.17) for family history removal (Supplementary Table 5) and 19.27% (95% CI: 16.8–21.64%) accuracy for phenotype onset timestamp extraction—far below TimeX. Similarly, the performance of SUTime and other LLM-based baselines was significantly lower than that of TimeX, shown in Fig. 2a. Runtime comparisons (Fig. 2b) showed substantially faster execution of TimeX compared with baselines. Module-level analysis revealed that most of the computational time was concentrated in the temporal expression extraction and normalization component (4.38 s per note), while the family history filtering module required only 0.47 s per note, and phenotype extraction was highly efficient at 0.023 s per note (Fig. 2c). The results demonstrated that TimeX maintained an efficient overall runtime, averaging 4.87 s per narrative note.

Fig. 2. Performance comparison and runtime estimate of TimeX.

Fig. 2

a Performance comparison between the proposed TimeX and baselines. TimeX (rare) refers to the additional evaluation of TimeX on the subset of rare disease cohorts. b Average runtime estimate for temporal expression extraction and normalization across TimeX and baseline approaches. c Runtime estimate breakdown by TimeX module. Note: All experiments were performed using a single NVIDIA L40S GPU (46 GB VRAM). No tensor parallelism or multi-GPU acceleration was employed. Runtime per note was estimated based on an average of 3.5 phenotypes per note, as observed in the validated dataset.

We performed a detailed error analysis of TimeX using truncated clinical notes and identified three main error categories (Table 1). Most errors came from TimeX’s difficulty capturing context across sentences. For example, it often failed to link a phenotype in one sentence to a time expression in another, more distant sentence, or to match each phenotype to its corresponding time when multiple phenotypes appeared in the same sentence. TimeX also occasionally made arithmetic mistakes when calculating exact dates (e.g., subtracting “one month before” from a reference date). Finally, we observed a small number of reasoning errors, where TimeX inferred the wrong reference time.

Table 1.

Distribution of major error types

Error type Frequency (%)
Contextual misinterpretation (wrong original time expression found) 75.9 (N = 88)
Arithmetic error 18.1 (N = 21)
Reasoning error (wrong reference time inferred) 6 (N = 7)

N represents the number of error cases.

Case study on rare disease cohorts

Hundreds of millions of people worldwide suffer from rare diseases that often cause chronic morbidity, significantly reducing the quality of life37,38. Individuals with rare diseases often experience prolonged diagnostic delays, typically with an average of 5 years between symptom onset and confirmed diagnosis, and a substantial proportion of patients remain undiagnosed. Early identification of phenotypic manifestations is thus crucial in streamlining rare disease diagnosis and optimizing subsequent clinical management. In this study, we applied TimeX to four rare disease cohorts as a case study to demonstrate its robustness in identifying phenotype onset timestamps and its potential to improve rare disease diagnosis and management.

We focused on rare diseases that emerge or are typically diagnosed only after adulthood. Four rare diseases were selected for investigation of their phenotype onsets due to their urgent need for early diagnosis and reduction in misdiagnosis and delayed diagnosis, including Behcet syndrome, Pulmonary Arterial Hypertension (PAH), Fabry disease, and Whipple’s disease39–42. Detailed definitions of the four rare disease cohorts are provided in Supplementary Data 1–4.

For the cohort of Behcet syndrome, we selected all clinical notes that fall into the top 15 note types (e.g., Surgical Path Event, Follow-up Visit, and Letter) that contain the most frequent occurrence of phenotypes based on prior literature43. A full list of selected note types is detailed in Supplementary Table 4. For the PAH cohort, we limited the selection to a maximum of five notes per patient, drawn from the top five note-type categories to reduce computational burden. All available notes were included for Fabry and Whipple’s disease cohorts due to the small sample size.

The demographic characteristics of the four cohorts are presented in Table 2. Among the four cohorts, the PAH cohort included the largest number of patients and clinical notes, comprising 9363 patients with a total of 24,700 notes. A substantial heterogeneity in diagnostic onset was observed in all cohorts, with a standard deviation of diagnosis above 17 years. A noticeable portion of patients had missing self-reported race and ethnicity information (Table 2).

Table 2.

Demographics of Behcet syndrome, Pulmonary Arterial Hypertension (PAH), Fabry disease, and Whipple’s disease cohorts

Behcet syndrome (N = 197) PAH (N = 9363) Fabry disease (N = 103) Whipple’s disease (N = 63)
Number of notes 1656 24,700 3763 2371
Age (Mean ± SD) 46.4 ± 18.0 66.1 ± 23.2 43.4 ± 21.6 70.8 ± 19.9
Age at diagnosis derived from condition start timestamps (Mean ± SD) 37.2 ± 17.2 57.5 ± 24.1 39.7 ± 20.5 58.6 ± 18.8
Sex [number of individuals (%)] Male 63 (31.98%) 4740 (50.62%) 55 (53.4%) 25 (39.68%)
Female 134 (68.02%) 4622 (49.36%) 48 (46.6%) 38 (60.32%)
Unknown - 1 (0.01%) - -
Self-reported Race [number of individuals (%)] American Indian or Alaska Native - 22 (0.23%) - -
Asian 8 (4.06%) 262 (2.79%) 24 (23.3%) 3 (4.76%)
Black 16 (8.12%) 1480 (15.8%) 10 (9.71%) 3 (4.76%)
Native Hawaiian or Other Pacific Islander 1 (0.51%) 31 (0.33%) - -
Other Race - 10 (0.1%) - -
Unknown 82 (41.63%) 3132 (33.44%) 28 (27.18%) 30 (47.62%)
White 90 (45.69%) 4426 (47.27%) 41 (39.81%) 27 (42.86%)
Self-reported Ethnicity [number of individuals (%)] Hispanic or Latino 50 (25.38%) 1671 (17.84%) 11 (10.68%) 9 (14.29%)
Unknown 54 (27.41%) 2385 (25.47%) 19 (18.45%) 18 (28.57%)
Not Hispanic or Latino 93 (47.21%) 5307 (56.68%) 73 (70.87%) 36 (57.14%)

To ensure that TimeX performs at the same accuracy level on rare disease cohorts, we randomly sampled 30 narrative notes from each cohort, resulting in a total of 120 notes and 113 distinct phenotypes. TimeX achieved an accuracy of 85.87% (precision: 0.81, recall: 0.62, and F1 score: 0.7) in temporal expression extraction and an accuracy of 83.39% (95% CI: 79.15–87.29%) in temporal expression normalization. Based on the results, TimeX showed consistent performance of TIE and normalization in rare disease cohorts.

Across the four cohorts shown in Fig. 3, we observed that approximately 75-85% phenotype terms extracted from clinical narratives lacked temporal information. Among terms with temporal attributes, times were mainly expressed implicitly, such as “2 weeks ago” and “several months ago.” A limited number of timestamps were expressed explicitly but may also lack the granularity needed for disease progression modeling, such as “in 2015” and “in Sep 2010.” The significant amount of relative time expressions within the notes suggested that it is imperative to extract and reason for phenotype onset information instead of relying on the documentation timestamps. In the next section, we present the analysis on normalized phenotype onset timestamps extracted from note narratives using the proposed TimeX.

Fig. 3. Distribution of phenotype time expressions among four rare diseases.

Fig. 3

Between 75% and 85% of temporal information is missing in clinical notes. Note: Explicit timestamp refers to a particular mention of a year, month, or day, whereas implicit timestamp refers to a relative time expression, such as “several days ago,” “recently.” In addition, we included only disease-associated terms based on HPO and Open Real-world based Annotation for Rare Diseases (OARD) as external knowledge sources (Supplementary Data 5 and 6).

Estimated phenotype onset appears earlier than documentation times

We consistently observed differences between phenotype onsets derived from note narratives and those based on note documentation times across cohorts. As illustrated in Fig. 4, among phenotypes that had temporal attributes, 45% of them had estimated onsets occurring more than 1 year before their documented onsets. For the Behcet syndrome, PAH, and Fabry disease cohorts, the mean onsets extracted from note narratives were generally more than 1 year earlier than those obtained from documentation times, except for diarrhea in Fabry disease (Supplementary Data 7–10). Notably, some phenotypes, such as arthralgia, chronic pulmonary obstruction, hypertension, stroke, proteinuria, and congestive heart failure, exhibited onsets from note narratives that preceded documentation-based estimates by at least 4 years, while phenotypes associated with Whipple’s disease showed relatively smaller differences (within 2 years) between the two estimation methods.

Fig. 4. Differences between estimated and documented phenotype onsets across age phases.

Fig. 4

Most phenotypes in all four cohorts had estimated onsets occurring at least 1 year before the documentation times. For instance, 59.57% of phenotypes in the Behcet cohort had estimated onsets at least 1 year earlier than the documentation times.

Statistical tests revealed significant differences (p value < 0.001) between phenotype onsets estimated from narrative notes and those obtained from documentation timestamps (Fig. 5). Similar significance was observed when comparing documentation-based and aggregated estimates. Furthermore, to explore the potential temporal patterns between phenotype onset and disease diagnosis, we examined the relative onset of phenotype compared to average diagnosis ages across cohorts. As shown in Fig. 5, most phenotypes associated with Behcet syndrome, Whipple’s disease, and PAH generally showed mean onsets at least 2 years earlier than the average diagnosis ages, whereas this pattern was observed for only one phenotype (nephropathy) in the Fabry disease cohort.

Fig. 5. Results of the Friedman test followed by Dunn’s test on comparisons of phenotype onsets of all four cohorts obtained from different sources.

Fig. 5

Clinically significant phenotypes associated with a Behcet syndrome; b Pulmonary arterial hypertension; c Fabry disease; d Whipple disease. Both aggregated onset estimates (Best-estimate) and narrative-extracted onsets (MentionTime) showed significant differences compared with documentation times (DocTime). P value: *0.05; **0.01; ***0.001

Discussion

In this study, we developed and evaluated an open-source, LLM-based temporal phenotype extraction pipeline that accurately identifies and normalizes temporal information of phenotypes from clinical notes. TimeX significantly outperformed the baseline. It effectively retained only the patient’s medical conditions by removing family history, achieving precise phenotype extraction. In contrast, the baseline frequently mistaken family history as the patient’s own conditions, leading to false positives. It also showed limited ability to infer implicit temporal expressions, often defaulting to the documentation datetime. We evaluated the performance of TimeX on extracting explicit timestamps such as “in 2005” and “on 02/08/15,” and implicit timestamps such as “2 days ago” and “over a week.” TimeX achieved an accuracy of 78.38% (95% CI: 64.8–91.89%) in extracting explicit temporal expressions and 70.31% (95% CI: 64.19–75.98%) accuracy for implicit timestamp extraction. Moreover, the baseline model constantly fabricated timestamps even when no associated temporal information was present in the text.

Additionally, we observed that the lightweight LLMs have difficulty in interpreting lengthy, complex clinical narratives when identifying the temporal expressions associated with a specific phenotype. This echoes a well-known issue: LLMs struggle with long contexts. To systematically evaluate this effect, we performed additional experiments to assess the impact of note length on the performance of TimeX. Clinical notes were stratified into short- and long-text groups using multiple character-length thresholds, and performance in TIE and normalization was evaluated across these strata (Supplementary Fig. 1). TimeX demonstrated improved performance on notes shorter than 3000 characters compared to longer notes, suggesting that the segmentation-based approach effectively reduces irrelevant information and enhances model focus. However, this strategy did not yield additional performance gain for notes shorter than 2500 characters, indicating a limitation in capturing cross-sentence event–time relationships when relevant temporal cues extend beyond the selected local context or require additional contextual information for accurate inference. Future work will focus on more advanced methods for identifying temporally relevant spans across entire documents, including intra-document retrieval strategies44 that prioritize semantically relevant sentences while preserving temporally informative evidence distributed across distant text segments. In parallel, we will investigate task-aware summarization approaches, such as phenotype- and temporally conditioned summarization to generate compact representations of clinically salient information while maintaining critical event–time relationships. These representations may improve both the accuracy and efficiency of TIE and normalization. While further refinement is needed, this study establishes an important foundation for automated temporal phenotype extraction and demonstrates the feasibility of leveraging LLMs to capture complex temporal patterns in clinical narratives.

Besides its demonstrated performance and portability, TimeX offers a robust foundation for temporal phenotyping for diverse diseases, enabling more accurate disease characterization, better understanding of disease trajectories, earlier diagnosis, and improved patient care. Our analysis revealed notable discrepancies between documentation time in both structured data and narratives and phenotype onset estimated from narratives, indicating that documentation timestamps alone may underestimate phenotype onset. Incorporating temporal information from unstructured clinical narratives can thus improve onset estimation and potentially facilitate accurate modeling of disease progression. In rare diseases, where diagnostic delays are common due to heterogeneous symptoms and limited awareness, TimeX identified several phenotypes appearing prior to formal diagnosis, suggesting their potential as early indicators. For instance, oral ulcer and skin rash typically emerge over 5 years before the average diagnosis age of Behcet syndrome45. Recognizing such early features could meaningfully accelerate diagnosis and mitigate disease progression risk.

Despite the promising performance of LLMs in temporal phenotyping, several challenges remain. Much of the phenotype onset information is implicitly stated or missing in clinical notes, leading to uncertainty in estimating onset times. Although we integrated complementary data sources such as structured EHR fields and note timestamps to address this issue, future work could incorporate additional modalities, such as laboratory results, encounter details, and medication records, to further improve temporal estimation. This finding should be interpreted with caution, as the observation that narrative-derived onset times may be more precise than documentation timestamps was supported by validation on a limited subset of cases. Larger-scale evaluation with rigorously annotated ground truth is needed to confirm its generalizability and robustness. Lastly, further evaluation on downstream tasks such as disease prediction is needed to assess the clinical utility of TimeX in the real-world setting.

We present TimeX, a generalizable, LLM-based pipeline for identifying temporal phenotype onset information from clinical narratives. Using four rare disease cohorts, we consistently observed that the onset information extracted from clinical notes is more accurate than documentation timestamps. TimeX demonstrates strong accuracy in phenotype onset extraction. Further fine-tuning of LLMs and investigation of phenotype-specific temporal patterns are needed to advance insights into disease progression over time.

Methods

The study was approved by Columbia University Irving Medical Center (CUIMC) Institutional Review Board under protocol number AAAR3954. Data used in this study were obtained from the Observational Medical Outcomes Partnership database at CUIMC, which contains structured and unstructured EHRs of all patients from 1985 to 2025.

Data preprocessing

To avoid confounding phenotype extraction with hereditary context, sentences describing family history were removed from the raw clinical notes (e.g., “father with asthma and myocardial infarction”) using the Llama-3.1-8B-Instruct model46. The model was guided through a step-by-step instruction process with an explicit definition of family history in the clinical context and detailed guidance for locating relevant content, as provided in Supplementary Table 1. After filtering family history, the remaining content of each note was then passed to the following phenotype extraction module for further processing.

Phenotype extraction

After family history removal, we extracted phenotypes from processed clinical narratives. For this task, we adopted PhenoBERT23, a state-of-the-art transformer-based model designed for phenotype extraction and normalization to HPO35. PhenoBERT demonstrated strong performance in identifying phenotype mentions across diverse clinical narratives while maintaining computational efficiency23. Phenotype negation detection was performed using the trained BERT-based model from Aken et al.47, which effectively distinguishes affirmed from negated clinical concepts. Additionally, an optional post-process step can be implemented to filter non-targeted phenotypes by leveraging external knowledge bases (e.g., HPO or curated disease-phenotype resources43) to select desired phenotypes for downstream analyses. For instance, scleroderma extracted by PhenoBERT from notes will be excluded if the desired cohort is patients with Behcet syndrome, as scleroderma is not associated with Behcet syndrome according to HPO.

Temporal expression extraction and normalization

This module is intended to identify and normalize temporal expressions that are explicitly or implicitly associated with phenotypes mentioned in clinical narratives. For this task, we employed the Llama-3.1-8B-Instruct foundation model46. Two implementation strategies were developed. In the first approach, the full-length clinical text was used as the input alongside the corresponding HPO terms. Temporal extraction was guided through an instruction-based prompting pipeline to detect and normalize time expressions associated with phenotypes.

In the second approach, we extracted a specific segment from the clinical text for each HPO term. Each segment was then processed using an instruction-based prompt combined with a hidden CoT strategy, in which the model was guided through sequential reasoning steps to locate relevant temporal expressions, estimate timestamps from the expressions, and normalize timestamps into a standardized format. To generate these segments, we extracted text spans corresponding to individual HPO phenotype terms. Specifically, for each clinical note, we first located all target sentences that contain the target HPO term. We then extracted each of the target sentences along with its preceding three sentences and its following two sentences as the desired segment of the note. Formally, we present the definition of the target segment of clinical note S in the following: for each phenotype occurrence identified at the ith sentence Si of the clinical note, we construct the following segment S as the input of the model, S=Si−3,Si−2,Si−1,Si,Si+1,Si+2. This truncation strategy was designed to mitigate the potential lost-in-the-middle problem48, where LLMs tend to underperform when processing lengthy clinical notes with relevant temporal cues scattered across multiple sentences. We believe this strategy can preserve the necessary temporal context while minimizing irrelevant information, thereby facilitating more accurate temporal estimation.

The extracted timestamps were subsequently normalized to the ISO 8601 format (YYYY-MM-DD) to ensure consistency in phenotype onset estimation across downstream analyses. Temporal expressions in clinical narratives often vary in both format and granularity; thus, we established a set of normalization rules to standardize them. Specifically, explicit temporal expressions referring to a particular month or year were normalized to the first day of the month or year. For instance, the expression “in March 2010” was normalized to 2010-03-01, and the expression “in 2015” was converted to 2015-01-01. Relative time expressions, such as “2 weeks ago” and “a few months ago,” were converted into normalized timestamps according to the rules summarized in Table 3. If there is no time expression associated with the HPO term, the model will output “not stated.” Note that if an HPO term appeared in multiple sentences, TimeX will identify all associated timestamps and output the earliest one.

Table 3.

Normalization rules for relative time expressions extracted from clinical notes

Relative time expression Conversion logic
“x weeks ago” x times 7 days prior to the referenced date
“x months ago” x times 30 days prior to the referenced date
“x years ago” x times 365 days prior to the referenced date
“several days ago” within 5 days prior to the referenced date
“several weeks/months/years ago” or “since past few weeks/months/years” within 3 weeks/months/years from the referenced date
“many days/weeks/months/years ago” within 5 days/weeks/months/years from the referenced date
“recently” within 2 weeks from the referenced date
“currently/present” note datetime
“past/chronic” phenotype onset not stated

“x” can be replaced by any arbitrary integer. The referenced date is defined as a date inferred from the context that serves as an anchor date to determine the exact date of a relative time expression.

All prompts for family history removal, phenotype timestamp extraction, and normalization were provided in Supplementary Tables 1–3. All experiments were conducted on a Health Insurance Portability and Accountability Act-compliant computational platform with four NVIDIA GeForce RTX 2080 Ti, each with 11 GB of memory. Hugging Face platform, Ollama platform, and the PyTorch library were major tools for experiment execution49–51.

Workflow evaluation

To ensure the accuracy of the proposed workflow, we conducted a manual evaluation for two key components: (1) the accuracy, precision, recall (sensitivity), F1 score, and specificity of identifying and removing sentences describing family history, (2) the accuracy, precision, recall (sensitivity), F1 score, and specificity of temporal expression extraction at the span-level, and (3) the accuracy with 95% confidence interval (CI) of the extracted timestamps in the specified normalized format associated with phenotype mentions. The evaluation was performed on 102 randomly sampled clinical notes from the CUIMC database. A total of 357 distinct phenotypes were identified from these notes. Two researchers (SJ and FC) each independently reviewed all notes and assessed the precision of outputs yielded from the two variations of TimeX, following the criteria defined in Table 3. Cohen’s κ was computed to assess the agreement between the two annotators, presented in Supplementary Table 7.

Accuracy is the proportion of system outputs that exactly matched or were deemed equivalent to the ground truth within the original clinical text. For family history identification, outputs were labeled as incorrect if they included hallucinated content (e.g., generating “Patient’s mother had lung cancer 5 years ago,” when not present in the note) or failed to identify existing family history statements. For the timestamp normalization task, the outputs were classified as incorrect if the normalized timestamps fell outside of the defined acceptable ranges detailed in Table 3 or if timestamps were provided without supporting clinical evidence in the source text. An error analysis was conducted to categorize common failure patterns, as described in the “Results” section.

Phenotype onset estimation

Phenotype onset was estimated by integrating information from multiple sources, including condition start times recorded from structured EHR data, note documentation datetimes, and phenotype timestamps extracted from clinical narratives. Structured conditions were mapped from Systematized Nomenclature of Medicine - Clinical Terms (SNOMED-CT)52 to HPO terms using PhenoBERT. Normalized timestamps were converted to age since the date of birth. For each phenotype per patient, the earliest onset identified across the three sources was used as the final onset estimate.

Documented note datetimes were retrieved for comparison with extracted phenotype timestamps. We applied quality control measures that excluded timestamps occurring before a patient’s birthdate or after the corresponding note documentation time, as well as outliers with values in age greater than three times the standard deviation. To assess the temporal discrepancies and identify significant differences among the onset estimates from documentation-based, narrative-based, and aggregated sources, we conducted the Friedman test followed by Dunn’s post hoc pairwise test with multiple-comparison correction53,54.

Baseline model

We compared TimeX against a CoT step-by-step baseline, adapted from recent temporal question-answering work that evaluates temporal reasoning using the “when”-type template55. In this setting, a general-purpose LLM receives a list of timestamped events and a temporal query (e.g., “When was the last time [phenotype] was documented?”). Instead of relying on a series of structured events, this baseline directly uses clinical notes as input, reflecting a more realistic EHR context where temporal information is often embedded within the free-text narratives. In our study, the model received each clinical note as input along with the target phenotype and was prompted with a “when”-type temporal question (e.g., “When did the patient initially experience chest pain?”). The prompt incorporated the instruction “Let’s think step by step” to elicit sequential reasoning, guiding the model to identify relevant temporal expressions within the note, interpret their contextual meaning (e.g., symptom onset, duration, or recurrence), and normalize the inferred date to the ISO 8601 format (YYYY-MM-DD). Additionally, we compared TimeX with a standard benchmark for TIE and normalization (SUTime)56. Besides, approaches using state-of-the-art open-source LLMs (Gemma2-27B57, Mistral-7B58, and GPT-OSS-20B59) were used as baselines as well.

Ethics declaration

This study was reviewed and approved by the Institutional Review Board (IRB) of CUIMC (Protocol No. AAAR3954). All procedures involving human participants were conducted in accordance with the ethical standards of the institutional research committee and with the Declaration of Helsinki and its later amendments. Due to the retrospective nature of the study, the requirement for informed consent was waived by the IRB.

Supplementary information

Supplementary Information (66.3KB, docx)
Supplementary Data (79.5KB, xlsx)

Acknowledgements

This research was sponsored by National Institutes of Health (NIH) grants R01HG013031 and U01HG008680. The content is solely the responsibility of the authors and does not necessarily represent the official views of the NIH.

Author contributions

F.C.: conceptualization, data curation, formal analysis, investigation, methodology, software, validation, visualization, writing—original draft, writing—review and editing. S.J.: conceptualization, data curation, formal analysis, investigation, methodology, software, validation, visualization, writing—original draft, writing—review and editing. Q.M.N.: data curation, formal analysis, writing—review and editing. K.W.: resources, funding acquisition, validation, writing—review and editing. C.N.T.: conceptualization, writing—review and editing. W.K.C.: funding acquisition, validation, writing—review and editing. C.W.: conceptualization, funding acquisition, investigation, methodology, project administration, resources, supervision, validation, writing—review and editing. All authors have read and approved the manuscript.

Data availability

The datasets generated and/or analyzed during the current study are not publicly available due to protected health information restrictions.

Code availability

The underlying code for this study can be accessed via this link: https://github.com/MadGenius0118/TimeX.

Competing interests

The authors declare no competing interests.

Consent to participate declaration

This research was determined by Columbia University Irving Medical Center Institutional Review Board to qualify for a waiver of consent as per 45CFR46.116(d) as the following criteria are met in this study: (1) the research involves no more than minimal risk to the subjects, (2) the waiver or alteration will not adversely affect the rights and welfare of the subjects, and (3) the research could not practicably be carried out without the waiver or alteration.

Footnotes

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

These authors contributed equally: Fangyi Chen, Shiyi Jiang.

These authors jointly supervised this work: Kai Wang, Wendy K. Chung, Chunhua Weng.

Supplementary information

The online version contains supplementary material available at 10.1038/s44401-026-00099-8.

References

  • 1.Shivade, C. et al. A review of approaches to identifying patient phenotype cohorts using electronic health records. J. Am. Med. Inform. Assoc.21, 221–230 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 2.Son, J. H. et al. Deep phenotyping on electronic health records facilitates genetic diagnosis by clinical exomes. Am. J. Hum. Genet.103, 58–73 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Hong, N. et al. Developing a FHIR-based EHR phenotyping framework: a case study for identification of patients with obesity and multiple comorbidities from discharge summaries. J. Biomed. Inform.99, 103310 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Yang, S., Varghese, P., Stephenson, E., Tu, K. & Gronsbell, J. Machine learning approaches for electronic health records phenotyping: a methodical review. J. Am. Med. Inform. Assoc.30, 367–381 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Liu, C., Wang, F., Hu, J., & Xiong, H. Temporal phenotyping from longitudinal electronic health records: A graph based framework. In Proceedings of the 21th ACM SIGKDD international conference on knowledgediscovery and data mining 705-714 (2015).
  • 6.Kim, Y., Lhatoo, S., Zhang, G.-Q., Chen, L. & Jiang, X. Temporal phenotyping for transitional disease progress: an application to epilepsy and Alzheimer’s disease. J. Biomed. Inform.107, 103462 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 7.O’riordan, S. et al. Age at onset as a factor in determining the phenotype of primary torsion dystonia. Neurology63, 1423–1426 (2004). [DOI] [PubMed] [Google Scholar]
  • 8.Estiri, H., Strasser, Z. H. & Murphy, S. N. High-throughput phenotyping with temporal sequences. J. Am. Med. Inform. Assoc.28, 772–781 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Hou, J., Chan, S. F., Wang, X. & Cai, T. Risk prediction with imperfect survival outcome information from electronic health records. Biometrics79, 190–202 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Ford, E. et al. What evidence is there for a delay in diagnostic coding of RA in UK general practice records? An observational study of free text. BMJ Open6, e010393 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Schulz, W. L. et al. Temporal relationship of computed and structured diagnoses in electronic health record data. BMC Med. Inform. Decis. Mak.21, 61 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Gai, X., Jiang, S. & Zhang, A. R. Subtype-aware registration of longitudinal electronic health records. J. Am. Stat. Assoc.1, 21 (2026). [Google Scholar]
  • 13.Leeuwenberg, A. & Moens, M.-F. A survey on temporal reasoning for temporal information extraction from text. J. Artif. Intell. Res.66, 341–380 (2019). [Google Scholar]
  • 14.Zhou, L., Friedman, C., Parsons, S., & Hripcsak, G. System architecture for temporal information extraction, representation and reasoning in clinical narrative reports. In AMIA Annual Symposium Proceedings Vol. 2005, 869. (2005). [PMC free article] [PubMed]
  • 15.Tang, B. et al. A hybrid system for temporal information extraction from clinical text. J. Am. Med. Inform. Assoc.20, 828–835 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Xu, Y., Wang, Y., Liu, T., Tsujii, J. & Chang, E. I. An end-to-end system to identify temporal relation in discharge summaries: 2012 i2b2 challenge. J. Am. Med. Inform. Assoc.20, 849–858 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.D’Souza, J. & Ng, V. Classifying temporal relations in clinical data: a hybrid, knowledge-rich approach. J. Biomed. Inform.46, S29–S39 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Roberts, K., Rink, B. & Harabagiu, S. M. A flexible framework for recognizing events, temporal expressions, and temporal relations in clinical text. J. Am. Med. Inform. Assoc.20, 867–875 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19.Sohn, S. et al. Comprehensive temporal information detection from clinical text: medical events, time, and TLINK identification. J. Am. Med. Inform. Assoc.20, 836–842 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Lee, J. et al. BioBERT: a pre-trained biomedical language representation model for biomedical text mining. Bioinformatics36, 1234–1240 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Huang, K., Altosaar, J. & Ranganath, R. ClinicalBERT: modeling clinical notes and predicting hospital readmission. Preprint at arXiv10.48550/arXiv.1904.05342 (2019).
  • 22.Habibi, M., Weber, L., Neves, M., Wiegandt, D. L. & Leser, U. Deep learning with word embeddings improves biomedical named entity recognition. Bioinformatics33, i37–i48 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Feng, Y., Qi, L. & Tian, W. PhenoBERT: a combined deep learning method for automated recognition of Human Phenotype Ontology. IEEE/ACM Trans. Comput. Biol. Bioinform.20, 1269–1277 (2022). [DOI] [PubMed] [Google Scholar]
  • 24.Sun, C. et al. Biomedical named entity recognition using BERT in the machine reading comprehension framework. J. Biomed. Inform.118, 103799 (2021). [DOI] [PubMed] [Google Scholar]
  • 25.Lin, C., Miller, T., Dligach, D., Bethard, S., & Savova, G. Representations of time expressionsfor temporal relation extraction with convolutional neural networks. In BioNLP2017 322−327 (2017).
  • 26.Dligach, D., Miller, T., Lin, C., Bethard, S. & Savova, G. Neural temporal relation extraction. In Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics Vol 2, Short Papers 746–751 (2017).
  • 27.Tourille, J., Ferret, O., Neveol, A., & Tannier, X. Neural architecture for temporal relation extraction: A Bi-LSTM approach for detecting narrative containers. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics Vol 2, Short Papers 224–230 (2017).
  • 28.Lin, C., Miller, T., Dligach, D., Bethard, S. & Savova, G. A BERT-based universal model for bothwithin-and cross-sentence clinical temporal relation extraction. In Proceedings of the 2nd clinical natural language processing workshop 65–71 (2019).
  • 29.Yang, J. et al. Harnessing the power of LLMs in practice: a survey on ChatGPT and beyond. ACM Trans. Knowl. Discov. Data18, 160 (2024).
  • 30.Minaee, S. et al. Large language models: a survey. Preprint at 10.48550/arXiv.2402.06196 (2025).
  • 31.Chang, Y. et al. A survey on evaluation of large language models. ACM Trans. Intell. Syst. Technol. 15, 39 (2024).
  • 32.Yang, J. et al. Enhancing phenotype recognition in clinical notes using large language models: PhenoBCBERT and PhenoGPT. Patterns5, 100887 (2024). [DOI] [PMC free article] [PubMed]
  • 33.Luo, L. et al. PhenoTagger: a hybrid method for phenotype concept recognition using Human Phenotype Ontology. Bioinformatics37, 1884–1890 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Groza, T. et al. An evaluation of GPT models for phenotype concept recognition. BMC Med. Inform. Decis. Mak.24, 30 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 35.Gargano, M. A. et al. The Human Phenotype Ontology in 2024: phenotypes around the world. Nucleic Acids Res52, D1333–D1346 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 36.Gargano, MA., Matentzoglu, N. & Coleman, B. et al. The Human Phenotype Ontology in 2024: phenotypes aroundthe world. Nucleic Acids Res52, D1333–D1346, 10.1093/nar/gkad1005 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37.Marwaha, S., Knowles, J. W. & Ashley, E. A. A guide for the diagnosis of rare and undiagnosed disease: beyond the exome. Genome Med.14, 23 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 38.Pogue, R. E. et al. Rare genetic diseases: update on diagnosis, treatment and online resources. Drug Discov. Today23, 187–195 (2018). [DOI] [PubMed] [Google Scholar]
  • 39.de Belen, E. et al. Gaps in the care of pulmonary hypertension: a cross-sectional patient simulation study among practicing cardiologists and pulmonologists. J. Am. Heart Assoc.12, e026413 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40.Melas, N., Amin, R., Gyllemark, P., Younes, A. H. & Almer, S. Whipple’s disease: the great masquerader—a high level of suspicion is the key to diagnosis. BMC Gastroenterol.21, 128 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 41.Reisin, R., Perrin, A. & García-Pavía, P. Time delays in the diagnosis and treatment of Fabry disease. Int. J. Clin. Pract.71, e12914 (2017). [DOI] [PubMed] [Google Scholar]
  • 42.Izzedine, H. & Jhaveri, K. D. Behçet’s syndrome. N. Engl. J. Med.390, 1731 (2024). [DOI] [PubMed] [Google Scholar]
  • 43.Liu, C. et al. OARD: Open annotations for rare diseases and their phenotypes based on real-world data. Am. J. Hum. Genet.109, 1591–1604 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 44.Soni, J. A., Anand, A., Pandey, R. K. & Soni, A. A. Dynamic context tuning for retrieval-augmented generation: enhancing multi-turn planning and tool adaptation. Preprint at arXiv10.48550/arXiv.2506.11092 (2025).
  • 45.McHugh, J. Different phenotypes identified for Behçet syndrome. Nat. Rev. Rheumatol.17, 188–188 (2021). [DOI] [PubMed] [Google Scholar]
  • 46.Grattafiori, A. et al. The Llama 3 herd of models. Preprint at 10.48550/arXiv.2407.21783 (2024).
  • 47.van Aken, B. et al. Assertion detection in clinical notes: medical language models to the rescue? In Proc. Second Workshop on Natural Language Processing for Medical Conversations (eds Shivade, C. et al.) 35–40. 10.18653/v1/2021.nlpmc-1.5 (Association for Computational Linguistics, 2021).
  • 48.Liu, N. F. et al. Lost in the Middle: How language models use long contexts. Trans. Assoc. Comput. Linguist.12, 157–173 (2024). [Google Scholar]
  • 49.Wolf, T. et al. HuggingFace’s transformers: state-of-the-art natural language processing. Preprint at 10.48550/arXiv.1910.03771 (2020).
  • 50.Ollama. Ollama—run large language models locally. GitHub repository, GitHub (2023).
  • 51.Paszke, A. et al. PyTorch: an imperative style, high-performance deep learning library. In Proc. 33rd International Conference on Neural Information Processing Systems (Curran Associates Inc., 2019).
  • 52.De Silva, T. S., MacDonald, D., Paterson, G., Sikdar, K. C. & Cochrane, B. Systematized nomenclature of medicine clinical terms (SNOMED CT) to represent computed tomography procedures. Comput. Methods Prog. Biomed.101, 324–329 (2011). [DOI] [PubMed] [Google Scholar]
  • 53.Friedman, M. The use of ranks to avoid the assumption of normality implicit in the analysis of variance. J. Am. Stat. Assoc.32, 675–701 (1937). [Google Scholar]
  • 54.Dunn, O. J. Multiple comparisons among means. J. Am. Stat. Assoc.56, 52–64 (1961). [Google Scholar]
  • 55.Kenneweg, S., Deigmöller, J., Cimiano, P. et al. TRAVELER: A Benchmark for Evaluating Temporal Reasoning Across Vague, Implicit and Explicit References. SN COMPUT. SCI. 7, 379 10.1007/s42979-026-04973-y (2025).
  • 56.Chang, Angel X., and Christopher D. Manning. Sutime: A library for recognizing and normalizing time expressions. Lrec. Vol. 12 (2012).
  • 57.Riviere, M. et al. Gemma 2: Improving open language models at a practical size. Preprint at arXiv10.48550/arXiv.2408.00118 (2024).
  • 58.Jiang, A. Q. Mistral 7B. Preprint at arXiv10.48550/arXiv.2310.06825 (2023).
  • 59.Agarwal, S. et al. gpt-oss-120b & gpt-oss-20b Model Card. Preprint at arXiv10.48550/arXiv.2508.10925 (2025).

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary Information (66.3KB, docx)
Supplementary Data (79.5KB, xlsx)

Data Availability Statement

The datasets generated and/or analyzed during the current study are not publicly available due to protected health information restrictions.

The underlying code for this study can be accessed via this link: https://github.com/MadGenius0118/TimeX.


Articles from npj Health Systems are provided here courtesy of Nature Publishing Group

RESOURCES