{"doi":"10.1093/jamiaopen/ooaf132","title":"Extracting TNFi switching reasons and trajectories from real-world data using large language models","abstract":"<h4>Background and significance</h4>To evaluate whether large language models (LLMs) can automate chart review to identify tumor necrosis factor inhibitor (TNFi) switching patterns and reasons for switching in a large real-world cohort.<h4>Materials and methods</h4>We conducted an observational study using de-identified electronic health record (EHR) data from 2012 to 2023 at a single academic medical center (University of California, San Francisco). TNFi medication orders and linked clinical notes were extracted, requiring at least 6 months of follow-up to identify treatment switches, defined as a change from one TNFi to another at consecutive encounters. Using GPT-4, we extracted which TNFi was stopped and started and classified the reason for switching. Performance was benchmarked against eight open-source LLMs, structured EHR data, and expert annotation.<h4>Results</h4>A total of 9187 patients (mean [SD] age, 39.9 [19.0] years; 57.1% female) received ≥1 TNFi with sufficient follow-up. We identified 3104 TNFi switches among 2112 patients. GPT-4 achieved micro-F1 scores of 0.75 (stopped drug), 0.80 (started drug), and 0.83 (reason). Among open-source models, Starling-7B-beta and Llama-3-8B performed most competitively. The most common reason identified by GPT-4 was lack of efficacy (56.9%), followed by adverse events (13.5%) and insurance/cost (10.8%).<h4>Conclusions</h4>Both GPT-4 and locally deployable LLMs effectively extracted complex treatment trajectories and rationale from clinical notes, supporting their broader utility in scalable EHR review and real-world evidence generation.","journal":"JAMIA Open","year":2025,"id":9673,"datarank":0.0,"base_score":0.0,"endowment":0.0,"self_citation_contribution":0.0,"citation_network_contribution":0.0,"self_endowment_contribution":0.0,"citer_contribution":0.0,"corpus_percentile":null,"corpus_rank":null,"citation_count":0,"citer_count":0,"citers_with_citation_signal":0,"citers_with_endowment":0,"datacite_reuse_total":0,"is_dataset":false,"is_dataset_confidence":0.3647,"is_data_producer":false,"deposit_databanks":null,"is_oa":true,"file_count":0,"downloads":0,"has_version_chain":false,"published_date":"2025-11-03","fair_score":null,"fair_percentile":null,"algorithm_id":"datarank_citation_only_1hop_v6","ranking_scope":"data_only","authors":[{"id":14771,"name":"Marie Binvignat","orcid":"0000-0001-7473-7636","position":1,"is_corresponding":false},{"id":58622,"name":"Maxim Bravo","orcid":null,"position":3,"is_corresponding":false},{"id":58623,"name":"Claire Q Miao","orcid":null,"position":5,"is_corresponding":false},{"id":68185,"name":"Ahmed M. Alaa","orcid":"0000-0001-9936-7141","position":6,"is_corresponding":false},{"id":700,"name":"Vivek Ashok Rudrapatna","orcid":"0000-0003-1789-3004","position":7,"is_corresponding":false},{"id":51,"name":"Atul Janardhan Butte","orcid":"0000-0002-7433-2740","position":8,"is_corresponding":false},{"id":58625,"name":"Gabriela Schmajuk","orcid":"0000-0003-2687-5043","position":9,"is_corresponding":false},{"id":24102,"name":"Jinoos Yazdany","orcid":"0000-0002-3508-4094","position":10,"is_corresponding":false},{"id":58465,"name":"Augusto García-Agúndez","orcid":"0000-0002-5440-1032","position":11,"is_corresponding":false},{"id":3412,"name":"Christopher Y. K. Williams","orcid":"0000-0001-8867-1623","position":12,"is_corresponding":false},{"id":58626,"name":"Chiyuan Miao","orcid":"0000-0001-6413-7020","position":13,"is_corresponding":false},{"id":3067,"name":"Brenda Y. Miao","orcid":"0000-0002-3393-9837","position":0,"is_corresponding":true}],"reference_count":23,"raw_metadata":null,"created_at":"2026-03-01T18:20:47.508186Z","pmid":null,"pmcid":null,"fwci":null,"citation_percentile":null,"influential_citations":0,"oa_status":null,"license":null,"views":0,"total_file_size_bytes":0,"version_count":0,"fair_f":null,"fair_a":null,"fair_i":null,"fair_r":null,"fair_zscore":null,"fair_rationale":null,"fair_model":null,"fair_agent_version":null,"fair_fulltext_source":null,"fair_has_llm":null,"fair_computed_at":null,"clinical_trials":[],"software_tools":[],"db_accessions":[],"linked_datasets":[],"topics":[]}