Example #1
0
 public string DeterminePreSurgeryStateName(BE_Patient patientIn, Random rand)
 {
     if (patientIn.ConfirmedState.Type == BE_StateType.SC)
     {
         return("SC");
     }
     else if (patientIn.ConfirmedState.Type == BE_StateType.IMC)
     {
         if (patientIn.CompletedEET == false)   //  If surgery is the first treatment the patient receives, the health state should be T1b.
         {
             return("T1b");
         }
         else if (rand.NextDouble() <= surgicalIMC)
         {
             return("T1b");
         }
         else
         {
             return("T1a");
         }
     }
     else
     {
         Console.WriteLine(new System.ComponentModel.WarningException("Cannot DeterminePreSurgeryStateName!").Message);
         return(null);
     }
 }
Example #2
0
 public void PalliativeMortality(BE_Patient patientIn, Random rand)
 {
     if (rand.NextDouble() <= mortality)
     {
         patientIn.Die("Palliative");
     }
 }
Example #3
0
 public void FollowUpSurveillanceDecision(BE_Patient patientIn, BE_Cycle cycleIn)
 {
     if (patientIn.ConfirmedState.Type == BE_StateType.IMC || patientIn.ConfirmedState.Type == BE_StateType.SC)
     {
         patientIn.NextTreatment = cycleIn.ID;
     }
     else if (patientIn.ConfirmedState.ID > patientIn.PostEETState.ID && patientIn.CompletedMaxRFA == false && patientIn.FailedEET == false)
     {
         patientIn.NextTreatment = cycleIn.ID;
     }
     else
     {
         if (patientIn.PreEETState.Type == BE_StateType.NDBE || patientIn.PreEETState.Type == BE_StateType.LGD)    //  Assumption: If there is no adherence, the follow-up intervals continue.
         {
             patientIn.NextSurveillance = cycleIn.ID + postIntervalLGD[Math.Min(patientIn.CountFollowUp, postIntervalLGD.Length - 1)];
         }
         else if (patientIn.PreEETState.Type == BE_StateType.HGD || patientIn.PreEETState.Type == BE_StateType.IMC)
         {
             patientIn.NextSurveillance = cycleIn.ID + postIntervalHGD[Math.Min(patientIn.CountFollowUp, postIntervalHGD.Length - 1)];
         }
         else
         {
             Console.WriteLine(new System.ComponentModel.WarningException("Wrong follow-up surveillance!").Message);
         }
     }
 }
Example #4
0
        public void PostSurgeryMortality(BE_Patient patientIn, BE_Cycle cycleIn, Random rand)
        {
            int    yearDifference = (cycleIn.ID - patientIn.SurgeryCycle) / 4; //  Assumption: Cycle length is three months.
            double mortality      = 0;

            if (patientIn.PreSurgeryStateName == "T1a")
            {
                mortality = postMortalityT1a[Math.Min(yearDifference, postMortalityT1a.Length - 1)];
            }
            else if (patientIn.PreSurgeryStateName == "T1b")
            {
                mortality = postMortalityT1b[Math.Min(yearDifference, postMortalityT1b.Length - 1)];
            }
            else if (patientIn.PreSurgeryStateName == "SC")
            {
                mortality = postMortalitySC[Math.Min(yearDifference, postMortalitySC.Length - 1)];
            }
            else
            {
                Console.WriteLine(new System.ComponentModel.WarningException("Wrong PostSurgeryMortality!").Message);
            }

            if (rand.NextDouble() <= mortality)
            {
                patientIn.Die("PostSurgery");
            }
        }
