This study aims to develop and apply multistate models to estimate, forecast, and manage hospital length of stay during the COVID-19 epidemic without using any external packages. Data from Bellvitge University Hospital in Barcelona, Spain, were analyzed, involving 2285 hospitalized COVID-19 patients with moderate to severe conditions. The implemented multistate model includes transition probabilities and risk rates calculated from transitions between defined states, such as admission, ICU transfer, discharge, and death. In addition to examining key factors like age and gender, diabetes, lymphocyte count, comorbidity burden, symptom duration, and different COVID-19 waves were analyzed. Based on the model, patients hospitalized stay an average of 11.90 days before discharge, 2.84 days before moving to the ICU, or 34.21 days before death. ICU patients remain for about 24.08 days, with subsequent stays of 124.30 days before discharge and 35.44 days before death. These results highlight hospital stays’ varying durations and trajectories, providing critical insights into patient flow and healthcare resource utilization. Additionally, it can predict ICU peak loads for specific subgroups, aiding in preparedness. Future work will integrate the developed code into the hospital’s Health Information System (HIS) following ISO 13606 EHR standards and implement recursive methods to enhance the model’s efficiency and accuracy.