## 3 Materials and Methods
### Components of the NLP-Extracted ECOG PS Variable  
A regular-expression-based NLP algorithm was developed to scan through unstructured EHR documents (including oncology clinic visit notes, nursing notes, radiology reports, pathology reports, and other uncategorized documents) and extract ECOG PS score values, numeric (e.g., '0') or non-numeric (e.g., 'zero' or 'PS0'), within three words of a set of signifiers ('ECOG', 'ECOG PS', 'Performance', or 'Performance Status') (Figure 1).  
As inputs, the extraction algorithm receives all eligible documents in a patient's treatment window (described below), and the regular expression is run across the full  
Figure 1: NLP algorithm approach to the extraction of ECOG PS scores from unstructured data sources. 1. Select relevant documents within treatment window (~30 to +7 days); 2. Search for terms such as ”ECOG” or ”performance” within three words of the numbers 0–5, in numeral or word form; 3. Apply a regular expression to parse the ECOG PS score; 4. Identify the extracted score qualifying as the patient’s ECOG PS score.  
text contents of each document. Each extracted ECOG PS score is tethered to the date of the document from which it was extracted. Through a process of manual and automated review, the base regular expression was adjusted to incorporate observed Optical Character Recognition (OCR) errors and common, alternative clinical documentation patterns not already captured, as well as made robust to erroneous ECOG-like documentation patterns not related to performance status or indicative of boiler plate text. We iteratively developed several optimizations to ensure that any form of a number (e.g., both underlined and not underlined numeric values) is picked up by the algorithm, but that numbers or dates that start with ECOG PS-like values are not mistakenly assigned as ECOG PS values [50]. The regular expression and heuristics for safe ECOG extraction were tuned across multiple held-out patient sets, with no overlap with the testing cohorts on which the approach was subsequently validated.  
The categorizations by the algorithm classify patients into the following strata: PS0, PS1, PS2, PS3, and unknown. PS4 is not categorized but grouped into the unknown category due to the rare prevalence and expected resulting low performance of the algorithm. PS5 (patient deceased) is not categorized given mortality is rarely documented this way and such patients are not eligible for treatment. We anchored the extraction of ECOG PS scores to the initiation of a treatment line (period between 30 days prior through 7 days after) for a given patient. We considered this time window most clinically relevant, as ECOG PS is used to inform clinical intervention decisions. Furthermore, we allowed for ECOG PS scores up to 7 days after treatment initiation to improve completeness while taking into account lags in documentation ingestion around the time of treatment initiation. When multiple ECOG PS scores were extracted during a relevant treatment initiation window, the one closest to the treatment line index date was selected (in cases needing tie-break, scores from pre-initiation dates were selected). Demographic descriptions were generated using distinct patient, cancer-type combinations and do not reflect the number of treatment lines.