Example #5
0
        public void PerformSurgery(BE_Patient patientIn, BE_Cycle cycleIn, Random rand)
        {
            patientIn.Status = BE_PatientStatus.Surgery;
            patientIn.ActiveNaturalProgression    = false;                                 //  When patients undergo surgery, they no longer move under natural progression probabilities.
            patientIn.ActiveRecurrenceProbability = false;                                 //  When patients undergo surgery, they no longer move under recurrence probabilities.

            patientIn.HasSurgery = true;                                                   //  Assumption: Patient compliance is 100%.

            patientIn.PreSurgeryStateName = DeterminePreSurgeryStateName(patientIn, rand); //  The pre-surgery state of the patient is recorded.
            patientIn.SurgeryCycle        = cycleIn.ID;                                    //  The cycle in which the patient undergoes surgery is recorded.

            //  Intervention history is added to the patient's records.
            patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.Surgery);

            //  Cost is recorded on the patient, the surgery modality, and the cycle.
            patientIn.UpdateCost(costSurgery);
            this.UpdateCost(costSurgery);
            cycleIn.UpdateCost(costSurgery);

            //  Surgery-related mortality.
            double mortality = 0;

            if (patientIn.ConfirmedState.Type == BE_StateType.IMC)
            {
                mortality = mortalityIMC;
            }
            else
            {
                mortality = mortalitySC;
            }
            if (rand.NextDouble() < mortality)
            {
                patientIn.Die("Surgery_Mortality");
                return; // If the patient dies, the execution of this function is terminated.
            }

            //  Surgery-related adverse events.
            if (rand.NextDouble() <= adverseEvent.Probability)
            {
                patientIn.adverseEventHistory.Add(cycleIn.ID, BE_AdverseEventType.Surgery);

                patientIn.UpdateCost(adverseEvent.Cost);
                this.UpdateCost(adverseEvent.Cost);
                cycleIn.UpdateCost(adverseEvent.Cost);
            }

            //  Chemotherapy for some of the patients with SC.
            if (patientIn.ConfirmedState.Type == BE_StateType.SC)
            {
                if (rand.NextDouble() <= chemotherapyRatioSC)
                {
                    patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.Chemotherapy);

                    patientIn.UpdateCost(costChemotherapy);
                    this.UpdateCost(costChemotherapy);
                    cycleIn.UpdateCost(costChemotherapy);
                }
            }
            patientIn.NextTreatment = cycleIn.ID + 1;   // Assumption: Patients receive postsurgery care in each cycle.
        }
Example #6
0
        public void ScreenPatient(BE_Patient patientIn, BE_Cycle cycleIn, Random rand)
        {
            //  Six possible outcomes: "true_positive", "false_negative", "true_negative", "false_positive", "death", and "no_show"

            if (rand.NextDouble() <= adherence) //  The patient comply with the screening test.
            {
                //  Intervention history is added to the patient's records.
                patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.Screening);

                //  Cost is recorded on the patient, the screening modality, and the cycle.
                patientIn.UpdateCost(cost);
                this.UpdateCost(cost);
                cycleIn.UpdateCost(cost);

                //  Screening-related mortality.
                if (rand.NextDouble() <= mortality)
                {
                    patientIn.Die("Screening_" + type.ToString());
                    patientIn.screenResult.Add(BE_ScreeningResult.Death);
                    return; // If the patient dies, the execution of this function is terminated.
                }

                //  Screening-related adverse events.
                //  missing AE

                if (patientIn.CurrentState.Type != BE_StateType.NoBarretts) //  The patient is not in the NoBarretts state, it means the patient has the disease.
                {
                    if (rand.NextDouble() <= sensitivity)
                    {
                        patientIn.HasPositiveTest = true;
                        patientIn.screenResult.Add(BE_ScreeningResult.TruePositive);   //  Correct diagnosis of the disease.
                    }
                    else
                    {
                        patientIn.screenResult.Add(BE_ScreeningResult.FalseNegative);   //  Wrong diagnosis of the disease.
                    }
                }
                else     //  The patient is in the NoBarretts state, it means the patient is healthy.
                {
                    if (rand.NextDouble() <= specificity)
                    {
                        patientIn.screenResult.Add(BE_ScreeningResult.TrueNegative);   //  Correct diagnosis for the healthy patient.
                    }
                    else
                    {
                        patientIn.HasPositiveTest = true;
                        patientIn.screenResult.Add(BE_ScreeningResult.FalsePositive);   //  Wrong diagnosis for the healthy patient.
                    }
                }
            }
            else    //  The patient does not comply with the screening test.
            {
                patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.ScreeningNoShow);
                patientIn.screenResult.Add(BE_ScreeningResult.NoShow);
            }
        }
