409 Background: Cancer-associated thrombosis (CAT) is preventable among high-risk individuals with prophylactic anticoagulation. Risk assessment tools focus only on the initial period after cancer diagnosis; however, some patients may face different risks during different periods of their cancer journey. We developed a longitudinal machine learning system to predict the risk of CAT throughout cancer treatment. Methods: Using electronic health record data at Princess Margaret Cancer Centre, we assembled a cohort of people with thoracic and gastrointestinal cancer receiving systemic treatments between August 1, 2017 and December 31, 2019. We manually labelled 5,000 CT scans and 500 Doppler ultrasounds for the occurrence of CAT. We fine-tuned open-source large language models (LLMs) on those labelled reports, which we then used to automatically detect CAT among all 37,000 CT scans and Dopplers. Finally, we trained longitudinal machine learning systems to predict CAT within 90 days after each cancer treatment. LLMs and the CAT risk prediction system were evaluated among the held-out test cohort of people whose first treatment occurred in 2019. Results: The overall cohort included 2,031 patients and 21,375 treatment sessions. When classifying radiology reports, the fine-tuned LLM achieved an area under the receiver operating characteristic curve (AUROC) of 0.758 for DVT and 0.988 for PE in the test cohort. CAT occurred within 90 days after 6.23% of treatment sessions. The best ML system predicted the risk of CAT within 90 days with an AUROC of 0.651 (95% CI, 0.620-0.678). Considering only the first treatment per patient, treatments within the first 90 days after the first treatment, and treatments after 90 days, the system achieved AUROC of 0.639 (95% CI, 0.568-0.704), 0.599 (95% CI, 0.559-0.642), and 0.741 (95% CI, 0.699-0.783), respectively. Conclusions: Machine learning can longitudinally predict CAT among patients receiving systemic therapy for aerodigestive cancers. These systems could personalize prophylactic anticoagulation by identifying specific periods when patients face sufficient risk to warrant prevention.