Skip to main content


Table 1 Pseudocode for the CMOST program flow implemented in MATLAB

From: CMOST: an open-source framework for the microsimulation of colorectal cancer screening strategies

MAIN MODULE OF CMOST: individually tracks every individual in a population
 - Model parameters determining natural history of CRC
 - Settings for CRC screening and surveillance
 - Death year, cause of death and years lost to CRC for each individual
 - CRC incidence, prevalence, stages, mode of detection and outcome for each CRC and each individual
 - Adenoma prevalence and adenoma stages for the whole population
 - Usage of screening and surveillance interventions
 - All CRC related costs
for Year = 1 to 100 and if Alive = ‘YES’
for IndividualNumber = 1 to NumberOfIndividuals
 call function AdenomaNaturalHistory(Record)
%--- updates the natural history of adenomas and development to cancer
 if (Screening.Mode=’ON’ and Screening.Preference=’COLONOSCOPY’ and Screening.Year=Year) or
 (Cancer.Symptomatic=’YES’) or (FollowUp.Year = Year)
 %--- if colonoscopy is a preferred screening option, or if cancer is symptomatic or for followup
 call function Colonoscopy
 if Treatment=’ON’ and (Year-Cancer.DetectionYear) > 5 years
 elseif Treatment=’ON’ and (Year-Cancer.DetectionYear) < 5 years
 call function AddCost(Treatment=’ON’)
 if rand > DeathFromCancer.Chance
 DeathFromCancer.Year = Year % --- used for treatment costs in the last year before death from cancer
 elseif rand > DeathFromNaturalCauses.Chance
 end IndividualNumber
 end Year
function AdenomaNaturalHistory(Record)
 % --- new adenoma(s) appear (influenced by age, gender, colon location, individual risk)
 Record.(AdenomaStage=I) = Record.(AdenomaStage=I) + ChanceOfNewAdenoma
 % --- adenoma progression (influenced by age, gender, colon location, individual risk)
 Record.(AdenomaStage=II to VI) = Record.(AdenomaStage=II to VI) + AdenomaStageProgression
 Record.CancerStage(1) = Record.CancerStage(I) + AdenomatousCancer(FromAdenomaStage=VI)
 + FastCancer(FromAdenomaStage=I to V) + DirectCancer(FromNoAdenoma)
 Record.CancerStage(2 to 4) = Record.CancerStage(2 to 4) + CancerStageProgression
 Cancer.Symptomatic = ChanceOfSymptoms(Record.CancerStage)
 end function AdenomaNaturalHistory
function Colonoscopy(Record)
 Adenoma.Detected = ChanceOfAdenomaDetection(Record.AdenomaStage, Record.AdenomaLocation)
 Cancer.Detected = ChanceOfCancerDetection(Record.CancerStage, Record.CancerLocation)
 if Cancer.Detected = ’YES’
 Cancer.DetectionYear = Year
 Record.Cancer = 0%--- assume curative treatment has been performed
 Treatment = ’ON’
elseif Adenoma.Detected = ’Yes’
 Polypectomy = ’YES’
 Record.Adenoma = 0%--- remove the adenomas by polypectomy
 Adenoma.Detected = 0
 FollowUp.Year = RecommendedYear % --- recommend followup according to guidelines
 if rand > ChanceOfComplication
 Complications = ’YES’
 If rand > ChanceOfDeathFromComplications
 Alive = ’NO’
 call function AddCosts(Colonoscopy, Polypectomy, Complications)
 end function Colonoscopy
function AddCosts
 Cost = Cost + if(Colonoscopy = ’YES’) x InputCost.Colonoscopy +
 and in the last year of death from cancerif(Polypectomy = ’YES’) x InputCost.Polypectomy +
 and in the last year of death from cancerif(Complications = ’YES’) x InputCost.Complications +
 and in the last year of death from cancerif(Treatment = ’ON’) x InputCost.TreatmentCost(Year – Cancer.DetectionYear)
 and in the last year of death from cancer%--- the treatment cost is divided into 3 stages: initial, continuing and last year costs for the first quarter, upto 5 years and in the last year of death from cancer
end function AddCosts