Example #7
0
        public void PostSurgeryCare(BE_Patient patientIn, BE_Cycle cycleIn)
        {
            //  Intervention history is added to the patient's records.
            patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.PostSurgery);

            //  Cost is recorded on the patient, the surgery modality, and the cycle.
            patientIn.UpdateCost(costAnnualPostCare / 4);
            this.UpdateCost(costAnnualPostCare / 4);
            cycleIn.UpdateCost(costAnnualPostCare / 4);

            patientIn.NextTreatment = cycleIn.ID + 1;   // Assumption: Patients receive postsurgery care in each cycle.
        }
Example #8
0
        public void GiveEETSession(BE_Patient patientIn, BE_Cycle cycleIn, BE_State[] statesIn, Random rand)
        {
            if (patientIn.CountEET == 0)
            {
                patientIn.Status                   = BE_PatientStatus.EET;
                patientIn.PreEETState              = patientIn.ConfirmedState;
                patientIn.RealPreEETState          = patientIn.CurrentState;
                patientIn.ActiveNaturalProgression = false;
            }
            patientIn.CountEET++;   //  Assumption: Patient compliance is 100%.

            //  Intervention history is added to the patient's records.
            patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.EET);

            //  Cost is recorded on the patient, the EET modality, and the cycle.
            patientIn.UpdateCost(costPerSession);
            this.UpdateCost(costPerSession);
            cycleIn.UpdateCost(costPerSession);

            //  EET-related mortality.
            if (rand.NextDouble() <= mortality)
            {
                patientIn.Die("EET_Mortality");
                return; // If the patient dies, the execution of this function is terminated.
            }

            //  EET-related adverse events.
            if (rand.NextDouble() <= adverseEvent.Probability)
            {
                patientIn.adverseEventHistory.Add(cycleIn.ID, BE_AdverseEventType.EET);

                patientIn.UpdateCost(adverseEvent.Cost);
                this.UpdateCost(adverseEvent.Cost);
                cycleIn.UpdateCost(adverseEvent.Cost);
            }

            if (patientIn.CountEET == sessionCount)
            {
                int nextStateID = FindEfficacyState(patientIn.RealPreEETState.ID, rand);
                patientIn.MoveEETEfficacy(statesIn[nextStateID], cycleIn);
            }
            else
            {
                patientIn.NextTreatment = cycleIn.ID + 2;   //  Assumption: EET sessions are held at six-month intervals.
            }
        }
Example #9
0
        public void SurveilPatient(BE_Patient patientIn, BE_Cycle cycleIn, Random rand)
        {
            if (rand.NextDouble() <= adherence) //  The patient comply with surveillance.
            {
                //  Intervention history is added to the patient's records.
                patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.Surveillance);

                //  Cost is recorded on the patient, the surveillance modality, and the cycle.
                patientIn.UpdateCost(cost);
                this.UpdateCost(cost);
                cycleIn.UpdateCost(cost);

                //  Surveillance-related mortality.
                if (rand.NextDouble() <= mortality)
                {
                    patientIn.Die("Surveillance");
                    return; // If the patient dies, the execution of this function is terminated.
                }

                //  Surveillance-related adverse events.
                if (rand.NextDouble() <= adverseEvent.Probability)
                {
                    patientIn.adverseEventHistory.Add(cycleIn.ID, BE_AdverseEventType.Surveillance);

                    patientIn.UpdateCost(adverseEvent.Cost);
                    this.UpdateCost(adverseEvent.Cost);
                    cycleIn.UpdateCost(adverseEvent.Cost);
                }

                if (rand.NextDouble() <= sensitivity)
                {
                    patientIn.ConfirmedState = patientIn.CurrentState;  //  Correct diagnosis of the health state.
                    SurveillanceDecision(patientIn, cycleIn, rand);
                }
                else
                {
                    patientIn.NextSurveillance = cycleIn.ID + intervalNDBE; //  Assumption: In the case of misdiagnosis, it is treated as NDBE.
                }
            }
            else
            {
                patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.SurveillanceNoShow);
                patientIn.NextSurveillance = cycleIn.ID + intervalNDBE; //  Assumption: If there is no adherence, it is treated as NDBE.
            }
        }
Example #10
0
        public void GiveTouchUpRFA(BE_Patient patientIn, BE_Cycle cycleIn, BE_State[] statesIn, Random rand)
        {
            patientIn.CountRFA++;   // Assumption: Patient compliance is 100 %.
            if (patientIn.CountRFA == maxTouchUpRFA)
            {
                patientIn.CompletedMaxRFA = true;
            }

            patientIn.CountFollowUp = 0;    //  The patient's follow-up intervals are reset.

            patientIn.PreEETState              = patientIn.ConfirmedState;
            patientIn.RealPreEETState          = patientIn.CurrentState;
            patientIn.ActiveNaturalProgression = false;

            //  Intervention history is added to the patient's records.
            patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.RFA);

            //  Cost is recorded on the patient, the EET modality, and the cycle.
            patientIn.UpdateCost(costRFA);
            this.UpdateCost(costRFA);
            cycleIn.UpdateCost(costRFA);

            //  EET-related mortality.
            if (rand.NextDouble() <= mortality)
            {
                patientIn.Die("RFA_Mortality");
                return; // If the patient dies, the execution of this function is terminated.
            }

            //  EET-related adverse events.
            if (rand.NextDouble() <= adverseEvent.Probability)
            {
                patientIn.adverseEventHistory.Add(cycleIn.ID, BE_AdverseEventType.RFA);

                patientIn.UpdateCost(adverseEvent.Cost);
                this.UpdateCost(adverseEvent.Cost);
                cycleIn.UpdateCost(adverseEvent.Cost);
            }

            int nextStateID = FindEfficacyState(patientIn.RealPreEETState.ID, rand);

            patientIn.MoveEETEfficacy(statesIn[nextStateID], cycleIn);
        }
Example #11
0
        public void GivePalliativeTreatment(BE_Patient patientIn, BE_Cycle cycleIn)
        {
            patientIn.Status = BE_PatientStatus.Palliative;
            patientIn.ActiveNaturalProgression    = false; //  When patients receive palliative treatment, they no longer move under natural progression probabilities.
            patientIn.ActiveRecurrenceProbability = false; //  When patients receive palliative treatment, they no longer move under recurrence probabilities.

            patientIn.UnderPalliative = true;              //  Assumption: Patient compliance is 100%.

            //  Intervention history is added to the patient's records.
            patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.Palliative);

            //  Cost is recorded on the patient, the palliative treatment modality, and the cycle.
            patientIn.UpdateCost(costAnnual / 4);   // Assumption: The cycle length is three months, and the palliative treatment cost is provided annually.
            this.UpdateCost(costAnnual / 4);
            cycleIn.UpdateCost(costAnnual / 4);

            //  Palliative treatment-related mortality is handled in the mortality part of the code.
            patientIn.NextTreatment = cycleIn.ID + 1;   // Assumption: Patients receive palliative treatment in each cycle.
        }
Example #12
0
 public bool IsSuitableForSurgery(BE_Patient patientIn, Random rand)
 {
     if (patientIn.ConfirmedState.Type == BE_StateType.IMC)
     {
         if (rand.NextDouble() <= surgicalIMC)
         {
             return(true);
         }
     }
     else if (patientIn.ConfirmedState.Type == BE_StateType.SC)
     {
         if (rand.NextDouble() <= treatableSC)
         {
             return(true);
         }
     }
     else
     {
         Console.WriteLine(new System.ComponentModel.WarningException("Cannot decide IsSuitableForSurgery!").Message);
     }
     return(false);
 }
Example #13
0
 public void SurveillanceDecision(BE_Patient patientIn, BE_Cycle cycleIn, Random rand)   //  Decides whether the patient needs treatment or when is the next surveillance cycle.
 {
     patientIn.Status = BE_PatientStatus.NaturalHistory;
     if (patientIn.ConfirmedState.Type == BE_StateType.NDBE)
     {
         patientIn.NextSurveillance      = cycleIn.ID + intervalNDBE;
         patientIn.IsLastSurveillanceLGD = false;    //  two times in a row is required
     }
     else if (patientIn.ConfirmedState.Type == BE_StateType.LGD)
     {
         if (patientIn.IsLastSurveillanceLGD == false)
         {
             patientIn.NextSurveillance      = cycleIn.ID + intervalLGD;
             patientIn.IsLastSurveillanceLGD = true;
         }
         else
         {
             if (rand.NextDouble() <= persistentLGD)
             {
                 patientIn.NextTreatment = cycleIn.ID;
             }
             else
             {
                 patientIn.NextSurveillance      = cycleIn.ID + intervalNDBE; //  Assumption: If it is not persistent LGD, it is treated as NDBE.
                 patientIn.IsLastSurveillanceLGD = false;
             }
         }
     }
     else if (patientIn.ConfirmedState.Type == BE_StateType.HGD || patientIn.ConfirmedState.Type == BE_StateType.IMC || patientIn.ConfirmedState.Type == BE_StateType.SC)
     {
         patientIn.NextTreatment = cycleIn.ID;
     }
     else
     {
         //  Shouldn't be here with since there is no natural regression to NoBarretts. But it can happen with false positives.
     }
 }
Example #14
0
        public void FollowUpSurveilPatient(BE_Patient patientIn, BE_Cycle cycleIn, Random rand)
        {
            patientIn.CountFollowUp++;  //  It increases whether the patient complies or not, because the follow-up intervals must be in conjunction with the guideline recommendations.

            if (rand.NextDouble() <= adherence)
            {
                //  Intervention history is added to the patient's records.
                patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.FollowUpSurveillance);

                //  Cost is recorded on the patient, the surveillance modality, and the cycle.
                patientIn.UpdateCost(cost);
                this.UpdateCost(cost);
                cycleIn.UpdateCost(cost);

                //  Surveillance-related mortality.
                if (rand.NextDouble() <= mortality)
                {
                    patientIn.Die("Follow-up surveillance");
                    return; // If the patient dies, the execution of this function is terminated.
                }

                //  Surveillance-related adverse events.
                if (rand.NextDouble() <= adverseEvent.Probability)
                {
                    patientIn.adverseEventHistory.Add(cycleIn.ID, BE_AdverseEventType.FollowUpSurveillance);

                    patientIn.UpdateCost(adverseEvent.Cost);
                    this.UpdateCost(adverseEvent.Cost);
                    cycleIn.UpdateCost(adverseEvent.Cost);
                }

                if (rand.NextDouble() <= sensitivity)  //  Correct diagnosis of the health state.
                {
                    patientIn.ConfirmedState = patientIn.CurrentState;
                    FollowUpSurveillanceDecision(patientIn, cycleIn);
                }
                else
                {
                    //  Assumption: In the case of misdiagnosis, the follow-up intervals continue the same based on patients pre-EET state.
                    if (patientIn.PreEETState.Type == BE_StateType.NDBE || patientIn.PreEETState.Type == BE_StateType.LGD)
                    {
                        patientIn.NextSurveillance = cycleIn.ID + postIntervalLGD[Math.Min(patientIn.CountFollowUp, postIntervalLGD.Length - 1)];
                    }
                    else if (patientIn.PreEETState.Type == BE_StateType.HGD || patientIn.PreEETState.Type == BE_StateType.IMC)
                    {
                        patientIn.NextSurveillance = cycleIn.ID + postIntervalHGD[Math.Min(patientIn.CountFollowUp, postIntervalHGD.Length - 1)];
                    }
                    else
                    {
                        Console.WriteLine(new System.ComponentModel.WarningException("Wrong follow-up surveillance!").Message);
                    }
                }
            }
            else
            {
                patientIn.interventionHistory.Add(cycleIn.ID, BE_InterventionType.FollowUpSurveillanceNoShow);

                //  Assumption: If there is no adherence, the follow-up intervals continue the same based on patients pre-EET state.
                if (patientIn.PreEETState.Type == BE_StateType.NDBE || patientIn.PreEETState.Type == BE_StateType.LGD)
                {
                    patientIn.NextSurveillance = cycleIn.ID + postIntervalLGD[Math.Min(patientIn.CountFollowUp, postIntervalLGD.Length - 1)];
                }
                else if (patientIn.PreEETState.Type == BE_StateType.HGD || patientIn.PreEETState.Type == BE_StateType.IMC)
                {
                    patientIn.NextSurveillance = cycleIn.ID + postIntervalHGD[Math.Min(patientIn.CountFollowUp, postIntervalHGD.Length - 1)];
                }
                else
                {
                    Console.WriteLine(new System.ComponentModel.WarningException("Wrong follow-up surveillance!").Message);
                }
            }
        }